(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-21 Kenichi OKADA <okada@opaopa.org>
+
+ * 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 <okada@opaopa.org>
* sasl.el (TopLevel): Autoload 'scram-md5' for `scram-make-security-info'.
PACKAGE = slim
API = 1.13
-RELEASE = 2
+RELEASE = 6
TAR = tar
RM = /bin/rm -f
(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)))
(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
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)
(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
(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)