emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rfc2104 change on 2008-02-01


From: Stefan Monnier
Subject: Re: rfc2104 change on 2008-02-01
Date: Fri, 25 Apr 2008 10:28:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> I have tracked down a problem sending authenticated e-mail that resulted
> in randomly failed CRAM-MD5 authentication (it sometimes work, usually
> after 2-3 retries).  The cause is:

> 2008-02-01  Kenichi Handa  <address@hidden>

>         * rfc2104.el (rfc2104-hexstring-to-byte-list): Renamed from
>         rfc2104-hexstring-to-bitstring and changed to return a byte list.

This might be the problem: why return a byte-list rather than
a unicode string?

How 'bout the patch below?


        Stefan


--- rfc2104.el.~1.14.~  2008-04-10 21:03:54.000000000 -0400
+++ rfc2104.el  2008-04-25 10:27:16.000000000 -0400
@@ -89,12 +89,12 @@
        (rfc2104-hex-to-int (reverse (append str nil))))
     0))
 
-(defun rfc2104-hexstring-to-byte-list (str)
+(defun rfc2104-hexstring-to-bitstring (str)
   (let (out)
     (while (< 0 (length str))
       (push (rfc2104-hex-to-int (substring str -2)) out)
       (setq str (substring str 0 -2)))
-    out))
+    (apply (if (fboundp 'unibyte-string) 'unibyte-string 'string) out)))
 
 (defun rfc2104-hash (hash block-length hash-length key text)
   (let* (;; if key is longer than B, reset it to HASH(key)
@@ -111,12 +111,9 @@
     (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
-            (encode-coding-string
-             (concat k_opad (rfc2104-hexstring-to-byte-list
+    (funcall hash (concat k_opad (rfc2104-hexstring-to-bitstring
                              ;; perform inner hash
-                             (funcall hash (concat k_ipad text))))
-             'iso-latin-1))))
+                                 (funcall hash (concat k_ipad text)))))))
 
 (provide 'rfc2104)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]