diff --git a/crypto_onetimeauth.js b/crypto_onetimeauth.js new file mode 100644 index 0000000..a7b4d60 --- /dev/null +++ b/crypto_onetimeauth.js @@ -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); +} diff --git a/index.js b/index.js index d6157fd..a0e7524 100644 --- a/index.js +++ b/index.js @@ -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) {