sasl-cram.el 1.5 KB

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