commit 0b23f0f052b777590f5bf989f1e48078768551ca parent e202b0a3b4af16553cf6bfbc0c810589d8260161 Author: Jared Tobin <jared@jtobin.io> Date: Tue, 10 Sep 2024 11:09:13 +0400 lib: use fewer lazy bytestring ops in hmac_lazy Diffstat:
M | lib/Crypto/Hash/SHA256.hs | | | 12 | ++++++------ |
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/Crypto/Hash/SHA256.hs b/lib/Crypto/Hash/SHA256.hs @@ -367,13 +367,13 @@ hmac_lazy :: BS.ByteString -> BL.ByteString -> BS.ByteString hmac_lazy k text | lk > 64 = error "ppad-sha256: hmac key exceeds 64 bytes" | otherwise = - let step1 = BL.fromStrict k <> BL.replicate (64 - lk) 0x00 - step2 = BL.map (B.xor 0x36) step1 - step3 = step2 <> text + let step1 = k <> BS.replicate (64 - lk) 0x00 + step2 = BS.map (B.xor 0x36) step1 + step3 = BL.fromStrict step2 <> text step4 = hash_lazy step3 - step5 = BL.map (B.xor 0x5C) step1 - step6 = step5 <> BL.fromStrict step4 - in hash_lazy step6 + step5 = BS.map (B.xor 0x5C) step1 + step6 = step5 <> step4 + in hash step6 where lk = fi (BS.length k)