Merge from emacs--devo--0
[gnus] / lisp / rfc2104.el
index cea9f58..43bbae9 100644 (file)
@@ -1,5 +1,7 @@
 ;;; rfc2104.el --- RFC2104 Hashed Message Authentication Codes
-;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <jas@pdc.kth.se>
 ;; Keywords: mail
@@ -8,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -51,6 +53,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:
 
        (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)
     (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)