[gnus git] branch master updated: m0-11-49-g12c7c45 =1= ntlm.el (ntlm-build-auth-request): Add NTLM2 Session support (Bug#15603)

Katsumi <[email protected]> Sun, 05 Oct 2014 01:43:45 +0200
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  12c7c4532331a9512bff680e4f1beda5afa22255 (commit)
      from  f774a59c97bf97bff1043b7e271ef51382f72d25 (commit)


- Log -----------------------------------------------------------------
commit 12c7c4532331a9512bff680e4f1beda5afa22255
Author: Thomas Fitzsimmons <[email protected]>
Date:   Sat Oct 4 23:43:31 2014 +0000

    ntlm.el (ntlm-build-auth-request): Add NTLM2 Session support (Bug#15603)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 25f43ba..d4fc3c6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-04  Thomas Fitzsimmons  <[email protected]>
+
+	* ntlm.el (ntlm-build-auth-request):
+	Add NTLM2 Session support.  (Bug#15603)
+
 2014-10-04  Alan Schmitt  <[email protected]>  (tiny change)
 
 	* lisp/nnimap.el (nnimap-process-expiry-targets): Reverse the list of
diff --git a/lisp/ntlm.el b/lisp/ntlm.el
index bff3bab..30958aa 100644
--- a/lisp/ntlm.el
+++ b/lisp/ntlm.el
@@ -80,8 +80,8 @@ is not given."
 	(request-msgType (concat (make-string 1 1) (make-string 3 0)))
 					;0x01 0x00 0x00 0x00
 	(request-flags (concat (make-string 1 7) (make-string 1 178)
-			       (make-string 2 0)))
-					;0x07 0xb2 0x00 0x00
+			       (make-string 1 8) (make-string 1 0)))
+					;0x07 0xb2 0x08 0x00
 	lu ld off-d off-u)
     (when (string-match "@" user)
       (unless domain
@@ -144,11 +144,35 @@ by PASSWORD-HASHES.  PASSWORD-HASHES should be a return value of
       (setq domain (substring user (1+ (match-beginning 0))))
       (setq user (substring user 0 (match-beginning 0))))
 
+    ;; check if "negotiate NTLM2 key" flag is set in type 2 message
+    (if (not (zerop (logand (aref flags 2) 8)))
+	(let (randomString
+	      sessionHash)
+	  ;; generate NTLM2 session response data
+	  (setq randomString (string-make-unibyte
+			      (concat
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256))
+			       (make-string 1 (random 256)))))
+	  (setq sessionHash (secure-hash 'md5
+					 (concat challengeData randomString)
+					 nil nil t))
+	  (setq sessionHash (substring sessionHash 0 8))
+
+	  (setq lmRespData (concat randomString (make-string 16 0)))
+	  (setq ntRespData (ntlm-smb-owf-encrypt
+			    (cadr password-hashes) sessionHash)))
+      (progn
 	;; generate response data
 	(setq lmRespData
 	      (ntlm-smb-owf-encrypt (car password-hashes) challengeData))
 	(setq ntRespData
-	  (ntlm-smb-owf-encrypt (cadr password-hashes) challengeData))
+	      (ntlm-smb-owf-encrypt (cadr password-hashes) challengeData))))
 
     ;; get offsets to fields to pack the response struct in a string
     (setq lu (length user))

-----------------------------------------------------------------------
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 |    9 +++++++--
 lisp/ntlm.el   |   38 +++++++++++++++++++++++++++++++-------
 2 files changed, 38 insertions(+), 9 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