* SLIM-VERSION: Fix.
[elisp/flim.git] / sasl.el
1 ;;; sasl.el --- basic functions for SASL
2
3 ;; Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
4
5 ;; Author: Kenichi OKADA <okada@opaopa.org>
6 ;; Keywords: SMTP, SASL, RFC2222
7
8 ;; This file is part of FLIM (Faithful Library about Internet Message).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'hmac-md5)
28
29 (defun sasl-cram-md5 (username passphrase challenge)
30   (let ((secure-word (copy-sequence passphrase)))
31     (setq secure-word (unwind-protect
32                           (hmac-md5 challenge secure-word)
33                         (fillarray secure-word 0))
34           secure-word (unwind-protect
35                           (encode-hex-string secure-word)
36                         (fillarray secure-word 0))
37           secure-word (unwind-protect
38                           (concat username " " secure-word)
39                         (fillarray secure-word 0)))))
40                 
41 (defun sasl-plain (authorid authenid passphrase)
42   (concat authorid "\0" authenid "\0" passphrase))
43
44 (provide 'sasl)
45
46 ;;; sasl.el ends here