aegis-aead 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +25 -20
  2. package/dist/aegis128l.d.ts +33 -33
  3. package/dist/aegis128l.js +225 -235
  4. package/dist/aegis128x.d.ts +35 -35
  5. package/dist/aegis128x.js +348 -282
  6. package/dist/aegis256.d.ts +34 -51
  7. package/dist/aegis256.js +215 -206
  8. package/dist/aegis256x.d.ts +32 -33
  9. package/dist/aegis256x.js +333 -265
  10. package/dist/aes-bs.d.ts +42 -35
  11. package/dist/aes-bs.js +2269 -401
  12. package/dist/index.d.ts +4 -7
  13. package/dist/index.js +4 -7
  14. package/dist/random.d.ts +0 -1
  15. package/dist/random.js +0 -1
  16. package/dist/utils.d.ts +14 -0
  17. package/dist/utils.js +31 -0
  18. package/package.json +5 -6
  19. package/dist/aegis128l-bs.d.ts +0 -137
  20. package/dist/aegis128l-bs.d.ts.map +0 -1
  21. package/dist/aegis128l-bs.js +0 -442
  22. package/dist/aegis128l-bs.js.map +0 -1
  23. package/dist/aegis128l.d.ts.map +0 -1
  24. package/dist/aegis128l.js.map +0 -1
  25. package/dist/aegis128x.d.ts.map +0 -1
  26. package/dist/aegis128x.js.map +0 -1
  27. package/dist/aegis256-bs.d.ts +0 -79
  28. package/dist/aegis256-bs.d.ts.map +0 -1
  29. package/dist/aegis256-bs.js +0 -366
  30. package/dist/aegis256-bs.js.map +0 -1
  31. package/dist/aegis256.d.ts.map +0 -1
  32. package/dist/aegis256.js.map +0 -1
  33. package/dist/aegis256x.d.ts.map +0 -1
  34. package/dist/aegis256x.js.map +0 -1
  35. package/dist/aes-bs.d.ts.map +0 -1
  36. package/dist/aes-bs.js.map +0 -1
  37. package/dist/aes.d.ts +0 -81
  38. package/dist/aes.d.ts.map +0 -1
  39. package/dist/aes.js +0 -232
  40. package/dist/aes.js.map +0 -1
  41. package/dist/index.d.ts.map +0 -1
  42. package/dist/index.js.map +0 -1
  43. package/dist/random.d.ts.map +0 -1
  44. package/dist/random.js.map +0 -1
  45. package/src/aegis128l-bs.ts +0 -600
  46. package/src/aegis128l.ts +0 -653
  47. package/src/aegis128x.ts +0 -932
  48. package/src/aegis256-bs.ts +0 -519
  49. package/src/aegis256.ts +0 -597
  50. package/src/aegis256x.ts +0 -893
  51. package/src/aes-bs.ts +0 -540
  52. package/src/aes.ts +0 -271
  53. package/src/index.ts +0 -126
  54. package/src/random.ts +0 -41
  55. package/src/typed-array.d.ts +0 -18
package/dist/aes-bs.d.ts CHANGED
@@ -2,6 +2,16 @@
2
2
  * Bitsliced AES implementation using 32-bit integers.
3
3
  * Processes 8 AES blocks simultaneously for constant-time operation.
4
4
  * Based on the barrel-shiftrows representation by Adomnicai and Peyrin.
5
+ *
6
+ * The packed layout matches the reference C implementation: the state words
7
+ * are permuted so that bit-plane k of byte group g lives in word 4k + g.
8
+ * The four group lanes of each bit-plane are therefore adjacent, ShiftRows
9
+ * and MixColumns work on isomorphic quads, and an AES round needs no
10
+ * per-round transposes.
11
+ *
12
+ * The hot-path functions (AEGIS rounds, constant-input packing, keystream
13
+ * extraction) are fully unrolled over local variables and generated by
14
+ * scripts/gen-aes-bs.ts.
5
15
  */
6
16
  /**
7
17
  * Bitsliced representation of 8 AES blocks.
@@ -21,10 +31,11 @@ export declare function createAesBlocks(): AesBlocks;
21
31
  */
22
32
  export declare function createAesBlock(): AesBlock;
23
33
  /**
24
- * Complete AES round (SubBytes + ShiftRows + MixColumns).
25
- * Note: AddRoundKey is handled separately in AEGIS.
34
+ * Computes the index of a block word in the unpacked state array.
35
+ * @param block - Block index (0-7)
36
+ * @param word - Word index (0-3)
26
37
  */
27
- export declare function aesRound(st: AesBlocks): void;
38
+ export declare function wordIdx(block: number, word: number): number;
28
39
  /**
29
40
  * Pack 8 AES blocks into bitsliced representation.
30
41
  */
@@ -34,54 +45,50 @@ export declare function pack(st: AesBlocks): void;
34
45
  */
35
46
  export declare function unpack(st: AesBlocks): void;
36
47
  /**
37
- * Pack only blocks 0 and 4 (used for constant inputs in AEGIS-128L).
38
- */
39
- export declare function pack04(st: AesBlocks): void;
40
- /**
41
- * Inverse of pack04: unpack only blocks 0 and 4.
42
- */
43
- export declare function unpack04(st: AesBlocks): void;
44
- /**
45
- * Pack only block 0 (used for constant inputs in AEGIS-256).
48
+ * Put a single AES block into the unpacked state at the given block position.
46
49
  */
47
- export declare function pack04_6(st: AesBlocks): void;
50
+ export declare function blocksPut(st: AesBlocks, s: AesBlock, block: number): void;
48
51
  /**
49
- * Inverse of pack04_6: unpack only block 0.
52
+ * Load 16 bytes at the given offset into an AES block (little-endian).
50
53
  */
51
- export declare function unpack04_6(st: AesBlocks): void;
54
+ export declare function blockFromBytes(out: AesBlock, src: Uint8Array, off?: number): void;
52
55
  /**
53
- * Computes the index into the bitsliced state array.
54
- * @param block - Block index (0-7)
55
- * @param word - Word index (0-3)
56
+ * Store an AES block as 16 bytes at the given offset (little-endian).
56
57
  */
57
- export declare function wordIdx(block: number, word: number): number;
58
+ export declare function blockToBytes(out: Uint8Array, src: AesBlock, off?: number): void;
58
59
  /**
59
- * Rotate all blocks right by 1 position (for AEGIS state rotation).
60
- * Performs (st[i] & 0xfefefefe) >> 1 | (st[i] & 0x01010101) << 7
60
+ * XOR two AES blocks: out = a ^ b
61
61
  */
62
- export declare function blocksRotr(st: AesBlocks): void;
62
+ export declare function blockXor(out: AesBlock, a: AesBlock, b: AesBlock): void;
63
63
  /**
64
- * Rotate within the bottom 6 lanes (for AEGIS-256, 6 blocks).
64
+ * Fused AEGIS-128L update round on the packed state:
65
+ * st = st ^ rotr8(AESRound(st)) ^ ci, where rotr8 rotates the 8 block lanes.
65
66
  */
66
- export declare function blocksRotr6(st: AesBlocks): void;
67
+ export declare function aegisRound128(st: AesBlocks, ci: AesBlocks): void;
67
68
  /**
68
- * Put a single AES block into the bitsliced state at the given block position.
69
+ * Fused AEGIS-256 update round on the packed state:
70
+ * st = st ^ rotr6(AESRound(st)) ^ ci, where rotr6 rotates the 6 block lanes.
69
71
  */
70
- export declare function blocksPut(st: AesBlocks, s: AesBlock, block: number): void;
72
+ export declare function aegisRound256(st: AesBlocks, ci: AesBlocks): void;
71
73
  /**
72
- * Load a 16-byte buffer into an AES block (4 uint32 little-endian).
74
+ * Pack two message blocks (at positions 0 and 4) into a constant-input state
75
+ * for the AEGIS-128L round. Specialized pack04 exploiting the sparse input.
73
76
  */
74
- export declare function blockFromBytes(out: AesBlock, src: Uint8Array): void;
77
+ export declare function packConstantInput128(out: AesBlocks, m0: AesBlock, m1: AesBlock): void;
75
78
  /**
76
- * Store an AES block to a 16-byte buffer (little-endian).
79
+ * Pack one message block (at position 0) into a constant-input state for the
80
+ * AEGIS-256 round. Specialized pack04_6 exploiting the sparse input.
77
81
  */
78
- export declare function blockToBytes(out: Uint8Array, src: AesBlock): void;
82
+ export declare function packConstantInput256(out: AesBlocks, m: AesBlock): void;
79
83
  /**
80
- * XOR two AES blocks: out = a ^ b
84
+ * AEGIS-128L keystream extraction from the packed state:
85
+ * z0 = S6 ^ S1 ^ (S2 & S3), z1 = S2 ^ S5 ^ (S6 & S7), computed lane-wise,
86
+ * then unpacked (unpack04 restricted to the words feeding blocks 0 and 4).
81
87
  */
82
- export declare function blockXor(out: AesBlock, a: AesBlock, b: AesBlock): void;
88
+ export declare function keystream128(st: AesBlocks, z0: AesBlock, z1: AesBlock): void;
83
89
  /**
84
- * XOR two bitsliced states: a ^= b
90
+ * AEGIS-256 keystream extraction from the packed state:
91
+ * z = S1 ^ S4 ^ S5 ^ (S2 & S3), computed lane-wise, then unpacked
92
+ * (unpack04_6 restricted to the words feeding block 0).
85
93
  */
86
- export declare function blocksXor(a: AesBlocks, b: AesBlocks): void;
87
- //# sourceMappingURL=aes-bs.d.ts.map
94
+ export declare function keystream256(st: AesBlocks, z: AesBlock): void;