summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stdlib/hmac.tl20
1 files changed, 9 insertions, 11 deletions
diff --git a/stdlib/hmac.tl b/stdlib/hmac.tl
index fc487cbe..5b4aeb7f 100644
--- a/stdlib/hmac.tl
+++ b/stdlib/hmac.tl
@@ -39,17 +39,15 @@
(buf-set-length key block-size)
- (for ((i 0) (okey (copy-buf key)) (ikey (copy-buf key))
- (ctx0 [begin-fn]) (ctx1 [begin-fn]))
- ((< i block-size)
- [update-fn ctx0 ikey]
- [update-fn ctx0 message]
- [update-fn ctx1 okey]
- [update-fn ctx1 [end-fn ctx0]]
- [end-fn ctx1])
- ((inc i))
- (upd [okey i] (logxor #x5c))
- (upd [ikey i] (logxor #x36))))
+ (let ((okey (buf-xor-pattern key #x5c))
+ (ikey (buf-xor-pattern key #x36))
+ (ctx0 [begin-fn])
+ (ctx1 [begin-fn]))
+ [update-fn ctx0 ikey]
+ [update-fn ctx0 message]
+ [update-fn ctx1 okey]
+ [update-fn ctx1 [end-fn ctx0]]
+ [end-fn ctx1]))
(defun hmac-sha1 (key message)
[hmac-impl key message sha1 sha1-begin sha1-hash sha1-end 64])