Function: ntlm-smb-dohash
ntlm-smb-dohash is a byte-compiled function defined in ntlm.el.gz.
Signature
(ntlm-smb-dohash IN KEY FORW)
Documentation
Return the hash value for a string IN and a string KEY.
Length of IN and KEY are 64. FORW non-nil means forward, nil means backward.
Source Code
;; Defined in /usr/src/emacs/lisp/net/ntlm.el.gz
(defun ntlm-smb-dohash (in key forw)
"Return the hash value for a string IN and a string KEY.
Length of IN and KEY are 64. FORW non-nil means forward, nil means
backward."
(let* ((pk1 (ntlm-string-permute key ntlm-smb-perm1 56)) ;string of length 56
(c (substring pk1 0 28)) ;string of length 28
(d (substring pk1 28 56)) ;string of length 28
cd ;string of length 56
(ki (make-vector 16 0)) ;vector of string of length 48
pd1 ;string of length 64
l ;string of length 32
r ;string of length 32
rl ;string of length 64
(i 0) (j 0) (k 0))
(dotimes (i 16)
(setq c (ntlm-string-lshift c (aref ntlm-smb-sc i) 28))
(setq d (ntlm-string-lshift d (aref ntlm-smb-sc i) 28))
(setq cd (concat (substring c 0 28) (substring d 0 28)))
(aset ki i (ntlm-string-permute cd ntlm-smb-perm2 48)))
(setq pd1 (ntlm-string-permute in ntlm-smb-perm3 64))
(setq l (substring pd1 0 32))
(setq r (substring pd1 32 64))
(setq i 0)
(let (er ;string of length 48
erk ;string of length 48
(b (make-vector 8 0)) ;vector of strings of length 6
cb ;string of length 32
pcb ;string of length 32
r2 ;string of length 32
jj m n bj sbox-jmn)
(while (< i 16)
(setq er (ntlm-string-permute r ntlm-smb-perm4 48))
(setq erk (ntlm-string-xor er
(aref ki (if forw i (- 15 i)))
48))
(setq j 0)
(while (< j 8)
(setq jj (* 6 j))
(aset b j (substring erk jj (+ jj 6)))
(setq j (1+ j)))
(setq j 0)
(while (< j 8)
(setq bj (aref b j))
(setq m (logior (ash (aref bj 0) 1) (aref bj 5)))
(setq n (logior (ash (aref bj 1) 3)
(ash (aref bj 2) 2)
(ash (aref bj 3) 1)
(aref bj 4)))
(setq k 0)
(setq sbox-jmn (aref (aref (aref ntlm-smb-sbox j) m) n))
(while (< k 4)
(aset bj k
(if (zerop (logand sbox-jmn (ash 1 (- 3 k))))
0 1))
(setq k (1+ k)))
(setq j (1+ j)))
(setq j 0)
(setq cb nil)
(while (< j 8)
(setq cb (concat cb (substring (aref b j) 0 4)))
(setq j (1+ j)))
(setq pcb (ntlm-string-permute cb ntlm-smb-perm5 32))
(setq r2 (ntlm-string-xor l pcb 32))
(setq l r)
(setq r r2)
(setq i (1+ i))))
(setq rl (concat r l))
(ntlm-string-permute rl ntlm-smb-perm6 64)))