sasl-ntlm.el 2.3 KB

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