[gnus git] branch master updated: m0-11-53-geac6893 =1= ntlm.el (ntlm-string-make-unibyte, ntlm-secure-hash): New compatibility functions. (ntlm-build-auth-response): Use them.
Katsumi <[email protected]> Mon, 06 Oct 2014 01:47:55 +0200
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via eac68931aa33d79c85ca6f118eb15ffe8489c4fc (commit)
from 7fbdd10147ea27d0eb211fa6eb4cd203d8340720 (commit)
- Log -----------------------------------------------------------------
commit eac68931aa33d79c85ca6f118eb15ffe8489c4fc
Author: Katsumi Yamaoka <[email protected]>
Date: Sun Oct 5 23:47:14 2014 +0000
ntlm.el (ntlm-string-make-unibyte, ntlm-secure-hash):
New compatibility functions.
(ntlm-build-auth-response): Use them.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 02acc59..8f67eaf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-05 Katsumi Yamaoka <[email protected]>
+
+ * ntlm.el (ntlm-string-make-unibyte, ntlm-secure-hash):
+ New compatibility functions.
+ (ntlm-build-auth-response): Use them.
+
2014-10-04 Thomas Fitzsimmons <[email protected]>
* ntlm.el (ntlm-build-auth-request):
diff --git a/lisp/ntlm.el b/lisp/ntlm.el
index 30958aa..ef6e020 100644
--- a/lisp/ntlm.el
+++ b/lisp/ntlm.el
@@ -110,8 +110,46 @@ is not given."
(defmacro ntlm-string-as-unibyte (string)
(if (fboundp 'string-as-unibyte)
`(string-as-unibyte ,string)
+ string))
+ (defmacro ntlm-string-make-unibyte (string)
+ (if (fboundp 'string-make-unibyte)
+ `(string-make-unibyte ,string)
string)))
+(eval-and-compile
+ (autoload 'sha1 "sha1")
+ (if (fboundp 'secure-hash)
+ (defalias 'ntlm-secure-hash 'secure-hash)
+ (defun ntlm-secure-hash (algorithm object &optional start end binary)
+ "Return the secure hash of OBJECT, a buffer or string.
+ALGORITHM is a symbol specifying the hash to use: md5, sha1.
+
+The two optional arguments START and END are positions specifying for
+which part of OBJECT to compute the hash. If nil or omitted, uses the
+whole OBJECT.
+
+If BINARY is non-nil, returns a string in binary form."
+ (cond ((eq algorithm 'md5)
+ (if binary
+ (let* ((hex (md5 object start end))
+ (len (length hex))
+ (beg 0)
+ rest)
+ (while (< beg len)
+ (push (ntlm-string-make-unibyte
+ (char-to-string
+ (string-to-number
+ (substring hex beg (setq beg (+ beg 2)))
+ 16)))
+ rest))
+ (apply #'concat (nreverse rest)))
+ (md5 object start end)))
+ ((eq algorithm 'sha1)
+ (sha1 object start end binary))
+ (t
+ (error "(ntlm-secure-hash) Unsupported algorithm: %s"
+ algorithm))))))
+
(defun ntlm-build-auth-response (challenge user password-hashes)
"Return the response string to a challenge string CHALLENGE given by
the NTLM based server for the user USER and the password hash list
@@ -149,7 +187,7 @@ by PASSWORD-HASHES. PASSWORD-HASHES should be a return value of
(let (randomString
sessionHash)
;; generate NTLM2 session response data
- (setq randomString (string-make-unibyte
+ (setq randomString (ntlm-string-make-unibyte
(concat
(make-string 1 (random 256))
(make-string 1 (random 256))
@@ -159,8 +197,8 @@ by PASSWORD-HASHES. PASSWORD-HASHES should be a return value of
(make-string 1 (random 256))
(make-string 1 (random 256))
(make-string 1 (random 256)))))
- (setq sessionHash (secure-hash 'md5
- (concat challengeData randomString)
+ (setq sessionHash (ntlm-secure-hash
+ 'md5 (concat challengeData randomString)
nil nil t))
(setq sessionHash (substring sessionHash 0 8))
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 6 ++++++
lisp/ntlm.el | 46 ++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 48 insertions(+), 4 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project