1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-09 15:50:21 +00:00

* rfc2104.el (rfc2104-hexstring-to-byte-list): Renamed from

rfc2104-hexstring-to-bitstring and changed to return a byte list.
(rfc2104-hash): Convert the result of concat to unibyte string.
This commit is contained in:
Kenichi Handa 2003-11-13 08:49:29 +00:00
parent 93ff0d1e66
commit a62e3ee2c8

View File

@ -51,6 +51,7 @@
;;; 1999-10-23 included in pgnus
;;; 2000-08-15 `rfc2104-hexstring-to-bitstring'
;;; 2000-05-12 added sha-1 example, added test case reference
;;; 2003-11-13 change rfc2104-hexstring-to-bitstring to ...-byte-list
;;; Code:
@ -86,12 +87,12 @@
(rfc2104-hex-to-int (reverse (append str nil))))
0))
(defun rfc2104-hexstring-to-bitstring (str)
(defun rfc2104-hexstring-to-byte-list (str)
(let (out)
(while (< 0 (length str))
(push (rfc2104-hex-to-int (substring str -2)) out)
(setq str (substring str 0 -2)))
(concat out)))
out))
(defun rfc2104-hash (hash block-length hash-length key text)
(let* (;; if key is longer than B, reset it to HASH(key)
@ -108,9 +109,12 @@
(setq k_ipad (mapcar (lambda (c) (logxor c rfc2104-ipad)) k_ipad))
(setq k_opad (mapcar (lambda (c) (logxor c rfc2104-opad)) k_opad))
;; perform outer hash
(funcall hash (concat k_opad (rfc2104-hexstring-to-bitstring
;; perform inner hash
(funcall hash (concat k_ipad text)))))))
(funcall hash
(encode-coding-string
(concat k_opad (rfc2104-hexstring-to-byte-list
;; perform inner hash
(funcall hash (concat k_ipad text))))
'iso-latin-1))))
(provide 'rfc2104)