]> zoso.dev Git - libnemo.git/commitdiff
Delete previously exported secretbox function and related deprecated functions.
authorChris Duncan <chris@zoso.dev>
Mon, 25 Nov 2024 05:37:40 +0000 (21:37 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 25 Nov 2024 05:37:40 +0000 (21:37 -0800)
src/lib/workers/nano25519.ts

index 6ebc3707c484b8f319c234c741124a65c6777ae3..7d14c2244ba4edb5d8ee20b14342fb20906b170c 100644 (file)
@@ -2171,11 +2171,6 @@ import blake2b from 'blake2b'
 \r
        /* High-level API */\r
 \r
-       function checkLengths(k, n) {\r
-               if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\r
-               if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\r
-       }\r
-\r
        function checkArrayTypes() {\r
                for (var i = 0; i < arguments.length; i++) {\r
                        if (!(arguments[i] instanceof Uint8Array))\r
@@ -2187,31 +2182,6 @@ import blake2b from 'blake2b'
                for (var i = 0; i < arr.length; i++) arr[i] = 0;\r
        }\r
 \r
-       secretbox = function(msg, nonce, key) {\r
-               checkArrayTypes(msg, nonce, key);\r
-               checkLengths(key, nonce);\r
-               var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\r
-               var c = new Uint8Array(m.length);\r
-               for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\r
-               crypto_secretbox(c, m, m.length, nonce, key);\r
-               return c.subarray(crypto_secretbox_BOXZEROBYTES);\r
-       };\r
-\r
-       secretbox.open = function(box, nonce, key) {\r
-               checkArrayTypes(box, nonce, key);\r
-               checkLengths(key, nonce);\r
-               var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\r
-               var m = new Uint8Array(c.length);\r
-               for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\r
-               if (c.length < 32) return null;\r
-               if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\r
-               return m.subarray(crypto_secretbox_ZEROBYTES);\r
-       };\r
-\r
-       secretbox.keyLength = crypto_secretbox_KEYBYTES;\r
-       secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\r
-       secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\r
-\r
        const sign = function(msg, secretKey) {\r
                        checkArrayTypes(msg, secretKey);\r
                        if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\r