From: Chris Duncan Date: Mon, 25 Nov 2024 05:37:40 +0000 (-0800) Subject: Delete previously exported secretbox function and related deprecated functions. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=0fa43a18b9c8429fbdcdd9ca07b2904708562c71;p=libnemo.git Delete previously exported secretbox function and related deprecated functions. --- diff --git a/src/lib/workers/nano25519.ts b/src/lib/workers/nano25519.ts index 6ebc370..7d14c22 100644 --- a/src/lib/workers/nano25519.ts +++ b/src/lib/workers/nano25519.ts @@ -2171,11 +2171,6 @@ import blake2b from 'blake2b' /* High-level API */ - function checkLengths(k, n) { - if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size'); - if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size'); - } - function checkArrayTypes() { for (var i = 0; i < arguments.length; i++) { if (!(arguments[i] instanceof Uint8Array)) @@ -2187,31 +2182,6 @@ import blake2b from 'blake2b' for (var i = 0; i < arr.length; i++) arr[i] = 0; } - secretbox = function(msg, nonce, key) { - checkArrayTypes(msg, nonce, key); - checkLengths(key, nonce); - var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length); - var c = new Uint8Array(m.length); - for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i]; - crypto_secretbox(c, m, m.length, nonce, key); - return c.subarray(crypto_secretbox_BOXZEROBYTES); - }; - - secretbox.open = function(box, nonce, key) { - checkArrayTypes(box, nonce, key); - checkLengths(key, nonce); - var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length); - var m = new Uint8Array(c.length); - for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i]; - if (c.length < 32) return null; - if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null; - return m.subarray(crypto_secretbox_ZEROBYTES); - }; - - secretbox.keyLength = crypto_secretbox_KEYBYTES; - secretbox.nonceLength = crypto_secretbox_NONCEBYTES; - secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES; - const sign = function(msg, secretKey) { checkArrayTypes(msg, secretKey); if (secretKey.length !== crypto_sign_SECRETKEYBYTES)