Function: sasl-scram--authenticate-server
sasl-scram--authenticate-server is a byte-compiled function defined in
sasl-scram-rfc.el.gz.
Signature
(sasl-scram--authenticate-server HASH-FUN BLOCK-LENGTH HASH-LENGTH CLIENT STEP)
Source Code
;; Defined in /usr/src/emacs/lisp/net/sasl-scram-rfc.el.gz
(defun sasl-scram--authenticate-server (hash-fun block-length hash-length client step)
(cond
((string-match "^e=\\([^,]+\\)" (sasl-step-data step))
(sasl-error (format "Server error: %s" (match-string 1 (sasl-step-data step)))))
((string-match "^v=\\([^,]+\\)" (sasl-step-data step))
(let* ((hmac-fun (lambda (text key)
(decode-hex-string
(rfc2104-hash hash-fun block-length hash-length key text))))
(verifier (base64-decode-string (match-string 1 (sasl-step-data step))))
(auth-message (sasl-client-property client 'auth-message))
(salted-password (sasl-client-property client 'salted-password))
(server-key (funcall hmac-fun "Server Key" salted-password))
(expected-server-signature
(funcall hmac-fun (encode-coding-string auth-message 'utf-8) server-key)))
(unless (string= expected-server-signature verifier)
(sasl-error "Server not authenticated"))))
(t
(sasl-error "Invalid response from server"))))