Fix truncated comparison

Problem: The comparison was happening on the last 32 bytes instead of
the first 32.

Solution: Change the offset from 32 to 0, and set the end at 32 bytes.
This commit is contained in:
Christian Bundy 2020-09-04 08:34:16 -07:00 committed by Christophe Diederichs
parent 6c688b77c1
commit 083e83161c

View File

@ -57,7 +57,7 @@ function crypto_auth_hmacsha512256 (out, input, k) {
function crypto_auth_hmacsha512256_verify (h, input, k) {
const correct = Sha512.HMAC(k).update(input).digest()
return crypto_verify_32(h, 0, correct, 0) | sodium_memcmp(correct.subarray(32), h, 32)
return crypto_verify_32(h, 0, correct, 0) | sodium_memcmp(correct.subarray(0, 32), h, 32)
}
function crypto_auth (out, input, k) {