module: crypto_onetimeauth

This commit is contained in:
Christophe Diederichs 2020-05-04 21:11:30 +02:00
parent a4cab9dfd4
commit 5dd22a0957
2 changed files with 20 additions and 14 deletions

20
crypto_onetimeauth.js Normal file
View File

@ -0,0 +1,20 @@
const poly1305 = require('./poly1305')
const { crypto_verify_16 } = require('./crypto_verify')
module.exports = {
crypto_onetimeauth,
crypto_onetimeauth_verify
}
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
var s = new poly1305(k);
s.update(m, mpos, n);
s.finish(out, outpos);
return 0;
}
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
var x = new Uint8Array(16);
crypto_onetimeauth(x,0,m,mpos,n,k);
return crypto_verify_16(h,hpos,x,0);
}

View File

@ -14,20 +14,6 @@ var sodium = module.exports
var randombytes = require('./randombytes').randombytes
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
var s = new poly1305(k);
s.update(m, mpos, n);
s.finish(out, outpos);
return 0;
}
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
var x = new Uint8Array(16);
crypto_onetimeauth(x,0,m,mpos,n,k);
return crypto_verify_16(h,hpos,x,0);
}
function crypto_box_keypair(pk, sk) {