From b0fcb363e8ed41be7a9ed2eb58fa5040425558cd Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Fri, 8 May 2020 22:34:41 +0200 Subject: [PATCH] fix: bug with counter >> 32 --- crypto_stream_chacha20.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_stream_chacha20.js b/crypto_stream_chacha20.js index 2bebf91..838c6d2 100644 --- a/crypto_stream_chacha20.js +++ b/crypto_stream_chacha20.js @@ -112,7 +112,7 @@ function Chacha20 (n, k, counter) { this.state[12] = counter & 0xffffffff if (n.byteLength === 8) { - this.state[13] = counter >> 32 + this.state[13] = (counter && 0xffffffff00000000) >> 32 this.state[14] = n.readUInt32LE(0) this.state[15] = n.readUInt32LE(4) } else {