diff options
| author | Vibhav Pant | 2020-08-21 14:04:35 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2020-08-21 14:04:35 +0530 |
| commit | f0f8d7b82492e741950c363a03b886965c91b1b0 (patch) | |
| tree | 19b716830b1ebabc0d7d75949c4e6800c0f104ad /lisp/net/ntlm.el | |
| parent | 9e64a087c4d167e7ec1c4e22bea3e6af53b563de (diff) | |
| parent | c818c29771d3cb51875643b2f6c894073e429dd2 (diff) | |
| download | emacs-feature/native-comp-macos-fixes.tar.gz emacs-feature/native-comp-macos-fixes.zip | |
Merge branch 'feature/native-comp' into feature/native-comp-macos-fixesfeature/native-comp-macos-fixes
Diffstat (limited to 'lisp/net/ntlm.el')
| -rw-r--r-- | lisp/net/ntlm.el | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/lisp/net/ntlm.el b/lisp/net/ntlm.el index ebcd21948bf..9401430799c 100644 --- a/lisp/net/ntlm.el +++ b/lisp/net/ntlm.el | |||
| @@ -69,7 +69,6 @@ | |||
| 69 | 69 | ||
| 70 | (require 'md4) | 70 | (require 'md4) |
| 71 | (require 'hmac-md5) | 71 | (require 'hmac-md5) |
| 72 | (require 'calc) | ||
| 73 | 72 | ||
| 74 | (defgroup ntlm nil | 73 | (defgroup ntlm nil |
| 75 | "NTLM (NT LanManager) authentication." | 74 | "NTLM (NT LanManager) authentication." |
| @@ -133,32 +132,27 @@ is not given." | |||
| 133 | domain ;buffer field | 132 | domain ;buffer field |
| 134 | )))) | 133 | )))) |
| 135 | 134 | ||
| 136 | (defun ntlm-compute-timestamp () | 135 | (defun ntlm--time-to-timestamp (time) |
| 137 | "Compute an NTLMv2 timestamp. | 136 | "Convert TIME to an NTLMv2 timestamp. |
| 138 | Return a unibyte string representing the number of tenths of a | 137 | Return a unibyte string representing the number of tenths of a |
| 139 | microsecond since January 1, 1601 as a 64-bit little-endian | 138 | microsecond since January 1, 1601 as a 64-bit little-endian |
| 140 | signed integer." | 139 | signed integer. TIME must be on the form (HIGH LOW USEC PSEC)." |
| 141 | ;; FIXME: This can likely be significantly simplified using the new | 140 | (let* ((s (+ (ash (nth 0 time) 16) (nth 1 time))) |
| 142 | ;; bignums support! | 141 | (us (nth 2 time)) |
| 143 | (let* ((s-to-tenths-of-us "mul(add(lsh($1,16),$2),10000000)") | 142 | (ps (nth 3 time)) |
| 144 | (us-to-tenths-of-us "mul($3,10)") | 143 | (tenths-of-us-since-jan-1-1601 |
| 145 | (ps-to-tenths-of-us "idiv($4,100000)") | 144 | (+ (* s 10000000) (* us 10) (/ ps 100000) |
| 146 | (tenths-of-us-since-jan-1-1601 | 145 | ;; tenths of microseconds between 1601-01-01 and 1970-01-01 |
| 147 | (apply #'calc-eval (concat "add(add(add(" | 146 | 116444736000000000))) |
| 148 | s-to-tenths-of-us "," | 147 | (apply #'unibyte-string |
| 149 | us-to-tenths-of-us ")," | 148 | (mapcar (lambda (i) |
| 150 | ps-to-tenths-of-us ")," | 149 | (logand (ash tenths-of-us-since-jan-1-1601 (* i -8)) |
| 151 | ;; tenths of microseconds between | 150 | #xff)) |
| 152 | ;; 1601-01-01 and 1970-01-01 | 151 | (number-sequence 0 7))))) |
| 153 | "116444736000000000)") | 152 | |
| 154 | 'rawnum (time-convert nil 'list))) | 153 | (defun ntlm-compute-timestamp () |
| 155 | result-bytes) | 154 | "Current time as an NTLMv2 timestamp, as a unibyte string." |
| 156 | (dotimes (_byte 8) | 155 | (ntlm--time-to-timestamp (time-convert nil 'list))) |
| 157 | (push (calc-eval "and($1,16#FF)" 'rawnum tenths-of-us-since-jan-1-1601) | ||
| 158 | result-bytes) | ||
| 159 | (setq tenths-of-us-since-jan-1-1601 | ||
| 160 | (calc-eval "rsh($1,8,64)" 'rawnum tenths-of-us-since-jan-1-1601))) | ||
| 161 | (apply #'unibyte-string (nreverse result-bytes)))) | ||
| 162 | 156 | ||
| 163 | (defun ntlm-generate-nonce () | 157 | (defun ntlm-generate-nonce () |
| 164 | "Generate a random nonce, not to be used more than once. | 158 | "Generate a random nonce, not to be used more than once. |