Mercurial > emacs
comparison lisp/gnus/rfc2104.el @ 49598:0d8b17d428b5
Trailing whitepace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 13:24:35 +0000 |
parents | a26d9b55abb6 |
children | 695cf19ef79e d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49597:e88404e8f2cf | 49598:0d8b17d428b5 |
---|---|
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 | 54 |
55 ;;; Code: | 55 ;;; Code: |
56 | 56 |
57 (eval-when-compile (require 'cl)) | 57 (eval-when-compile (require 'cl)) |
58 | 58 |
59 ;; Magic character for inner HMAC round. 0x36 == 54 == '6' | 59 ;; Magic character for inner HMAC round. 0x36 == 54 == '6' |
60 (defconst rfc2104-ipad ?\x36) | 60 (defconst rfc2104-ipad ?\x36) |
61 | 61 |
64 | 64 |
65 ;; Not so magic character for padding the key. 0x00 | 65 ;; Not so magic character for padding the key. 0x00 |
66 (defconst rfc2104-zero ?\x00) | 66 (defconst rfc2104-zero ?\x00) |
67 | 67 |
68 ;; Alist for converting hex to decimal. | 68 ;; Alist for converting hex to decimal. |
69 (defconst rfc2104-hex-alist | 69 (defconst rfc2104-hex-alist |
70 '((?0 . 0) (?a . 10) (?A . 10) | 70 '((?0 . 0) (?a . 10) (?A . 10) |
71 (?1 . 1) (?b . 11) (?B . 11) | 71 (?1 . 1) (?b . 11) (?B . 11) |
72 (?2 . 2) (?c . 12) (?C . 12) | 72 (?2 . 2) (?c . 12) (?C . 12) |
73 (?3 . 3) (?d . 13) (?D . 13) | 73 (?3 . 3) (?d . 13) (?D . 13) |
74 (?4 . 4) (?e . 14) (?E . 14) | 74 (?4 . 4) (?e . 14) (?E . 14) |
93 (setq str (substring str 0 -2))) | 93 (setq str (substring str 0 -2))) |
94 (concat out))) | 94 (concat out))) |
95 | 95 |
96 (defun rfc2104-hash (hash block-length hash-length key text) | 96 (defun rfc2104-hash (hash block-length hash-length key text) |
97 (let* (;; if key is longer than B, reset it to HASH(key) | 97 (let* (;; if key is longer than B, reset it to HASH(key) |
98 (key (if (> (length key) block-length) | 98 (key (if (> (length key) block-length) |
99 (funcall hash key) key)) | 99 (funcall hash key) key)) |
100 (k_ipad (append key nil)) | 100 (k_ipad (append key nil)) |
101 (k_opad (append key nil))) | 101 (k_opad (append key nil))) |
102 ;; zero pad k_ipad/k_opad | 102 ;; zero pad k_ipad/k_opad |
103 (while (< (length k_ipad) block-length) | 103 (while (< (length k_ipad) block-length) |