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.
- package/README.md +29 -22
- package/dist/aegis128l.d.ts +33 -33
- package/dist/aegis128l.js +225 -235
- package/dist/aegis128x.d.ts +35 -35
- package/dist/aegis128x.js +348 -282
- package/dist/aegis256.d.ts +34 -51
- package/dist/aegis256.js +215 -206
- package/dist/aegis256x.d.ts +32 -33
- package/dist/aegis256x.js +333 -265
- package/dist/aes-bs.d.ts +46 -23
- package/dist/aes-bs.js +2273 -331
- package/dist/index.d.ts +4 -7
- package/dist/index.js +4 -7
- package/dist/random.d.ts +0 -1
- package/dist/random.js +0 -1
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +31 -0
- package/package.json +6 -6
- package/dist/aegis128l-bs.d.ts +0 -194
- package/dist/aegis128l-bs.d.ts.map +0 -1
- package/dist/aegis128l-bs.js +0 -549
- package/dist/aegis128l-bs.js.map +0 -1
- package/dist/aegis128l.d.ts.map +0 -1
- package/dist/aegis128l.js.map +0 -1
- package/dist/aegis128x.d.ts.map +0 -1
- package/dist/aegis128x.js.map +0 -1
- package/dist/aegis256-bs.d.ts +0 -183
- package/dist/aegis256-bs.d.ts.map +0 -1
- package/dist/aegis256-bs.js +0 -477
- package/dist/aegis256-bs.js.map +0 -1
- package/dist/aegis256.d.ts.map +0 -1
- package/dist/aegis256.js.map +0 -1
- package/dist/aegis256x.d.ts.map +0 -1
- package/dist/aegis256x.js.map +0 -1
- package/dist/aes-bs.d.ts.map +0 -1
- package/dist/aes-bs.js.map +0 -1
- package/dist/aes.d.ts +0 -81
- package/dist/aes.d.ts.map +0 -1
- package/dist/aes.js +0 -232
- package/dist/aes.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/random.d.ts.map +0 -1
- package/dist/random.js.map +0 -1
- package/src/aegis128l-bs.ts +0 -709
- package/src/aegis128l.ts +0 -653
- package/src/aegis128x.ts +0 -932
- package/src/aegis256-bs.ts +0 -625
- package/src/aegis256.ts +0 -597
- package/src/aegis256x.ts +0 -893
- package/src/aes-bs.ts +0 -459
- package/src/aes.ts +0 -271
- package/src/index.ts +0 -126
- package/src/random.ts +0 -41
- package/src/typed-array.d.ts +0 -18
package/src/aes.ts
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
const SBOX = new Uint8Array([
|
|
2
|
-
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe,
|
|
3
|
-
0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4,
|
|
4
|
-
0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7,
|
|
5
|
-
0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3,
|
|
6
|
-
0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09,
|
|
7
|
-
0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3,
|
|
8
|
-
0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe,
|
|
9
|
-
0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
|
|
10
|
-
0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92,
|
|
11
|
-
0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c,
|
|
12
|
-
0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19,
|
|
13
|
-
0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14,
|
|
14
|
-
0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2,
|
|
15
|
-
0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5,
|
|
16
|
-
0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25,
|
|
17
|
-
0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
|
18
|
-
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86,
|
|
19
|
-
0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e,
|
|
20
|
-
0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42,
|
|
21
|
-
0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16,
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
function mul2(x: number): number {
|
|
25
|
-
return ((x << 1) ^ ((x >>> 7) * 0x1b)) & 0xff;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function mul3(x: number): number {
|
|
29
|
-
return mul2(x) ^ x;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Performs a single AES round (SubBytes, ShiftRows, MixColumns, AddRoundKey).
|
|
34
|
-
* Writes result to the provided output buffer.
|
|
35
|
-
* @param input - 16-byte input block
|
|
36
|
-
* @param roundKey - 16-byte round key
|
|
37
|
-
* @param out - 16-byte output buffer
|
|
38
|
-
*/
|
|
39
|
-
export function aesRoundTo(
|
|
40
|
-
input: ArrayLike<number>,
|
|
41
|
-
roundKey: ArrayLike<number>,
|
|
42
|
-
out: Uint8Array,
|
|
43
|
-
): void {
|
|
44
|
-
const s0 = SBOX[input[0]!]!;
|
|
45
|
-
const s1 = SBOX[input[5]!]!;
|
|
46
|
-
const s2 = SBOX[input[10]!]!;
|
|
47
|
-
const s3 = SBOX[input[15]!]!;
|
|
48
|
-
const s4 = SBOX[input[4]!]!;
|
|
49
|
-
const s5 = SBOX[input[9]!]!;
|
|
50
|
-
const s6 = SBOX[input[14]!]!;
|
|
51
|
-
const s7 = SBOX[input[3]!]!;
|
|
52
|
-
const s8 = SBOX[input[8]!]!;
|
|
53
|
-
const s9 = SBOX[input[13]!]!;
|
|
54
|
-
const s10 = SBOX[input[2]!]!;
|
|
55
|
-
const s11 = SBOX[input[7]!]!;
|
|
56
|
-
const s12 = SBOX[input[12]!]!;
|
|
57
|
-
const s13 = SBOX[input[1]!]!;
|
|
58
|
-
const s14 = SBOX[input[6]!]!;
|
|
59
|
-
const s15 = SBOX[input[11]!]!;
|
|
60
|
-
|
|
61
|
-
out[0] = mul2(s0) ^ mul3(s1) ^ s2 ^ s3 ^ roundKey[0]!;
|
|
62
|
-
out[1] = s0 ^ mul2(s1) ^ mul3(s2) ^ s3 ^ roundKey[1]!;
|
|
63
|
-
out[2] = s0 ^ s1 ^ mul2(s2) ^ mul3(s3) ^ roundKey[2]!;
|
|
64
|
-
out[3] = mul3(s0) ^ s1 ^ s2 ^ mul2(s3) ^ roundKey[3]!;
|
|
65
|
-
out[4] = mul2(s4) ^ mul3(s5) ^ s6 ^ s7 ^ roundKey[4]!;
|
|
66
|
-
out[5] = s4 ^ mul2(s5) ^ mul3(s6) ^ s7 ^ roundKey[5]!;
|
|
67
|
-
out[6] = s4 ^ s5 ^ mul2(s6) ^ mul3(s7) ^ roundKey[6]!;
|
|
68
|
-
out[7] = mul3(s4) ^ s5 ^ s6 ^ mul2(s7) ^ roundKey[7]!;
|
|
69
|
-
out[8] = mul2(s8) ^ mul3(s9) ^ s10 ^ s11 ^ roundKey[8]!;
|
|
70
|
-
out[9] = s8 ^ mul2(s9) ^ mul3(s10) ^ s11 ^ roundKey[9]!;
|
|
71
|
-
out[10] = s8 ^ s9 ^ mul2(s10) ^ mul3(s11) ^ roundKey[10]!;
|
|
72
|
-
out[11] = mul3(s8) ^ s9 ^ s10 ^ mul2(s11) ^ roundKey[11]!;
|
|
73
|
-
out[12] = mul2(s12) ^ mul3(s13) ^ s14 ^ s15 ^ roundKey[12]!;
|
|
74
|
-
out[13] = s12 ^ mul2(s13) ^ mul3(s14) ^ s15 ^ roundKey[13]!;
|
|
75
|
-
out[14] = s12 ^ s13 ^ mul2(s14) ^ mul3(s15) ^ roundKey[14]!;
|
|
76
|
-
out[15] = mul3(s12) ^ s13 ^ s14 ^ mul2(s15) ^ roundKey[15]!;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Performs a single AES round (SubBytes, ShiftRows, MixColumns, AddRoundKey).
|
|
81
|
-
* @param input - 16-byte input block
|
|
82
|
-
* @param roundKey - 16-byte round key
|
|
83
|
-
* @returns 16-byte output block
|
|
84
|
-
*/
|
|
85
|
-
export function aesRound(
|
|
86
|
-
input: ArrayLike<number>,
|
|
87
|
-
roundKey: ArrayLike<number>,
|
|
88
|
-
): Uint8Array {
|
|
89
|
-
const out = new Uint8Array(16);
|
|
90
|
-
aesRoundTo(input, roundKey, out);
|
|
91
|
-
return out;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* XORs two 16-byte blocks and writes result to destination.
|
|
96
|
-
* @param a - First byte array
|
|
97
|
-
* @param b - Second byte array
|
|
98
|
-
* @param out - Output buffer
|
|
99
|
-
*/
|
|
100
|
-
export function xorBlocksTo(
|
|
101
|
-
a: ArrayLike<number>,
|
|
102
|
-
b: ArrayLike<number>,
|
|
103
|
-
out: Uint8Array,
|
|
104
|
-
): void {
|
|
105
|
-
out[0] = a[0]! ^ b[0]!;
|
|
106
|
-
out[1] = a[1]! ^ b[1]!;
|
|
107
|
-
out[2] = a[2]! ^ b[2]!;
|
|
108
|
-
out[3] = a[3]! ^ b[3]!;
|
|
109
|
-
out[4] = a[4]! ^ b[4]!;
|
|
110
|
-
out[5] = a[5]! ^ b[5]!;
|
|
111
|
-
out[6] = a[6]! ^ b[6]!;
|
|
112
|
-
out[7] = a[7]! ^ b[7]!;
|
|
113
|
-
out[8] = a[8]! ^ b[8]!;
|
|
114
|
-
out[9] = a[9]! ^ b[9]!;
|
|
115
|
-
out[10] = a[10]! ^ b[10]!;
|
|
116
|
-
out[11] = a[11]! ^ b[11]!;
|
|
117
|
-
out[12] = a[12]! ^ b[12]!;
|
|
118
|
-
out[13] = a[13]! ^ b[13]!;
|
|
119
|
-
out[14] = a[14]! ^ b[14]!;
|
|
120
|
-
out[15] = a[15]! ^ b[15]!;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* XORs two byte arrays of equal length.
|
|
125
|
-
* @param a - First byte array
|
|
126
|
-
* @param b - Second byte array
|
|
127
|
-
* @returns XOR result
|
|
128
|
-
*/
|
|
129
|
-
export function xorBlocks(
|
|
130
|
-
a: ArrayLike<number>,
|
|
131
|
-
b: ArrayLike<number>,
|
|
132
|
-
): Uint8Array {
|
|
133
|
-
const result = new Uint8Array(a.length);
|
|
134
|
-
for (let i = 0; i < a.length; i++) {
|
|
135
|
-
result[i] = a[i]! ^ b[i]!;
|
|
136
|
-
}
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* ANDs two 16-byte blocks and writes result to destination.
|
|
142
|
-
* @param a - First byte array
|
|
143
|
-
* @param b - Second byte array
|
|
144
|
-
* @param out - Output buffer
|
|
145
|
-
*/
|
|
146
|
-
export function andBlocksTo(
|
|
147
|
-
a: ArrayLike<number>,
|
|
148
|
-
b: ArrayLike<number>,
|
|
149
|
-
out: Uint8Array,
|
|
150
|
-
): void {
|
|
151
|
-
out[0] = a[0]! & b[0]!;
|
|
152
|
-
out[1] = a[1]! & b[1]!;
|
|
153
|
-
out[2] = a[2]! & b[2]!;
|
|
154
|
-
out[3] = a[3]! & b[3]!;
|
|
155
|
-
out[4] = a[4]! & b[4]!;
|
|
156
|
-
out[5] = a[5]! & b[5]!;
|
|
157
|
-
out[6] = a[6]! & b[6]!;
|
|
158
|
-
out[7] = a[7]! & b[7]!;
|
|
159
|
-
out[8] = a[8]! & b[8]!;
|
|
160
|
-
out[9] = a[9]! & b[9]!;
|
|
161
|
-
out[10] = a[10]! & b[10]!;
|
|
162
|
-
out[11] = a[11]! & b[11]!;
|
|
163
|
-
out[12] = a[12]! & b[12]!;
|
|
164
|
-
out[13] = a[13]! & b[13]!;
|
|
165
|
-
out[14] = a[14]! & b[14]!;
|
|
166
|
-
out[15] = a[15]! & b[15]!;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* ANDs two byte arrays of equal length.
|
|
171
|
-
* @param a - First byte array
|
|
172
|
-
* @param b - Second byte array
|
|
173
|
-
* @returns AND result
|
|
174
|
-
*/
|
|
175
|
-
export function andBlocks(
|
|
176
|
-
a: ArrayLike<number>,
|
|
177
|
-
b: ArrayLike<number>,
|
|
178
|
-
): Uint8Array {
|
|
179
|
-
const result = new Uint8Array(a.length);
|
|
180
|
-
for (let i = 0; i < a.length; i++) {
|
|
181
|
-
result[i] = a[i]! & b[i]!;
|
|
182
|
-
}
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Pads data with zeros to a multiple of the block size.
|
|
188
|
-
* @param data - Input data
|
|
189
|
-
* @param blockSizeBytes - Block size in bytes
|
|
190
|
-
* @returns Padded data (or empty array if data is empty)
|
|
191
|
-
*/
|
|
192
|
-
export function zeroPad(
|
|
193
|
-
data: ArrayLike<number>,
|
|
194
|
-
blockSizeBytes: number,
|
|
195
|
-
): Uint8Array {
|
|
196
|
-
if (data.length === 0) return new Uint8Array(0);
|
|
197
|
-
const paddedLen = Math.ceil(data.length / blockSizeBytes) * blockSizeBytes;
|
|
198
|
-
if (paddedLen === data.length) return new Uint8Array(data);
|
|
199
|
-
const padded = new Uint8Array(paddedLen);
|
|
200
|
-
padded.set(data);
|
|
201
|
-
return padded;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Concatenates multiple byte arrays into a single Uint8Array.
|
|
206
|
-
* @param arrays - Byte arrays to concatenate
|
|
207
|
-
* @returns Concatenated result
|
|
208
|
-
*/
|
|
209
|
-
export function concatBytes(...arrays: ArrayLike<number>[]): Uint8Array {
|
|
210
|
-
const totalLen = arrays.reduce((sum, arr) => sum + arr.length, 0);
|
|
211
|
-
const result = new Uint8Array(totalLen);
|
|
212
|
-
let offset = 0;
|
|
213
|
-
for (const arr of arrays) {
|
|
214
|
-
result.set(arr, offset);
|
|
215
|
-
offset += arr.length;
|
|
216
|
-
}
|
|
217
|
-
return result;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Writes a 64-bit unsigned integer in little-endian format to a buffer.
|
|
222
|
-
* @param value - Value to encode (as bigint)
|
|
223
|
-
* @param out - Output buffer (at least 8 bytes)
|
|
224
|
-
* @param offset - Offset in output buffer (default: 0)
|
|
225
|
-
*/
|
|
226
|
-
export function le64To(value: bigint, out: Uint8Array, offset = 0): void {
|
|
227
|
-
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
228
|
-
view.setUint32(offset, Number(value & 0xffffffffn), true);
|
|
229
|
-
view.setUint32(offset + 4, Number((value >> 32n) & 0xffffffffn), true);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Encodes a 64-bit unsigned integer in little-endian format.
|
|
234
|
-
* @param value - Value to encode (as bigint)
|
|
235
|
-
* @returns 8-byte little-endian representation
|
|
236
|
-
*/
|
|
237
|
-
export function le64(value: bigint): Uint8Array {
|
|
238
|
-
const result = new Uint8Array(8);
|
|
239
|
-
le64To(value, result);
|
|
240
|
-
return result;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Compares two byte arrays in constant time to prevent timing attacks.
|
|
245
|
-
* @param a - First byte array
|
|
246
|
-
* @param b - Second byte array
|
|
247
|
-
* @returns True if arrays are equal, false otherwise
|
|
248
|
-
*/
|
|
249
|
-
export function constantTimeEqual(
|
|
250
|
-
a: ArrayLike<number>,
|
|
251
|
-
b: ArrayLike<number>,
|
|
252
|
-
): boolean {
|
|
253
|
-
if (a.length !== b.length) return false;
|
|
254
|
-
let diff = 0;
|
|
255
|
-
for (let i = 0; i < a.length; i++) {
|
|
256
|
-
diff |= a[i]! ^ b[i]!;
|
|
257
|
-
}
|
|
258
|
-
return diff === 0;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/** AEGIS initialization constant C0 (first bytes of the Fibonacci sequence mod 256). */
|
|
262
|
-
export const C0 = new Uint8Array([
|
|
263
|
-
0x00, 0x01, 0x01, 0x02, 0x03, 0x05, 0x08, 0x0d, 0x15, 0x22, 0x37, 0x59, 0x90,
|
|
264
|
-
0xe9, 0x79, 0x62,
|
|
265
|
-
]);
|
|
266
|
-
|
|
267
|
-
/** AEGIS initialization constant C1 (derived from sqrt(5)). */
|
|
268
|
-
export const C1 = new Uint8Array([
|
|
269
|
-
0xdb, 0x3d, 0x18, 0x55, 0x6d, 0xc2, 0x2f, 0xf1, 0x20, 0x11, 0x31, 0x42, 0x73,
|
|
270
|
-
0xb5, 0x28, 0xdd,
|
|
271
|
-
]);
|
package/src/index.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
AEGIS_128L_KEY_SIZE,
|
|
3
|
-
AEGIS_128L_NONCE_SIZE,
|
|
4
|
-
aegis128LCreateKey,
|
|
5
|
-
aegis128LCreateNonce,
|
|
6
|
-
aegis128LDecrypt,
|
|
7
|
-
aegis128LDecryptDetached,
|
|
8
|
-
aegis128LDecryptDetachedInPlace,
|
|
9
|
-
aegis128LEncrypt,
|
|
10
|
-
aegis128LEncryptDetached,
|
|
11
|
-
aegis128LEncryptDetachedInPlace,
|
|
12
|
-
aegis128LMac,
|
|
13
|
-
aegis128LMacVerify,
|
|
14
|
-
} from "./aegis128l.js";
|
|
15
|
-
export {
|
|
16
|
-
AEGIS_128L_BS_KEY_SIZE,
|
|
17
|
-
AEGIS_128L_BS_NONCE_SIZE,
|
|
18
|
-
Aegis128LBsState,
|
|
19
|
-
aegis128LBsCreateKey,
|
|
20
|
-
aegis128LBsCreateNonce,
|
|
21
|
-
aegis128LBsDecrypt,
|
|
22
|
-
aegis128LBsDecryptDetached,
|
|
23
|
-
aegis128LBsDecryptDetachedInPlace,
|
|
24
|
-
aegis128LBsEncrypt,
|
|
25
|
-
aegis128LBsEncryptDetached,
|
|
26
|
-
aegis128LBsEncryptDetachedInPlace,
|
|
27
|
-
aegis128LBsMac,
|
|
28
|
-
aegis128LBsMacVerify,
|
|
29
|
-
} from "./aegis128l-bs.js";
|
|
30
|
-
export {
|
|
31
|
-
AEGIS_128X_KEY_SIZE,
|
|
32
|
-
AEGIS_128X_NONCE_SIZE,
|
|
33
|
-
aegis128X2CreateKey,
|
|
34
|
-
aegis128X2CreateNonce,
|
|
35
|
-
aegis128X2Decrypt,
|
|
36
|
-
aegis128X2DecryptDetached,
|
|
37
|
-
aegis128X2DecryptDetachedInPlace,
|
|
38
|
-
aegis128X2Encrypt,
|
|
39
|
-
aegis128X2EncryptDetached,
|
|
40
|
-
aegis128X2EncryptDetachedInPlace,
|
|
41
|
-
aegis128X2Mac,
|
|
42
|
-
aegis128X2MacVerify,
|
|
43
|
-
aegis128X4CreateKey,
|
|
44
|
-
aegis128X4CreateNonce,
|
|
45
|
-
aegis128X4Decrypt,
|
|
46
|
-
aegis128X4DecryptDetached,
|
|
47
|
-
aegis128X4DecryptDetachedInPlace,
|
|
48
|
-
aegis128X4Encrypt,
|
|
49
|
-
aegis128X4EncryptDetached,
|
|
50
|
-
aegis128X4EncryptDetachedInPlace,
|
|
51
|
-
aegis128X4Mac,
|
|
52
|
-
aegis128X4MacVerify,
|
|
53
|
-
aegis128XCreateKey,
|
|
54
|
-
aegis128XCreateNonce,
|
|
55
|
-
aegis128XDecrypt,
|
|
56
|
-
aegis128XDecryptDetached,
|
|
57
|
-
aegis128XDecryptDetachedInPlace,
|
|
58
|
-
aegis128XEncrypt,
|
|
59
|
-
aegis128XEncryptDetached,
|
|
60
|
-
aegis128XEncryptDetachedInPlace,
|
|
61
|
-
aegis128XMac,
|
|
62
|
-
aegis128XMacVerify,
|
|
63
|
-
} from "./aegis128x.js";
|
|
64
|
-
export {
|
|
65
|
-
AEGIS_256_KEY_SIZE,
|
|
66
|
-
AEGIS_256_NONCE_SIZE,
|
|
67
|
-
aegis256CreateKey,
|
|
68
|
-
aegis256CreateNonce,
|
|
69
|
-
aegis256Decrypt,
|
|
70
|
-
aegis256DecryptDetached,
|
|
71
|
-
aegis256DecryptDetachedInPlace,
|
|
72
|
-
aegis256Encrypt,
|
|
73
|
-
aegis256EncryptDetached,
|
|
74
|
-
aegis256EncryptDetachedInPlace,
|
|
75
|
-
aegis256Mac,
|
|
76
|
-
aegis256MacVerify,
|
|
77
|
-
} from "./aegis256.js";
|
|
78
|
-
export {
|
|
79
|
-
AEGIS_256_BS_KEY_SIZE,
|
|
80
|
-
AEGIS_256_BS_NONCE_SIZE,
|
|
81
|
-
Aegis256BsState,
|
|
82
|
-
aegis256BsCreateKey,
|
|
83
|
-
aegis256BsCreateNonce,
|
|
84
|
-
aegis256BsDecrypt,
|
|
85
|
-
aegis256BsDecryptDetached,
|
|
86
|
-
aegis256BsDecryptDetachedInPlace,
|
|
87
|
-
aegis256BsEncrypt,
|
|
88
|
-
aegis256BsEncryptDetached,
|
|
89
|
-
aegis256BsEncryptDetachedInPlace,
|
|
90
|
-
aegis256BsMac,
|
|
91
|
-
aegis256BsMacVerify,
|
|
92
|
-
} from "./aegis256-bs.js";
|
|
93
|
-
export {
|
|
94
|
-
AEGIS_256X_KEY_SIZE,
|
|
95
|
-
AEGIS_256X_NONCE_SIZE,
|
|
96
|
-
aegis256X2CreateKey,
|
|
97
|
-
aegis256X2CreateNonce,
|
|
98
|
-
aegis256X2Decrypt,
|
|
99
|
-
aegis256X2DecryptDetached,
|
|
100
|
-
aegis256X2DecryptDetachedInPlace,
|
|
101
|
-
aegis256X2Encrypt,
|
|
102
|
-
aegis256X2EncryptDetached,
|
|
103
|
-
aegis256X2EncryptDetachedInPlace,
|
|
104
|
-
aegis256X2Mac,
|
|
105
|
-
aegis256X2MacVerify,
|
|
106
|
-
aegis256X4CreateKey,
|
|
107
|
-
aegis256X4CreateNonce,
|
|
108
|
-
aegis256X4Decrypt,
|
|
109
|
-
aegis256X4DecryptDetached,
|
|
110
|
-
aegis256X4DecryptDetachedInPlace,
|
|
111
|
-
aegis256X4Encrypt,
|
|
112
|
-
aegis256X4EncryptDetached,
|
|
113
|
-
aegis256X4EncryptDetachedInPlace,
|
|
114
|
-
aegis256X4Mac,
|
|
115
|
-
aegis256X4MacVerify,
|
|
116
|
-
aegis256XCreateKey,
|
|
117
|
-
aegis256XCreateNonce,
|
|
118
|
-
aegis256XDecrypt,
|
|
119
|
-
aegis256XDecryptDetached,
|
|
120
|
-
aegis256XDecryptDetachedInPlace,
|
|
121
|
-
aegis256XEncrypt,
|
|
122
|
-
aegis256XEncryptDetached,
|
|
123
|
-
aegis256XEncryptDetachedInPlace,
|
|
124
|
-
aegis256XMac,
|
|
125
|
-
aegis256XMacVerify,
|
|
126
|
-
} from "./aegis256x.js";
|
package/src/random.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-platform cryptographically secure random byte generation.
|
|
3
|
-
*
|
|
4
|
-
* Uses the Web Crypto API (globalThis.crypto.getRandomValues) which is available in:
|
|
5
|
-
* - All modern browsers
|
|
6
|
-
* - Node.js 19+
|
|
7
|
-
* - Deno
|
|
8
|
-
* - Bun
|
|
9
|
-
*
|
|
10
|
-
* For older Node.js versions, you can polyfill:
|
|
11
|
-
* ```
|
|
12
|
-
* globalThis.crypto = require('crypto').webcrypto;
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
function getCrypto(): Crypto {
|
|
17
|
-
if (
|
|
18
|
-
typeof globalThis !== "undefined" &&
|
|
19
|
-
globalThis.crypto &&
|
|
20
|
-
typeof globalThis.crypto.getRandomValues === "function"
|
|
21
|
-
) {
|
|
22
|
-
return globalThis.crypto;
|
|
23
|
-
}
|
|
24
|
-
throw new Error(
|
|
25
|
-
"No cryptographic random source available. " +
|
|
26
|
-
"In older Node.js versions, use: globalThis.crypto = require('crypto').webcrypto",
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generates cryptographically secure random bytes.
|
|
32
|
-
* @param length - Number of random bytes to generate
|
|
33
|
-
* @returns Uint8Array of random bytes
|
|
34
|
-
* @throws Error if no cryptographic random source is available
|
|
35
|
-
*/
|
|
36
|
-
export function randomBytes(length: number): Uint8Array {
|
|
37
|
-
const crypto = getCrypto();
|
|
38
|
-
const bytes = new Uint8Array(length);
|
|
39
|
-
crypto.getRandomValues(bytes);
|
|
40
|
-
return bytes;
|
|
41
|
-
}
|
package/src/typed-array.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface Uint8ArrayConstructor {
|
|
3
|
-
new (length: number): Uint8Array;
|
|
4
|
-
new (array: ArrayLike<number> | ArrayBufferLike): Uint8Array;
|
|
5
|
-
new (
|
|
6
|
-
buffer: ArrayBufferLike,
|
|
7
|
-
byteOffset?: number,
|
|
8
|
-
length?: number,
|
|
9
|
-
): Uint8Array;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Uint8Array {
|
|
13
|
-
subarray(begin?: number, end?: number): Uint8Array;
|
|
14
|
-
slice(start?: number, end?: number): Uint8Array;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {};
|