diff --git a/package.json b/package.json index 9dbb6ff..c3b169b 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,14 @@ "import": "./esm/_polyval.js", "require": "./_polyval.js" }, + "./aes": { + "import": "./esm/aes.js", + "require": "./aes.js" + }, + "./chacha": { + "import": "./esm/chacha.js", + "require": "./chacha.js" + }, "./crypto": { "types": "./crypto.d.ts", "node": { @@ -64,30 +72,22 @@ "import": "./esm/crypto.js", "default": "./crypto.js" }, - "./aes": { - "import": "./esm/aes.js", - "require": "./aes.js" + "./ff1": { + "import": "./esm/ff1.js", + "require": "./ff1.js" }, - "./chacha": { - "import": "./esm/chacha.js", - "require": "./chacha.js" + "./index": { + "import": "./esm/index.js", + "require": "./index.js" }, "./salsa": { "import": "./esm/salsa.js", "require": "./salsa.js" }, - "./ff1": { - "import": "./esm/ff1.js", - "require": "./ff1.js" - }, "./utils": { "import": "./esm/utils.js", "require": "./utils.js" }, - "./index": { - "import": "./esm/index.js", - "require": "./index.js" - }, "./webcrypto": { "import": "./esm/webcrypto.js", "require": "./webcrypto.js" diff --git a/src/_micro.ts b/src/_micro.ts index 2eda571..986265a 100644 --- a/src/_micro.ts +++ b/src/_micro.ts @@ -81,7 +81,7 @@ function salsaCore( const y = new Uint32Array([ s[0], k[0], k[1], k[2], // "expa" Key Key Key k[3], s[1], n[0], n[1], // Key "nd 3" Nonce Nonce - cnt, 0, s[2], k[4], // Pos. Pos. "2-by" Key + cnt, 0, s[2], k[4], // Pos. Pos. "2-by" Key k[5], k[6], k[7], s[3], // Key Key Key "te k" ]); const x = y.slice(); @@ -118,7 +118,7 @@ function chachaCore( s[0], s[1], s[2], s[3], // "expa" "nd 3" "2-by" "te k" k[0], k[1], k[2], k[3], // Key Key Key Key k[4], k[5], k[6], k[7], // Key Key Key Key - cnt, n[0], n[1], n[2], // Counter Counter Nonce Nonce + cnt, n[0], n[1], n[2], // Counter Counter Nonce Nonce ]); const x = y.slice(); chachaRound(x, rounds); diff --git a/src/chacha.ts b/src/chacha.ts index ce7e10d..47a131b 100644 --- a/src/chacha.ts +++ b/src/chacha.ts @@ -24,9 +24,9 @@ function chachaCore( s: Uint32Array, k: Uint32Array, n: Uint32Array, out: Uint32Array, cnt: number, rounds = 20 ): void { let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], // "expa" "nd 3" "2-by" "te k" - y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], // Key Key Key Key - y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], // Key Key Key Key - y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter Nonce Nonce + y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], // Key Key Key Key + y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], // Key Key Key Key + y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2]; // Counter Counter Nonce Nonce // Save state to temporary variables let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, diff --git a/src/salsa.ts b/src/salsa.ts index a9d5d63..4478732 100644 --- a/src/salsa.ts +++ b/src/salsa.ts @@ -17,9 +17,9 @@ function salsaCore( ): void { // Based on https://cr.yp.to/salsa20.html let y00 = s[0], y01 = k[0], y02 = k[1], y03 = k[2], // "expa" Key Key Key - y04 = k[3], y05 = s[1], y06 = n[0], y07 = n[1], // Key "nd 3" Nonce Nonce - y08 = cnt, y09 = 0, y10 = s[2], y11 = k[4], // Pos. Pos. "2-by" Key - y12 = k[5], y13 = k[6], y14 = k[7], y15 = s[3]; // Key Key Key "te k" + y04 = k[3], y05 = s[1], y06 = n[0], y07 = n[1], // Key "nd 3" Nonce Nonce + y08 = cnt, y09 = 0, y10 = s[2], y11 = k[4], // Pos. Pos. "2-by" Key + y12 = k[5], y13 = k[6], y14 = k[7], y15 = s[3]; // Key Key Key "te k" // Save state to temporary variables let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07,