Commit | Line | Data |
---|---|---|
369fc5a6 GM |
1 | ;;; sasl-ntlm.el --- NTLM (NT Lan Manager) module for the SASL client framework |
2 | ||
73b0cd50 | 3 | ;; Copyright (C) 2000, 2007-2011 Free Software Foundation, Inc. |
369fc5a6 GM |
4 | |
5 | ;; Author: Taro Kawagishi <tarok@transpulse.org> | |
6 | ;; Keywords: SASL, NTLM | |
7 | ;; Version: 1.00 | |
8 | ;; Created: February 2001 | |
bd78fa1d | 9 | ;; Package: sasl |
369fc5a6 GM |
10 | |
11 | ;; This file is part of GNU Emacs. | |
12 | ||
874a927a | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
369fc5a6 | 14 | ;; it under the terms of the GNU General Public License as published by |
874a927a GM |
15 | ;; the Free Software Foundation, either version 3 of the License, or |
16 | ;; (at your option) any later version. | |
369fc5a6 GM |
17 | |
18 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;; GNU General Public License for more details. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
874a927a | 24 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
369fc5a6 GM |
25 | |
26 | ;;; Commentary: | |
27 | ||
28 | ;; This is a SASL interface layer for NTLM authentication message | |
29 | ;; generation by ntlm.el | |
30 | ||
31 | ;;; Code: | |
32 | ||
33 | (require 'sasl) | |
34 | (require 'ntlm) | |
35 | ||
36 | (defconst sasl-ntlm-steps | |
37 | '(ignore ;nothing to do before making | |
38 | sasl-ntlm-request ;authentication request | |
39 | sasl-ntlm-response) ;response to challenge | |
ea597303 JB |
40 | "A list of functions to be called in sequence for the NTLM |
41 | authentication steps. They are called by `sasl-next-step'.") | |
369fc5a6 GM |
42 | |
43 | (defun sasl-ntlm-request (client step) | |
44 | "SASL step function to generate a NTLM authentication request to the server. | |
ea597303 | 45 | Called from `sasl-next-step'. |
369fc5a6 GM |
46 | CLIENT is a vector [mechanism user service server sasl-client-properties] |
47 | STEP is a vector [<previous step function> <result of previous step function>]" | |
48 | (let ((user (sasl-client-name client))) | |
49 | (ntlm-build-auth-request user))) | |
50 | ||
51 | (defun sasl-ntlm-response (client step) | |
52 | "SASL step function to generate a NTLM response against the server | |
ea597303 | 53 | challenge stored in the 2nd element of STEP. Called from `sasl-next-step'." |
369fc5a6 GM |
54 | (let* ((user (sasl-client-name client)) |
55 | (passphrase | |
56 | (sasl-read-passphrase (format "NTLM passphrase for %s: " user))) | |
57 | (challenge (sasl-step-data step))) | |
58 | (ntlm-build-auth-response challenge user | |
59 | (ntlm-get-password-hashes passphrase)))) | |
60 | ||
61 | (put 'sasl-ntlm 'sasl-mechanism | |
62 | (sasl-make-mechanism "NTLM" sasl-ntlm-steps)) | |
63 | ||
64 | (provide 'sasl-ntlm) | |
65 | ||
369fc5a6 | 66 | ;;; sasl-ntlm.el ends here |