annotate lisp/net/sasl-cram.el @ 106143:50585d0e8c11

(math-use-emacs-fn): Let `calc-twos-complement-mode' be nil.
author Jay Belanger <jay.p.belanger@gmail.com>
date Fri, 20 Nov 2009 00:58:54 +0000
parents a9dc0e7c3f2b
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86994
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
1 ;;; sasl-cram.el --- CRAM-MD5 module for the SASL client framework
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
2
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 94677
diff changeset
3 ;; Copyright (C) 2000, 2007, 2008, 2009 Free Software Foundation, Inc.
86994
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
4
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
5 ;; Author: Daiki Ueno <ueno@unixuser.org>
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
6 ;; Kenichi OKADA <okada@opaopa.org>
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
7 ;; Keywords: SASL, CRAM-MD5
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
8
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
10
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
86994
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; (at your option) any later version.
86994
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
15
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
20
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
86994
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
23
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
25
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
26 (require 'sasl)
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
27 (require 'hmac-md5)
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
28
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
29 (defconst sasl-cram-md5-steps
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
30 '(ignore ;no initial response
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
31 sasl-cram-md5-response))
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
32
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
33 (defun sasl-cram-md5-response (client step)
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
34 (let ((passphrase
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
35 (sasl-read-passphrase
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
36 (format "CRAM-MD5 passphrase for %s: "
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
37 (sasl-client-name client)))))
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
38 (unwind-protect
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
39 (concat (sasl-client-name client) " "
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
40 (encode-hex-string
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
41 (hmac-md5 (sasl-step-data step) passphrase)))
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
42 (fillarray passphrase 0))))
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
43
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
44 (put 'sasl-cram 'sasl-mechanism
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
45 (sasl-make-mechanism "CRAM-MD5" sasl-cram-md5-steps))
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
46
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
47 (provide 'sasl-cram)
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
48
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87665
diff changeset
49 ;; arch-tag: 46cb281b-975a-4fe0-a39f-3018691b1b05
86994
09dace156f42 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
50 ;;; sasl-cram.el ends here