From 85bba731c01f0cd01deb7e31a9b77f5f54008678 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Wed, 5 Jan 2022 16:59:40 +0000 Subject: [PATCH] do not export STORE64_LE --- crypto_kdf.js | 1 - crypto_secretstream.js | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crypto_kdf.js b/crypto_kdf.js index 0e658da..d94d312 100644 --- a/crypto_kdf.js +++ b/crypto_kdf.js @@ -8,7 +8,6 @@ module.exports.crypto_kdf_BYTES_MIN = 16 module.exports.crypto_kdf_BYTES_MAX = 64 module.exports.crypto_kdf_CONTEXTBYTES = 8 module.exports.crypto_kdf_KEYBYTES = 32 -module.exports.STORE64_LE = STORE64_LE function STORE64_LE (dest, int) { var mul = 1 diff --git a/crypto_secretstream.js b/crypto_secretstream.js index ad16ad1..2fb7aa9 100644 --- a/crypto_secretstream.js +++ b/crypto_secretstream.js @@ -10,7 +10,6 @@ const { } = require('./crypto_stream_chacha20') const { crypto_core_hchacha20, crypto_core_hchacha20_INPUTBYTES } = require('./internal/hchacha20') const Poly1305 = require('./internal/poly1305') -const { STORE64_LE } = require('./crypto_kdf') const { sodium_increment, sodium_is_zero, sodium_memcmp } = require('./helpers') const crypto_onetimeauth_poly1305_BYTES = 16 @@ -35,11 +34,12 @@ const crypto_secretstream_xchacha20poly1305_TAG_FINAL = crypto_secretstream_xcha const _pad0 = new Uint8Array(16) -class Crypto_secretstream_xchacha20poly1305_state { - constructor () { - this.k = new Uint8Array(crypto_stream_chacha20_ietf_KEYBYTES) - this.nonce = new Uint8Array(crypto_stream_chacha20_ietf_NONCEBYTES) - this.pad = new Uint8Array(8) +function STORE64_LE (dest, int) { + let mul = 1 + let i = 0 + dest[0] = int & 0xFF + while (++i < 8 && (mul *= 0x100)) { + dest[i] = (int / mul) & 0xFF } }