diff options
| author | Stefan Monnier | 2008-05-08 14:19:51 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-08 14:19:51 +0000 |
| commit | 4fedcc004bb01336e15f2f1610e919bf9023f09e (patch) | |
| tree | 74037ea4c85b75e4bab3f8934e14c28435d270c8 | |
| parent | 9c059794a2a407f607e4cbf9f3cfde79bf50b58e (diff) | |
| download | emacs-4fedcc004bb01336e15f2f1610e919bf9023f09e.tar.gz emacs-4fedcc004bb01336e15f2f1610e919bf9023f09e.zip | |
(rfc2104-hexstring-to-bitstring): Rename it back from
rfc2104-hexstring-to-byte-list. Return a unibyte string.
(rfc2104-hash): Use it.
| -rw-r--r-- | lisp/gnus/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/gnus/rfc2104.el | 69 |
2 files changed, 43 insertions, 40 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 4f70aabd321..7de606761c7 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-05-08 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * rfc2104.el (rfc2104-hexstring-to-bitstring): Rename it back from | ||
| 4 | rfc2104-hexstring-to-byte-list. Return a unibyte string. | ||
| 5 | (rfc2104-hash): Use it. | ||
| 6 | |||
| 1 | 2008-05-08 Juanma Barranquero <lekktu@gmail.com> | 7 | 2008-05-08 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 8 | ||
| 3 | * gnus-art.el (gnus-article-toggle-truncate-lines): | 9 | * gnus-art.el (gnus-article-toggle-truncate-lines): |
| @@ -11,8 +17,8 @@ | |||
| 11 | (gnus-extract-address-component-email): Convenience functions around | 17 | (gnus-extract-address-component-email): Convenience functions around |
| 12 | `gnus-extract-address-components'. | 18 | `gnus-extract-address-components'. |
| 13 | 19 | ||
| 14 | * gnus-registry.el (gnus-registry-split-fancy-with-parent): Use | 20 | * gnus-registry.el (gnus-registry-split-fancy-with-parent): |
| 15 | `gnus-extract-address-component-email' to fix bug of comparing full | 21 | Use `gnus-extract-address-component-email' to fix bug of comparing full |
| 16 | sender name to `user-mail-address'. | 22 | sender name to `user-mail-address'. |
| 17 | 23 | ||
| 18 | 2008-05-05 Teodor Zlatanov <tzz@lifelogs.com> | 24 | 2008-05-05 Teodor Zlatanov <tzz@lifelogs.com> |
| @@ -696,7 +702,7 @@ | |||
| 696 | 702 | ||
| 697 | 2008-02-01 Kenichi Handa <handa@m17n.org> | 703 | 2008-02-01 Kenichi Handa <handa@m17n.org> |
| 698 | 704 | ||
| 699 | * rfc2104.el (rfc2104-hexstring-to-byte-list): Renamed from | 705 | * rfc2104.el (rfc2104-hexstring-to-byte-list): Rename from |
| 700 | rfc2104-hexstring-to-bitstring and changed to return a byte list. | 706 | rfc2104-hexstring-to-bitstring and changed to return a byte list. |
| 701 | (rfc2104-hash): Convert the result of concat to unibyte string. | 707 | (rfc2104-hash): Convert the result of concat to unibyte string. |
| 702 | 708 | ||
| @@ -707,7 +713,7 @@ | |||
| 707 | (gnus-gnus-to-quick-newsrc-format): Insert coding cookie. | 713 | (gnus-gnus-to-quick-newsrc-format): Insert coding cookie. |
| 708 | 714 | ||
| 709 | * mm-util.el (mm-hack-charsets, mm-iso-8859-15-compatible) | 715 | * mm-util.el (mm-hack-charsets, mm-iso-8859-15-compatible) |
| 710 | (mm-iso-8859-x-to-15-table, mm-iso-8859-x-to-15-region): Deleted. | 716 | (mm-iso-8859-x-to-15-table, mm-iso-8859-x-to-15-region): Delete. |
| 711 | (mm-find-mime-charset-region): Remove hack-charsets stuff. | 717 | (mm-find-mime-charset-region): Remove hack-charsets stuff. |
| 712 | 718 | ||
| 713 | 2008-01-24 Michael Sperber <sperber@deinprogramm.de> | 719 | 2008-01-24 Michael Sperber <sperber@deinprogramm.de> |
diff --git a/lisp/gnus/rfc2104.el b/lisp/gnus/rfc2104.el index a0090dc2687..c471b8b596d 100644 --- a/lisp/gnus/rfc2104.el +++ b/lisp/gnus/rfc2104.el | |||
| @@ -23,35 +23,35 @@ | |||
| 23 | 23 | ||
| 24 | ;;; Commentary: | 24 | ;;; Commentary: |
| 25 | 25 | ||
| 26 | ;;; This is a quick'n'dirty, low performance, implementation of RFC2104. | 26 | ;; This is a quick'n'dirty, low performance, implementation of RFC2104. |
| 27 | ;;; | 27 | ;; |
| 28 | ;;; Example: | 28 | ;; Example: |
| 29 | ;;; | 29 | ;; |
| 30 | ;;; (require 'md5) | 30 | ;; (require 'md5) |
| 31 | ;;; (rfc2104-hash 'md5 64 16 "Jefe" "what do ya want for nothing?") | 31 | ;; (rfc2104-hash 'md5 64 16 "Jefe" "what do ya want for nothing?") |
| 32 | ;;; "750c783e6ab0b503eaa86e310a5db738" | 32 | ;; "750c783e6ab0b503eaa86e310a5db738" |
| 33 | ;;; | 33 | ;; |
| 34 | ;;; (require 'sha-1) | 34 | ;; (require 'sha-1) |
| 35 | ;;; (rfc2104-hash 'sha1-encode 64 20 "Jefe" "what do ya want for nothing?") | 35 | ;; (rfc2104-hash 'sha1-encode 64 20 "Jefe" "what do ya want for nothing?") |
| 36 | ;;; "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79" | 36 | ;; "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79" |
| 37 | ;;; | 37 | ;; |
| 38 | ;;; 64 is block length of hash function (64 for MD5 and SHA), 16 is | 38 | ;; 64 is block length of hash function (64 for MD5 and SHA), 16 is |
| 39 | ;;; resulting hash length (16 for MD5, 20 for SHA). | 39 | ;; resulting hash length (16 for MD5, 20 for SHA). |
| 40 | ;;; | 40 | ;; |
| 41 | ;;; Tested with Emacs 20.2 and XEmacs 20.3. | 41 | ;; Tested with Emacs 20.2 and XEmacs 20.3. |
| 42 | ;;; | 42 | ;; |
| 43 | ;;; Test case reference: RFC 2202. | 43 | ;; Test case reference: RFC 2202. |
| 44 | 44 | ||
| 45 | ;;; Release history: | 45 | ;;; History: |
| 46 | ;;; | 46 | |
| 47 | ;;; 1998-08-16 initial release posted to gnu.emacs.sources | 47 | ;; 1998-08-16 initial release posted to gnu.emacs.sources |
| 48 | ;;; 1998-08-17 use append instead of char-list-to-string | 48 | ;; 1998-08-17 use append instead of char-list-to-string |
| 49 | ;;; 1998-08-26 don't require hexl | 49 | ;; 1998-08-26 don't require hexl |
| 50 | ;;; 1998-09-25 renamed from hmac.el to rfc2104.el, also renamed functions | 50 | ;; 1998-09-25 renamed from hmac.el to rfc2104.el, also renamed functions |
| 51 | ;;; 1999-10-23 included in pgnus | 51 | ;; 1999-10-23 included in pgnus |
| 52 | ;;; 2000-08-15 `rfc2104-hexstring-to-bitstring' | 52 | ;; 2000-08-15 `rfc2104-hexstring-to-bitstring' |
| 53 | ;;; 2000-05-12 added sha-1 example, added test case reference | 53 | ;; 2000-05-12 added sha-1 example, added test case reference |
| 54 | ;;; 2003-11-13 change rfc2104-hexstring-to-bitstring to ...-byte-list | 54 | ;; 2003-11-13 change rfc2104-hexstring-to-bitstring to ...-byte-list |
| 55 | 55 | ||
| 56 | ;;; Code: | 56 | ;;; Code: |
| 57 | 57 | ||
| @@ -87,12 +87,12 @@ | |||
| 87 | (rfc2104-hex-to-int (reverse (append str nil)))) | 87 | (rfc2104-hex-to-int (reverse (append str nil)))) |
| 88 | 0)) | 88 | 0)) |
| 89 | 89 | ||
| 90 | (defun rfc2104-hexstring-to-byte-list (str) | 90 | (defun rfc2104-hexstring-to-bitstring (str) |
| 91 | (let (out) | 91 | (let (out) |
| 92 | (while (< 0 (length str)) | 92 | (while (< 0 (length str)) |
| 93 | (push (rfc2104-hex-to-int (substring str -2)) out) | 93 | (push (rfc2104-hex-to-int (substring str -2)) out) |
| 94 | (setq str (substring str 0 -2))) | 94 | (setq str (substring str 0 -2))) |
| 95 | out)) | 95 | (apply (if (fboundp 'unibyte-string) 'unibyte-string 'string) out))) |
| 96 | 96 | ||
| 97 | (defun rfc2104-hash (hash block-length hash-length key text) | 97 | (defun rfc2104-hash (hash block-length hash-length key text) |
| 98 | (let* (;; if key is longer than B, reset it to HASH(key) | 98 | (let* (;; if key is longer than B, reset it to HASH(key) |
| @@ -109,12 +109,9 @@ | |||
| 109 | (setq k_ipad (mapcar (lambda (c) (logxor c rfc2104-ipad)) k_ipad)) | 109 | (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)) | 110 | (setq k_opad (mapcar (lambda (c) (logxor c rfc2104-opad)) k_opad)) |
| 111 | ;; perform outer hash | 111 | ;; perform outer hash |
| 112 | (funcall hash | 112 | (funcall hash (concat k_opad (rfc2104-hexstring-to-bitstring |
| 113 | (encode-coding-string | ||
| 114 | (concat k_opad (rfc2104-hexstring-to-byte-list | ||
| 115 | ;; perform inner hash | 113 | ;; perform inner hash |
| 116 | (funcall hash (concat k_ipad text)))) | 114 | (funcall hash (concat k_ipad text))))))) |
| 117 | 'iso-latin-1)))) | ||
| 118 | 115 | ||
| 119 | (provide 'rfc2104) | 116 | (provide 'rfc2104) |
| 120 | 117 | ||