Avoid floating-point exceptions while drawing underwave
[emacs.git] / lisp / net / sasl-cram.el
blobcd6c7e1a583ab0034e236f1c64c1208fb5c2e96f
1 ;;; sasl-cram.el --- CRAM-MD5 module for the SASL client framework
3 ;; Copyright (C) 2000, 2007-2017 Free Software Foundation, Inc.
5 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Kenichi OKADA <okada@opaopa.org>
7 ;; Keywords: SASL, CRAM-MD5
8 ;; Package: sasl
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 (require 'sasl)
28 (require 'hmac-md5)
30 (defconst sasl-cram-md5-steps
31 '(ignore ;no initial response
32 sasl-cram-md5-response))
34 (defun sasl-cram-md5-response (client step)
35 (let ((passphrase
36 (sasl-read-passphrase
37 (format "CRAM-MD5 passphrase for %s: "
38 (sasl-client-name client)))))
39 (unwind-protect
40 (concat (sasl-client-name client) " "
41 (encode-hex-string
42 (hmac-md5 (sasl-step-data step) passphrase)))
43 (fillarray passphrase 0))))
45 (put 'sasl-cram 'sasl-mechanism
46 (sasl-make-mechanism "CRAM-MD5" sasl-cram-md5-steps))
48 (provide 'sasl-cram)
50 ;;; sasl-cram.el ends here