From: okada Date: Fri, 21 Jan 2000 10:05:22 +0000 (+0000) Subject: * digest-md5.el (TopLevel): Delete `digest-md5-nonce-count'. X-Git-Tag: slim-1_13_6~6 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10c6c6970b80cdb21a5af50573f943f9fb1fffa5;p=elisp%2Fflim.git * digest-md5.el (TopLevel): Delete `digest-md5-nonce-count'. (digest-md5-build-response-value): Add `realm', `nonce' and `nonce-count'. (digest-md5-digest-response): Add options as RFC. * sasl.el (TopLevel): New variable `sasl-digest-md5-nonce-count'. New functions `sasl-digest-md5-digest-response' and `sasl-digest-md5-parse-digest-challenge'. * smtp.el (TopLevel): New function `smtp-auth-digest-md5'. --- diff --git a/ChangeLog b/ChangeLog index 2879765..e940d92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-01-21 Kenichi OKADA + + * digest-md5.el (TopLevel): Delete `digest-md5-nonce-count'. + (digest-md5-build-response-value): Add `realm', `nonce' and `nonce-count'. + (digest-md5-digest-response): Add options as RFC. + * sasl.el (TopLevel): New variable `sasl-digest-md5-nonce-count'. + New functions `sasl-digest-md5-digest-response' and + `sasl-digest-md5-parse-digest-challenge'. + * smtp.el (TopLevel): New function `smtp-auth-digest-md5'. + 2000-01-06 Kenichi OKADA * sasl.el (TopLevel): Autoload 'scram-md5' for `scram-make-security-info'. diff --git a/Makefile b/Makefile index d318299..12f0d2c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PACKAGE = slim API = 1.13 -RELEASE = 2 +RELEASE = 6 TAR = tar RM = /bin/rm -f diff --git a/digest-md5.el b/digest-md5.el index cb4d697..4ecd228 100644 --- a/digest-md5.el +++ b/digest-md5.el @@ -48,7 +48,7 @@ (require 'unique-id) (defvar digest-md5-challenge nil) -(defvar digest-md5-nonce-count 1) +;(defvar digest-md5-nonce-count 1) (defvar digest-md5-parse-digest-challenge-syntax-table (let ((table (make-syntax-table))) @@ -90,22 +90,22 @@ (defmacro digest-md5-challenge (prop) (list 'get ''digest-md5-challenge prop)) -(defmacro digest-md5-build-response-value - (username passwd cnonce digest-uri qop) +(defmacro digest-md5-build-response-value + (username realm passwd nonce cnonce nonce-count digest-uri qop) `(encode-hex-string (md5-binary (concat (encode-hex-string (md5-binary (concat (md5-binary (concat ,username - ":" (digest-md5-challenge 'realm) + ":" ,realm ":" ,passwd)) - ":" (digest-md5-challenge 'nonce) + ":" ,nonce ":" ,cnonce (let ((authzid (digest-md5-challenge 'authzid))) (if authzid (concat ":" authzid) nil))))) - ":" (digest-md5-challenge 'nonce) - ":" (format "%08x" digest-md5-nonce-count) ":" ,cnonce ":" ,qop ":" + ":" ,nonce + ":" (format "%08x" ,nonce-count) ":" ,cnonce ":" ,qop ":" (encode-hex-string (md5-binary (concat "AUTHENTICATE:" ,digest-uri @@ -114,28 +114,30 @@ nil)))))))) ;;;###autoload -(defun digest-md5-digest-response (username passwd digest-uri &optional qop) - (let ((cnonce (digest-md5-cnonce))) - (concat - "username=\"" username "\"," - "realm=\"" (digest-md5-challenge 'realm) "\"," - "nonce=\"" (digest-md5-challenge 'nonce) "\"," - (format "nc=%08x," digest-md5-nonce-count) - "cnonce=\"" cnonce "\"," - "digest-uri=\"" digest-uri "\"," - "response=" - (digest-md5-build-response-value username passwd cnonce digest-uri - (or qop "auth")) - "," - (mapconcat - #'identity - (delq nil - (mapcar (lambda (prop) - (if (digest-md5-challenge prop) - (format "%s=%s" - prop (digest-md5-challenge prop)))) - '(charset qop maxbuf cipher authzid))) - ",")))) +(defun digest-md5-digest-response + (username realm passwd nonce cnonce nonce-count digest-uri + &optional charset qop maxbuf cipher authzid) + (concat + "username=\"" username "\"," + "realm=\"" realm "\"," + "nonce=\"" nonce "\"," + (format "nc=%08x," nonce-count) + "cnonce=\"" cnonce "\"," + "digest-uri=\"" digest-uri "\"," + "response=" + (digest-md5-build-response-value + username realm passwd nonce cnonce nonce-count digest-uri + (or qop "auth")) + "," + (mapconcat + #'identity + (delq nil + (mapcar (lambda (prop) + (if (digest-md5-challenge prop) + (format "%s=%s" + prop (digest-md5-challenge prop)))) + '(charset qop maxbuf cipher authzid))) + ","))) (provide 'digest-md5) diff --git a/sasl.el b/sasl.el index e43291c..dff52d6 100644 --- a/sasl.el +++ b/sasl.el @@ -134,6 +134,25 @@ (scram-md5-parse-server-msg-1 server-msg-1)) salted-pass))) +;;; DIGEST-MD5 + +(defvar sasl-digest-md5-nonce-count 1) + +(defun sasl-digest-md5-digest-response (username passwd + serv-type host &optional realm) + (digest-md5-digest-response + username + (or realm (digest-md5-challenge 'realm)) ;; need to check. + passwd + (digest-md5-challenge 'nonce) + (digest-md5-cnonce) + sasl-digest-md5-nonce-count + (digest-md5-digest-uri serv-type host) ;; MX host + )) + +(defun sasl-digest-md5-parse-digest-challenge (digest-challenge) + (digest-md5-parse-digest-challenge digest-challenge)) + (provide 'sasl) ;;; sasl.el ends here \ No newline at end of file diff --git a/smtp.el b/smtp.el index 02e9d38..913e1a4 100644 --- a/smtp.el +++ b/smtp.el @@ -659,29 +659,35 @@ don't define this value." (defun smtp-auth-digest-md5 (process) "Login to server using the AUTH DIGEST-MD5 method." - (let (responce) + (let (user realm responce) (smtp-send-command process "AUTH DIGEST-MD5") (setq response (smtp-read-response process)) (if (or (null (car response)) (not (integerp (car response))) (>= (car response) 400)) (throw 'done (car (cdr response)))) - (digest-md5-parse-digest-challenge + (sasl-digest-md5-parse-digest-challenge (base64-decode-string (substring (car (cdr response)) 4))) + (if (string-match "^\\([^@]*\\)@\\([^@]*\\)" + smtp-authenticate-user) + (setq user (match-string 1 smtp-authenticate-user) + realm (match-string 2 smtp-authenticate-user)) + (setq user smtp-authenticate-user + realm nil)) (smtp-send-command process - (base64-encode-string - (digest-md5-digest-response - smtp-authenticate-user - smtp-authenticate-passphrase - (digest-md5-digest-uri - "smtp" (digest-md5-challenge 'realm))) - 'no-line-break)) + (base64-encode-string + (sasl-digest-md5-digest-response + user + smtp-authenticate-passphrase + "smtp" smtp-server realm) + 'no-line-break)) (setq response (smtp-read-response process)) (if (or (null (car response)) (not (integerp (car response))) (>= (car response) 400)) - (throw 'done (car (cdr response)))))) + (throw 'done (car (cdr response)))) + (smtp-send-command process ""))) (provide 'smtp)