added: sodium_memcmp

This commit is contained in:
Christophe Diederichs 2020-06-17 13:06:30 +02:00
parent 6a0e8e7236
commit 0b37ca03ec

View File

@ -1,3 +1,5 @@
const assert = require('nanoassert')
module.exports = { module.exports = {
crypto_verify_16, crypto_verify_16,
crypto_verify_32 crypto_verify_32
@ -16,3 +18,9 @@ function crypto_verify_16(x, xi, y, yi) {
function crypto_verify_32(x, xi, y, yi) { function crypto_verify_32(x, xi, y, yi) {
return vn(x, xi, y, yi, 32) return vn(x, xi, y, yi, 32)
} }
function sodium_memcmp (a, b) {
assert(a.byteLength = b.byteLength, 'buffers must be the same size')
return vn(a, 0, b, 0, a.byteLength)
}