aegis-aead 0.2.1 → 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 +29 -22
  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 +46 -23
  11. package/dist/aes-bs.js +2273 -331
  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 +6 -6
  19. package/dist/aegis128l-bs.d.ts +0 -194
  20. package/dist/aegis128l-bs.d.ts.map +0 -1
  21. package/dist/aegis128l-bs.js +0 -549
  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 -183
  28. package/dist/aegis256-bs.d.ts.map +0 -1
  29. package/dist/aegis256-bs.js +0 -477
  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 -709
  46. package/src/aegis128l.ts +0 -653
  47. package/src/aegis128x.ts +0 -932
  48. package/src/aegis256-bs.ts +0 -625
  49. package/src/aegis256.ts +0 -597
  50. package/src/aegis256x.ts +0 -893
  51. package/src/aes-bs.ts +0 -459
  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,38 +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).
48
+ * Put a single AES block into the unpacked state at the given block position.
38
49
  */
39
- export declare function pack04(st: AesBlocks): void;
50
+ export declare function blocksPut(st: AesBlocks, s: AesBlock, block: number): void;
40
51
  /**
41
- * Computes the index into the bitsliced state array.
42
- * @param block - Block index (0-7)
43
- * @param word - Word index (0-3)
52
+ * Load 16 bytes at the given offset into an AES block (little-endian).
44
53
  */
45
- export declare function wordIdx(block: number, word: number): number;
54
+ export declare function blockFromBytes(out: AesBlock, src: Uint8Array, off?: number): void;
55
+ /**
56
+ * Store an AES block as 16 bytes at the given offset (little-endian).
57
+ */
58
+ export declare function blockToBytes(out: Uint8Array, src: AesBlock, off?: number): void;
46
59
  /**
47
- * Rotate all blocks right by 1 position (for AEGIS state rotation).
48
- * Performs (st[i] & 0xfefefefe) >> 1 | (st[i] & 0x01010101) << 7
60
+ * XOR two AES blocks: out = a ^ b
49
61
  */
50
- export declare function blocksRotr(st: AesBlocks): void;
62
+ export declare function blockXor(out: AesBlock, a: AesBlock, b: AesBlock): void;
51
63
  /**
52
- * Put a single AES block into the bitsliced state at the given block position.
64
+ * Fused AEGIS-128L update round on the packed state:
65
+ * st = st ^ rotr8(AESRound(st)) ^ ci, where rotr8 rotates the 8 block lanes.
53
66
  */
54
- export declare function blocksPut(st: AesBlocks, s: AesBlock, block: number): void;
67
+ export declare function aegisRound128(st: AesBlocks, ci: AesBlocks): void;
55
68
  /**
56
- * Load a 16-byte buffer into an AES block (4 uint32 little-endian).
69
+ * Fused AEGIS-256 update round on the packed state:
70
+ * st = st ^ rotr6(AESRound(st)) ^ ci, where rotr6 rotates the 6 block lanes.
57
71
  */
58
- export declare function blockFromBytes(out: AesBlock, src: Uint8Array): void;
72
+ export declare function aegisRound256(st: AesBlocks, ci: AesBlocks): void;
59
73
  /**
60
- * Store an AES block to a 16-byte buffer (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.
61
76
  */
62
- export declare function blockToBytes(out: Uint8Array, src: AesBlock): void;
77
+ export declare function packConstantInput128(out: AesBlocks, m0: AesBlock, m1: AesBlock): void;
63
78
  /**
64
- * XOR two AES blocks: out = a ^ b
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.
65
81
  */
66
- export declare function blockXor(out: AesBlock, a: AesBlock, b: AesBlock): void;
82
+ export declare function packConstantInput256(out: AesBlocks, m: AesBlock): void;
83
+ /**
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).
87
+ */
88
+ export declare function keystream128(st: AesBlocks, z0: AesBlock, z1: AesBlock): void;
67
89
  /**
68
- * 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).
69
93
  */
70
- export declare function blocksXor(a: AesBlocks, b: AesBlocks): void;
71
- //# sourceMappingURL=aes-bs.d.ts.map
94
+ export declare function keystream256(st: AesBlocks, z: AesBlock): void;