crypto_verify return booleans

This commit is contained in:
Christophe Diederichs 2020-09-04 15:53:02 +02:00
parent a546f3e51d
commit 13fcad4d8e
2 changed files with 9 additions and 4 deletions

View File

@ -131,7 +131,7 @@ function crypto_aead_chacha20poly1305_ietf_decrypt_detached (m, nsec, c, mac, ad
computed_mac.fill(0)
slen.fill(0)
if (ret !== 0) {
if (!ret) {
m.fill(0)
throw new Error('could not verify data')
}

View File

@ -1,7 +1,8 @@
/* eslint-disable camelcase */
module.exports = {
crypto_verify_16,
crypto_verify_32
crypto_verify_32,
crypto_verify_64
}
function vn (x, xi, y, yi, n) {
@ -16,9 +17,13 @@ Object.defineProperty(module.exports, 'vn', {
})
function crypto_verify_16 (x, xi, y, yi) {
return vn(x, xi, y, yi, 16)
return vn(x, xi, y, yi, 16) === 0
}
function crypto_verify_32 (x, xi, y, yi) {
return vn(x, xi, y, yi, 32)
return vn(x, xi, y, yi, 32) === 0
}
function crypto_verify_64 (x, xi, y, yi) {
return vn(x, xi, y, yi, 64) === 0
}