From: okada Date: Thu, 9 Dec 1999 04:11:34 +0000 (+0000) Subject: * sasl.el (sasl-number-base36): New function. X-Git-Tag: slim-1_13_5~30 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f38e7df68371b717f2e6df9164cca4090674faf6;p=elisp%2Fflim.git * sasl.el (sasl-number-base36): New function. (sasl-unique-id): New function. (sasl-unique-id-char): New variable. * scram-md5.el (scram-make-unique-nonce): Fix to use `sasl-unique-id'. --- diff --git a/ChangeLog b/ChangeLog index 2fcc4e0..efd3db1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 1999-12-06 Kenichi OKADA + * sasl.el (sasl-number-base36): New function. + (sasl-unique-id): New function. + (sasl-unique-id-char): New variable. + * scram-md5.el (scram-make-unique-nonce): Fix to use `sasl-unique-id'. + +1999-12-06 Kenichi OKADA + + * sha1-el.el: Fix. + * hex-util.el: Fix. + + +1999-12-06 Kenichi OKADA + * SLIM: Version 1.13.4 released. 1999-12-04 Kenichi OKADA diff --git a/sasl.el b/sasl.el index db86609..29bf560 100644 --- a/sasl.el +++ b/sasl.el @@ -41,6 +41,56 @@ (defun sasl-plain (authorid authenid passphrase) (concat authorid "\0" authenid "\0" passphrase)) +(defun sasl-number-base36 (num len) + (if (if (< len 0) + (<= num 0) + (= len 0)) + "" + (concat (sasl-number-base36 (/ num 36) (1- len)) + (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210" + (% num 36)))))) + +(defvar sasl-unique-id-char nil) + +(defun sasl-unique-id () + ;; Don't use microseconds from (current-time), they may be unsupported. + ;; Instead we use this randomly inited counter. + (setq sasl-unique-id-char + (% (1+ (or sasl-unique-id-char (logand (random t) (1- (lsh 1 20))))) + ;; (current-time) returns 16-bit ints, + ;; and 2^16*25 just fits into 4 digits i base 36. + (* 25 25))) + (let ((tm (static-if (fboundp 'current-time) + (current-time) + (let* ((cts (split-string (current-time-string) "[ :]")) + (m (cdr (assoc (nth 1 cts) + '(("Jan" . "01") ("Feb" . "02") + ("Mar" . "03") ("Apr" . "04") + ("May" . "05") ("Jun" . "06") + ("Jul" . "07") ("Aug" . "08") + ("Sep" . "09") ("Oct" . "10") + ("Nov" . "11") ("Dec" . "12")))))) + (list (string-to-int (concat (nth 6 cts) m + (substring (nth 2 cts) 0 1))) + (string-to-int (concat (substring (nth 2 cts) 1) + (nth 4 cts) (nth 5 cts) + (nth 6 cts)))))))) + (concat + (if (memq system-type '(ms-dos emx vax-vms)) + (let ((user (downcase (user-login-name)))) + (while (string-match "[^a-z0-9_]" user) + (aset user (match-beginning 0) ?_)) + user) + (sasl-number-base36 (user-uid) -1)) + (sasl-number-base36 (+ (car tm) + (lsh (% sasl-unique-id-char 25) 16)) 4) + (sasl-number-base36 (+ (nth 1 tm) + (lsh (/ sasl-unique-id-char 25) 16)) 4) + ;; Append the name of the message interface, because while the + ;; generated ID is unique to this newsreader, other newsreaders + ;; might otherwise generate the same ID via another algorithm. + ".sasl"))) + (provide 'sasl) ;;; sasl.el ends here diff --git a/scram-md5.el b/scram-md5.el index 7a22f27..1d885e2 100644 --- a/scram-md5.el +++ b/scram-md5.el @@ -64,7 +64,7 @@ (defun scram-make-unique-nonce () ; 8*OCTET, globally unique. ;; For example, concatenated string of process-identifier, system-clock, ;; sequence-number, random-number, and domain-name. - (concat "<" "foo" "bar" "baz" "@" (system-name) ">")) ; TEMPORARY + (concat "<" (sasl-unique-id) "@" (system-name) ">")) (defun scram-xor-string (str1 str2) ;; (length str1) == (length str2) == (length dst) == 16 (in SCRAM-MD5)