/[emacs]/emacs/lisp/gnus/rfc2104.el
ViewVC logotype

Diff of /emacs/lisp/gnus/rfc2104.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by lektu, Tue Feb 4 13:06:38 2003 UTC revision 1.4.6.1 by handa, Thu Nov 13 08:49:29 2003 UTC
# Line 51  Line 51 
51  ;;; 1999-10-23  included in pgnus  ;;; 1999-10-23  included in pgnus
52  ;;; 2000-08-15  `rfc2104-hexstring-to-bitstring'  ;;; 2000-08-15  `rfc2104-hexstring-to-bitstring'
53  ;;; 2000-05-12  added sha-1 example, added test case reference  ;;; 2000-05-12  added sha-1 example, added test case reference
54    ;;; 2003-11-13  change rfc2104-hexstring-to-bitstring to ...-byte-list
55    
56  ;;; Code:  ;;; Code:
57    
# Line 86  Line 87 
87          (rfc2104-hex-to-int (reverse (append str nil))))          (rfc2104-hex-to-int (reverse (append str nil))))
88      0))      0))
89    
90  (defun rfc2104-hexstring-to-bitstring (str)  (defun rfc2104-hexstring-to-byte-list (str)
91    (let (out)    (let (out)
92      (while (< 0 (length str))      (while (< 0 (length str))
93        (push (rfc2104-hex-to-int (substring str -2)) out)        (push (rfc2104-hex-to-int (substring str -2)) out)
94        (setq str (substring str 0 -2)))        (setq str (substring str 0 -2)))
95      (concat out)))      out))
96    
97  (defun rfc2104-hash (hash block-length hash-length key text)  (defun rfc2104-hash (hash block-length hash-length key text)
98    (let* (;; if key is longer than B, reset it to HASH(key)    (let* (;; if key is longer than B, reset it to HASH(key)
# Line 108  Line 109 
109      (setq k_ipad (mapcar (lambda (c) (logxor c rfc2104-ipad)) k_ipad))      (setq k_ipad (mapcar (lambda (c) (logxor c rfc2104-ipad)) k_ipad))
110      (setq k_opad (mapcar (lambda (c) (logxor c rfc2104-opad)) k_opad))      (setq k_opad (mapcar (lambda (c) (logxor c rfc2104-opad)) k_opad))
111      ;; perform outer hash      ;; perform outer hash
112      (funcall hash (concat k_opad (rfc2104-hexstring-to-bitstring      (funcall hash
113                                    ;; perform inner hash               (encode-coding-string
114                                    (funcall hash (concat k_ipad text)))))))                (concat k_opad (rfc2104-hexstring-to-byte-list
115                                  ;; perform inner hash
116                                  (funcall hash (concat k_ipad text))))
117                  'iso-latin-1))))
118    
119  (provide 'rfc2104)  (provide 'rfc2104)
120    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.4.6.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26