diff options
| author | Thomas Fitzsimmons | 2016-10-01 23:57:20 -0400 |
|---|---|---|
| committer | Thomas Fitzsimmons | 2016-10-05 20:18:18 -0400 |
| commit | 33c607aab51636a19dcd67abb9bee0c0be077b46 (patch) | |
| tree | a78f6176569ac34a6797fc553e64c221d0de3d67 | |
| parent | 680e3986adaf1742a6a69ef2eb43a874ca6d5984 (diff) | |
| download | emacs-33c607aab51636a19dcd67abb9bee0c0be077b46.tar.gz emacs-33c607aab51636a19dcd67abb9bee0c0be077b46.zip | |
lisp/net/ntlm.el: Fix comment and docstring formatting
| -rw-r--r-- | lisp/net/ntlm.el | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/lisp/net/ntlm.el b/lisp/net/ntlm.el index 89f09b07448..7d285c5644b 100644 --- a/lisp/net/ntlm.el +++ b/lisp/net/ntlm.el | |||
| @@ -49,10 +49,12 @@ | |||
| 49 | ;; | 49 | ;; |
| 50 | ;; 1. Open a network connection to the Exchange server at the IMAP port (143) | 50 | ;; 1. Open a network connection to the Exchange server at the IMAP port (143) |
| 51 | ;; 2. Receive an opening message such as: | 51 | ;; 2. Receive an opening message such as: |
| 52 | ;; "* OK Microsoft Exchange IMAP4rev1 server version 5.5.2653.7 (XXXX) ready" | 52 | ;; "* OK Microsoft Exchange IMAP4rev1 server |
| 53 | ;; version 5.5.2653.7 (XXXX) ready" | ||
| 53 | ;; 3. Ask for IMAP server capability by sending "NNN capability" | 54 | ;; 3. Ask for IMAP server capability by sending "NNN capability" |
| 54 | ;; 4. Receive a capability message such as: | 55 | ;; 4. Receive a capability message such as: |
| 55 | ;; "* CAPABILITY IMAP4 IMAP4rev1 IDLE LITERAL+ LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE AUTH=NTLM" | 56 | ;; "* CAPABILITY IMAP4 IMAP4rev1 IDLE LITERAL+ |
| 57 | ;; LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE AUTH=NTLM" | ||
| 56 | ;; 5. Ask for NTLM authentication by sending a string | 58 | ;; 5. Ask for NTLM authentication by sending a string |
| 57 | ;; "NNN authenticate ntlm" | 59 | ;; "NNN authenticate ntlm" |
| 58 | ;; 6. Receive continuation acknowledgment "+" | 60 | ;; 6. Receive continuation acknowledgment "+" |
| @@ -118,17 +120,17 @@ is not given." | |||
| 118 | (setq off-u 32) ;offset to the string 'user | 120 | (setq off-u 32) ;offset to the string 'user |
| 119 | (setq off-d (+ 32 lu)) ;offset to the string 'domain | 121 | (setq off-d (+ 32 lu)) ;offset to the string 'domain |
| 120 | ;; pack the request struct in a string | 122 | ;; pack the request struct in a string |
| 121 | (concat request-ident ;8 bytes | 123 | (concat request-ident ;8 bytes |
| 122 | request-msgType ;4 bytes | 124 | request-msgType ;4 bytes |
| 123 | request-flags ;4 bytes | 125 | request-flags ;4 bytes |
| 124 | (md4-pack-int16 lu) ;user field, count field | 126 | (md4-pack-int16 lu) ;user field, count field |
| 125 | (md4-pack-int16 lu) ;user field, max count field | 127 | (md4-pack-int16 lu) ;user field, max count field |
| 126 | (md4-pack-int32 (cons 0 off-u)) ;user field, offset field | 128 | (md4-pack-int32 (cons 0 off-u)) ;user field, offset field |
| 127 | (md4-pack-int16 ld) ;domain field, count field | 129 | (md4-pack-int16 ld) ;domain field, count field |
| 128 | (md4-pack-int16 ld) ;domain field, max count field | 130 | (md4-pack-int16 ld) ;domain field, max count field |
| 129 | (md4-pack-int32 (cons 0 off-d)) ;domain field, offset field | 131 | (md4-pack-int32 (cons 0 off-d)) ;domain field, offset field |
| 130 | user ;buffer field | 132 | user ;buffer field |
| 131 | domain ;buffer field | 133 | domain ;buffer field |
| 132 | ))) | 134 | ))) |
| 133 | 135 | ||
| 134 | (eval-when-compile | 136 | (eval-when-compile |
| @@ -239,12 +241,12 @@ by PASSWORD-HASHES. PASSWORD-HASHES should be a return value of | |||
| 239 | (cadr password-hashes))) | 241 | (cadr password-hashes))) |
| 240 | (nonce (ntlm-generate-nonce)) | 242 | (nonce (ntlm-generate-nonce)) |
| 241 | (blob (concat (make-string 2 1) | 243 | (blob (concat (make-string 2 1) |
| 242 | (make-string 2 0) ; blob signature | 244 | (make-string 2 0) ;blob signature |
| 243 | (make-string 4 0) ; reserved value | 245 | (make-string 4 0) ;reserved value |
| 244 | (ntlm-compute-timestamp) ; timestamp | 246 | (ntlm-compute-timestamp) ;timestamp |
| 245 | nonce ; client nonce | 247 | nonce ;client nonce |
| 246 | (make-string 4 0) ; unknown | 248 | (make-string 4 0) ;unknown |
| 247 | targetInfo)) ; target info | 249 | targetInfo)) ;target info |
| 248 | ;; for reference: LMv2 interim calculation | 250 | ;; for reference: LMv2 interim calculation |
| 249 | (lm-interim (hmac-md5 (concat challengeData nonce) | 251 | (lm-interim (hmac-md5 (concat challengeData nonce) |
| 250 | ntlmv2-hash)) | 252 | ntlmv2-hash)) |
| @@ -288,58 +290,58 @@ by PASSWORD-HASHES. PASSWORD-HASHES should be a return value of | |||
| 288 | (setq off-lm (+ off-w (* 2 lw))) ;offset to string 'lmResponse | 290 | (setq off-lm (+ off-w (* 2 lw))) ;offset to string 'lmResponse |
| 289 | (setq off-nt (+ off-lm ll)) ;offset to string 'ntResponse | 291 | (setq off-nt (+ off-lm ll)) ;offset to string 'ntResponse |
| 290 | ;; pack the response struct in a string | 292 | ;; pack the response struct in a string |
| 291 | (concat "NTLMSSP\0" ;response ident field, 8 bytes | 293 | (concat "NTLMSSP\0" ;response ident field, 8 bytes |
| 292 | (md4-pack-int32 '(0 . 3)) ;response msgType field, 4 bytes | 294 | (md4-pack-int32 '(0 . 3)) ;response msgType field, 4 bytes |
| 293 | 295 | ||
| 294 | ;; lmResponse field, 8 bytes | 296 | ;; lmResponse field, 8 bytes |
| 295 | ;;AddBytes(response,lmResponse,lmRespData,24); | 297 | ;;AddBytes(response,lmResponse,lmRespData,24); |
| 296 | (md4-pack-int16 ll) ;len field | 298 | (md4-pack-int16 ll) ;len field |
| 297 | (md4-pack-int16 ll) ;maxlen field | 299 | (md4-pack-int16 ll) ;maxlen field |
| 298 | (md4-pack-int32 (cons 0 off-lm)) ;field offset | 300 | (md4-pack-int32 (cons 0 off-lm)) ;field offset |
| 299 | 301 | ||
| 300 | ;; ntResponse field, 8 bytes | 302 | ;; ntResponse field, 8 bytes |
| 301 | ;;AddBytes(response,ntResponse,ntRespData,ln); | 303 | ;;AddBytes(response,ntResponse,ntRespData,ln); |
| 302 | (md4-pack-int16 ln) ;len field | 304 | (md4-pack-int16 ln) ;len field |
| 303 | (md4-pack-int16 ln) ;maxlen field | 305 | (md4-pack-int16 ln) ;maxlen field |
| 304 | (md4-pack-int32 (cons 0 off-nt)) ;field offset | 306 | (md4-pack-int32 (cons 0 off-nt)) ;field offset |
| 305 | 307 | ||
| 306 | ;; uDomain field, 8 bytes | 308 | ;; uDomain field, 8 bytes |
| 307 | ;;AddUnicodeString(response,uDomain,domain); | 309 | ;;AddUnicodeString(response,uDomain,domain); |
| 308 | ;;AddBytes(response, uDomain, udomain, 2*ld); | 310 | ;;AddBytes(response, uDomain, udomain, 2*ld); |
| 309 | (md4-pack-int16 (* 2 ld)) ;len field | 311 | (md4-pack-int16 (* 2 ld)) ;len field |
| 310 | (md4-pack-int16 (* 2 ld)) ;maxlen field | 312 | (md4-pack-int16 (* 2 ld)) ;maxlen field |
| 311 | ;; match Mozilla behavior, which is to hard-code the | 313 | ;; match Mozilla behavior, which is to hard-code the |
| 312 | ;; domain offset to 64 | 314 | ;; domain offset to 64 |
| 313 | (md4-pack-int32 (cons 0 64)) ;field offset | 315 | (md4-pack-int32 (cons 0 64)) ;field offset |
| 314 | 316 | ||
| 315 | ;; uUser field, 8 bytes | 317 | ;; uUser field, 8 bytes |
| 316 | ;;AddUnicodeString(response,uUser,u); | 318 | ;;AddUnicodeString(response,uUser,u); |
| 317 | ;;AddBytes(response, uUser, uuser, 2*lu); | 319 | ;;AddBytes(response, uUser, uuser, 2*lu); |
| 318 | (md4-pack-int16 (* 2 lu)) ;len field | 320 | (md4-pack-int16 (* 2 lu)) ;len field |
| 319 | (md4-pack-int16 (* 2 lu)) ;maxlen field | 321 | (md4-pack-int16 (* 2 lu)) ;maxlen field |
| 320 | (md4-pack-int32 (cons 0 off-u)) ;field offset | 322 | (md4-pack-int32 (cons 0 off-u)) ;field offset |
| 321 | 323 | ||
| 322 | ;; uWks field, 8 bytes | 324 | ;; uWks field, 8 bytes |
| 323 | ;;AddUnicodeString(response,uWks,u); | 325 | ;;AddUnicodeString(response,uWks,u); |
| 324 | (md4-pack-int16 (* 2 lw)) ;len field | 326 | (md4-pack-int16 (* 2 lw)) ;len field |
| 325 | (md4-pack-int16 (* 2 lw)) ;maxlen field | 327 | (md4-pack-int16 (* 2 lw)) ;maxlen field |
| 326 | (md4-pack-int32 (cons 0 off-w)) ;field offset | 328 | (md4-pack-int32 (cons 0 off-w)) ;field offset |
| 327 | 329 | ||
| 328 | ;; sessionKey field, blank, 8 bytes | 330 | ;; sessionKey field, blank, 8 bytes |
| 329 | ;;AddString(response,sessionKey,NULL); | 331 | ;;AddString(response,sessionKey,NULL); |
| 330 | (md4-pack-int16 0) ;len field | 332 | (md4-pack-int16 0) ;len field |
| 331 | (md4-pack-int16 0) ;maxlen field | 333 | (md4-pack-int16 0) ;maxlen field |
| 332 | (md4-pack-int32 (cons 0 0)) ;field offset | 334 | (md4-pack-int32 (cons 0 0)) ;field offset |
| 333 | 335 | ||
| 334 | ;; flags field, 4 bytes | 336 | ;; flags field, 4 bytes |
| 335 | flags ; | 337 | flags |
| 336 | 338 | ||
| 337 | ;; buffer field | 339 | ;; buffer field |
| 338 | (ntlm-ascii2unicode user lu) ;Unicode user, 2*lu bytes | 340 | (ntlm-ascii2unicode user lu) ;Unicode user, 2*lu bytes |
| 339 | (ntlm-ascii2unicode domain ld) ;Unicode domain, 2*ld bytes | 341 | (ntlm-ascii2unicode domain ld) ;Unicode domain, 2*ld bytes |
| 340 | (ntlm-ascii2unicode workstation lw) ;Unicode workstation, 2*lw bytes | 342 | (ntlm-ascii2unicode workstation lw) ;Unicode workstation, 2*lw bytes |
| 341 | lmRespData ;lmResponse, 24 bytes | 343 | lmRespData ;lmResponse, 24 bytes |
| 342 | ntRespData ;ntResponse, ln bytes | 344 | ntRespData ;ntResponse, ln bytes |
| 343 | ))) | 345 | ))) |
| 344 | 346 | ||
| 345 | (defun ntlm-get-password-hashes (password) | 347 | (defun ntlm-get-password-hashes (password) |
| @@ -558,7 +560,7 @@ length of STR is LEN." | |||
| 558 | (concat (substring str c len) (substring str 0 c)))) | 560 | (concat (substring str c len) (substring str 0 c)))) |
| 559 | 561 | ||
| 560 | (defsubst ntlm-string-xor (in1 in2 n) | 562 | (defsubst ntlm-string-xor (in1 in2 n) |
| 561 | "Return exclusive-or of sequences in1 and in2" | 563 | "Return exclusive-or of sequences in1 and in2." |
| 562 | (let ((w (make-string n 0)) (i 0)) | 564 | (let ((w (make-string n 0)) (i 0)) |
| 563 | (while (< i n) | 565 | (while (< i n) |
| 564 | (aset w i (logxor (aref in1 i) (aref in2 i))) | 566 | (aset w i (logxor (aref in1 i) (aref in2 i))) |