micro509 0.17.0 → 0.18.0

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 (137) hide show
  1. package/CHANGELOG.md +123 -6
  2. package/README.md +3 -0
  3. package/dist/crypto/crypto.d.ts +2 -3
  4. package/dist/crypto.d.ts +6 -0
  5. package/dist/der/der.d.ts +14 -4
  6. package/dist/der/der.js +19 -19
  7. package/dist/der.d.ts +26 -2
  8. package/dist/der.js +4 -4
  9. package/dist/index.d.ts +82 -15
  10. package/dist/index.js +19 -19
  11. package/dist/internal/asn1/asn1.d.ts +1 -2
  12. package/dist/internal/asn1/der.d.ts +1 -2
  13. package/dist/internal/asn1/oids.js +71 -353
  14. package/dist/internal/asn1/oids.js.map +1 -1
  15. package/dist/internal/asn1/oids.json.js +357 -0
  16. package/dist/internal/asn1/oids.json.js.map +1 -0
  17. package/dist/internal/crypto/algorithm-names.js +1 -1
  18. package/dist/internal/crypto/pbes2.d.ts +1 -2
  19. package/dist/internal/crypto/pbes2.js +70 -70
  20. package/dist/internal/crypto/prime-ec.js +37 -0
  21. package/dist/internal/crypto/prime-ec.js.map +1 -0
  22. package/dist/internal/crypto/rsa-pss.js +50 -50
  23. package/dist/internal/crypto/sig-verify.d.ts +1 -2
  24. package/dist/internal/crypto/sig-verify.js +60 -60
  25. package/dist/internal/crypto/signing.d.ts +1 -2
  26. package/dist/internal/crypto/signing.js +26 -26
  27. package/dist/internal/jose/json-data.js +108 -0
  28. package/dist/internal/jose/json-data.js.map +1 -0
  29. package/dist/internal/jose/strict-json.d.ts +1 -2
  30. package/dist/internal/shared/dn.d.ts +1 -2
  31. package/dist/internal/shared/dn.js +1 -1
  32. package/dist/internal/shared/ip.d.ts +1 -2
  33. package/dist/internal/verify/name-constraints-engine.js +64 -64
  34. package/dist/internal/verify/policy-engine.js +1 -1
  35. package/dist/internal/verify/verify-path.d.ts +1 -2
  36. package/dist/internal/verify/verify-path.js +19 -19
  37. package/dist/internal/x509/directory-name.js +10 -10
  38. package/dist/internal/x509/extension-errors.d.ts +1 -2
  39. package/dist/internal/x509/extension-registry.js +18 -18
  40. package/dist/internal/x509/general-name-profile.js +9 -9
  41. package/dist/internal/x509/general-name.js +32 -32
  42. package/dist/internal/x509/name-fields.js +1 -1
  43. package/dist/jose/base64url.d.ts +4 -0
  44. package/dist/jose/base64url.js +14 -0
  45. package/dist/jose/base64url.js.map +1 -0
  46. package/dist/jose/errors.d.ts +9 -3
  47. package/dist/jose/errors.js.map +1 -1
  48. package/dist/jose/jwe.d.ts +64 -0
  49. package/dist/jose/jwe.js +188 -0
  50. package/dist/jose/jwe.js.map +1 -0
  51. package/dist/jose/jwks.d.ts +38 -10
  52. package/dist/jose/jwks.js +156 -96
  53. package/dist/jose/jwks.js.map +1 -1
  54. package/dist/jose/jws.d.ts +8 -6
  55. package/dist/jose/jws.js +216 -170
  56. package/dist/jose/jws.js.map +1 -1
  57. package/dist/jose/jwt.d.ts +8 -2
  58. package/dist/jose/jwt.js +98 -98
  59. package/dist/jose/remote-jwks.d.ts +1 -2
  60. package/dist/jose/remote-jwks.js +106 -108
  61. package/dist/jose/remote-jwks.js.map +1 -1
  62. package/dist/jose.d.ts +15 -4
  63. package/dist/jose.js +7 -5
  64. package/dist/kdf/argon2-arithmetic.js +15 -0
  65. package/dist/kdf/argon2-arithmetic.js.map +1 -0
  66. package/dist/kdf/argon2-core.js +486 -0
  67. package/dist/kdf/argon2-core.js.map +1 -0
  68. package/dist/kdf/argon2-memory.js +20 -0
  69. package/dist/kdf/argon2-memory.js.map +1 -0
  70. package/dist/kdf/argon2-portable.js +18 -0
  71. package/dist/kdf/argon2-portable.js.map +1 -0
  72. package/dist/kdf/argon2.d.ts +22 -11
  73. package/dist/kdf/argon2.js +32 -13
  74. package/dist/kdf/argon2.js.map +1 -1
  75. package/dist/kdf.d.ts +6 -0
  76. package/dist/keys/keys.d.ts +31 -6
  77. package/dist/keys/keys.js +315 -233
  78. package/dist/keys/keys.js.map +1 -1
  79. package/dist/keys.d.ts +11 -2
  80. package/dist/keys.js +2 -2
  81. package/dist/pem/pem.d.ts +1 -2
  82. package/dist/pem/pem.js +40 -25
  83. package/dist/pem/pem.js.map +1 -1
  84. package/dist/pem.d.ts +6 -0
  85. package/dist/pkcs/pfx.d.ts +2 -3
  86. package/dist/pkcs/pfx.js +142 -142
  87. package/dist/pkcs/pkcs12-mac.d.ts +1 -2
  88. package/dist/pkcs/pkcs12-mac.js +122 -122
  89. package/dist/pkcs/pkcs7.d.ts +14 -3
  90. package/dist/pkcs/pkcs7.js +268 -248
  91. package/dist/pkcs/pkcs7.js.map +1 -1
  92. package/dist/pkcs.d.ts +10 -1
  93. package/dist/pkcs.js +4 -4
  94. package/dist/result/result.d.ts +1 -2
  95. package/dist/result.d.ts +6 -0
  96. package/dist/revocation/chain.d.ts +2 -3
  97. package/dist/revocation/chain.js +52 -52
  98. package/dist/revocation/crl.d.ts +2 -3
  99. package/dist/revocation/crl.js +319 -319
  100. package/dist/revocation/crl.js.map +1 -1
  101. package/dist/revocation/ocsp.d.ts +2 -3
  102. package/dist/revocation/ocsp.js +395 -395
  103. package/dist/revocation/revocation.d.ts +2 -3
  104. package/dist/revocation/revocation.js +22 -22
  105. package/dist/revocation.d.ts +12 -3
  106. package/dist/revocation.js +4 -4
  107. package/dist/ssh/ssh.d.ts +2 -3
  108. package/dist/ssh/ssh.js +165 -170
  109. package/dist/ssh/ssh.js.map +1 -1
  110. package/dist/ssh/wire.d.ts +1 -2
  111. package/dist/ssh/wire.js +10 -10
  112. package/dist/ssh.d.ts +8 -0
  113. package/dist/verify/identity.d.ts +1 -2
  114. package/dist/verify/identity.js +31 -31
  115. package/dist/verify/name-constraints.d.ts +9 -2
  116. package/dist/verify/policy.d.ts +9 -2
  117. package/dist/verify/verify.d.ts +3 -4
  118. package/dist/verify/verify.js +121 -121
  119. package/dist/verify.d.ts +9 -0
  120. package/dist/x509/certificate.d.ts +4 -5
  121. package/dist/x509/certificate.js +40 -40
  122. package/dist/x509/csr.d.ts +3 -4
  123. package/dist/x509/csr.js +15 -15
  124. package/dist/x509/extensions.d.ts +1 -2
  125. package/dist/x509/extensions.js +165 -165
  126. package/dist/x509/extensions.js.map +1 -1
  127. package/dist/x509/fingerprint.d.ts +1 -2
  128. package/dist/x509/name-text.d.ts +1 -2
  129. package/dist/x509/name.d.ts +1 -2
  130. package/dist/x509/name.js +15 -15
  131. package/dist/x509/parse.d.ts +3 -4
  132. package/dist/x509/parse.js +423 -423
  133. package/dist/x509.d.ts +17 -4
  134. package/dist/x509.js +8 -8
  135. package/package.json +27 -34
  136. package/dist/internal/asn1/oids2.js +0 -75
  137. package/dist/internal/asn1/oids2.js.map +0 -1
@@ -0,0 +1,486 @@
1
+ import { multiplyHigh as e } from "./argon2-arithmetic.js";
2
+ import { createMatrixPool as t } from "./argon2-memory.js";
3
+ // src/kdf/argon2-core.ts
4
+ const n = t(), r = 18446744073709551615n, i = [
5
+ 7640891576956012808n,
6
+ 13503953896175478587n,
7
+ 4354685564936845355n,
8
+ 11912009170470909681n,
9
+ 5840696475078001361n,
10
+ 11170449401992604703n,
11
+ 2270897969802886507n,
12
+ 6620516959819538809n
13
+ ], a = [
14
+ [
15
+ 0,
16
+ 1,
17
+ 2,
18
+ 3,
19
+ 4,
20
+ 5,
21
+ 6,
22
+ 7,
23
+ 8,
24
+ 9,
25
+ 10,
26
+ 11,
27
+ 12,
28
+ 13,
29
+ 14,
30
+ 15
31
+ ],
32
+ [
33
+ 14,
34
+ 10,
35
+ 4,
36
+ 8,
37
+ 9,
38
+ 15,
39
+ 13,
40
+ 6,
41
+ 1,
42
+ 12,
43
+ 0,
44
+ 2,
45
+ 11,
46
+ 7,
47
+ 5,
48
+ 3
49
+ ],
50
+ [
51
+ 11,
52
+ 8,
53
+ 12,
54
+ 0,
55
+ 5,
56
+ 2,
57
+ 15,
58
+ 13,
59
+ 10,
60
+ 14,
61
+ 3,
62
+ 6,
63
+ 7,
64
+ 1,
65
+ 9,
66
+ 4
67
+ ],
68
+ [
69
+ 7,
70
+ 9,
71
+ 3,
72
+ 1,
73
+ 13,
74
+ 12,
75
+ 11,
76
+ 14,
77
+ 2,
78
+ 6,
79
+ 5,
80
+ 10,
81
+ 4,
82
+ 0,
83
+ 15,
84
+ 8
85
+ ],
86
+ [
87
+ 9,
88
+ 0,
89
+ 5,
90
+ 7,
91
+ 2,
92
+ 4,
93
+ 10,
94
+ 15,
95
+ 14,
96
+ 1,
97
+ 11,
98
+ 12,
99
+ 6,
100
+ 8,
101
+ 3,
102
+ 13
103
+ ],
104
+ [
105
+ 2,
106
+ 12,
107
+ 6,
108
+ 10,
109
+ 0,
110
+ 11,
111
+ 8,
112
+ 3,
113
+ 4,
114
+ 13,
115
+ 7,
116
+ 5,
117
+ 15,
118
+ 14,
119
+ 1,
120
+ 9
121
+ ],
122
+ [
123
+ 12,
124
+ 5,
125
+ 1,
126
+ 15,
127
+ 14,
128
+ 13,
129
+ 4,
130
+ 10,
131
+ 0,
132
+ 7,
133
+ 6,
134
+ 3,
135
+ 9,
136
+ 2,
137
+ 8,
138
+ 11
139
+ ],
140
+ [
141
+ 13,
142
+ 11,
143
+ 7,
144
+ 14,
145
+ 12,
146
+ 1,
147
+ 3,
148
+ 9,
149
+ 5,
150
+ 0,
151
+ 15,
152
+ 4,
153
+ 8,
154
+ 6,
155
+ 2,
156
+ 10
157
+ ],
158
+ [
159
+ 6,
160
+ 15,
161
+ 14,
162
+ 9,
163
+ 11,
164
+ 3,
165
+ 0,
166
+ 8,
167
+ 12,
168
+ 2,
169
+ 13,
170
+ 7,
171
+ 1,
172
+ 4,
173
+ 10,
174
+ 5
175
+ ],
176
+ [
177
+ 10,
178
+ 2,
179
+ 8,
180
+ 4,
181
+ 7,
182
+ 6,
183
+ 1,
184
+ 5,
185
+ 15,
186
+ 11,
187
+ 9,
188
+ 14,
189
+ 3,
190
+ 12,
191
+ 13,
192
+ 0
193
+ ],
194
+ [
195
+ 0,
196
+ 1,
197
+ 2,
198
+ 3,
199
+ 4,
200
+ 5,
201
+ 6,
202
+ 7,
203
+ 8,
204
+ 9,
205
+ 10,
206
+ 11,
207
+ 12,
208
+ 13,
209
+ 14,
210
+ 15
211
+ ],
212
+ [
213
+ 14,
214
+ 10,
215
+ 4,
216
+ 8,
217
+ 9,
218
+ 15,
219
+ 13,
220
+ 6,
221
+ 1,
222
+ 12,
223
+ 0,
224
+ 2,
225
+ 11,
226
+ 7,
227
+ 5,
228
+ 3
229
+ ]
230
+ ], o = [
231
+ [
232
+ 0,
233
+ 4,
234
+ 8,
235
+ 12
236
+ ],
237
+ [
238
+ 1,
239
+ 5,
240
+ 9,
241
+ 13
242
+ ],
243
+ [
244
+ 2,
245
+ 6,
246
+ 10,
247
+ 14
248
+ ],
249
+ [
250
+ 3,
251
+ 7,
252
+ 11,
253
+ 15
254
+ ],
255
+ [
256
+ 0,
257
+ 5,
258
+ 10,
259
+ 15
260
+ ],
261
+ [
262
+ 1,
263
+ 6,
264
+ 11,
265
+ 12
266
+ ],
267
+ [
268
+ 2,
269
+ 7,
270
+ 8,
271
+ 13
272
+ ],
273
+ [
274
+ 3,
275
+ 4,
276
+ 9,
277
+ 14
278
+ ]
279
+ ];
280
+ function read32(e, t) {
281
+ return ((e[t] ?? 0) | (e[t + 1] ?? 0) << 8 | (e[t + 2] ?? 0) << 16 | (e[t + 3] ?? 0) << 24) >>> 0;
282
+ }
283
+ function write32(e, t, n) {
284
+ e[t] = n & 255, e[t + 1] = n >>> 8 & 255, e[t + 2] = n >>> 16 & 255, e[t + 3] = n >>> 24;
285
+ }
286
+ function read64(e, t) {
287
+ let n = 0n;
288
+ for (let r = 7; r >= 0; --r) n = n << 8n | BigInt(e[t + r] ?? 0);
289
+ return n;
290
+ }
291
+ function concat(...e) {
292
+ let t = new Uint8Array(e.reduce((e, t) => e + t.length, 0)), n = 0;
293
+ for (let r of e) t.set(r, n), n += r.length;
294
+ return t;
295
+ }
296
+ function blakeMix(e, t, n, i, a, o, s) {
297
+ e[t] = (e[t] ?? 0n) + (e[n] ?? 0n) + o & r, e[a] = rotateRight((e[a] ?? 0n) ^ (e[t] ?? 0n), 32), e[i] = (e[i] ?? 0n) + (e[a] ?? 0n) & r, e[n] = rotateRight((e[n] ?? 0n) ^ (e[i] ?? 0n), 24), e[t] = (e[t] ?? 0n) + (e[n] ?? 0n) + s & r, e[a] = rotateRight((e[a] ?? 0n) ^ (e[t] ?? 0n), 16), e[i] = (e[i] ?? 0n) + (e[a] ?? 0n) & r, e[n] = rotateRight((e[n] ?? 0n) ^ (e[i] ?? 0n), 63);
298
+ }
299
+ function rotateRight(e, t) {
300
+ let n = BigInt(t);
301
+ return (e >> n | e << 64n - n) & r;
302
+ }
303
+ function blakeRound(e, t, n) {
304
+ for (let [r, [i, a, s, c]] of o.entries()) blakeMix(e, i, a, s, c, t[n[r * 2] ?? 0] ?? 0n, t[n[r * 2 + 1] ?? 0] ?? 0n);
305
+ }
306
+ function blake2bCompress(e, t, n, o) {
307
+ let s = Array.from({ length: 16 }, (e, n) => read64(t, n * 8)), c = [...e, ...i];
308
+ try {
309
+ c[12] = (c[12] ?? 0n) ^ n & r, c[13] = (c[13] ?? 0n) ^ n >> 64n, o && (c[14] = (c[14] ?? 0n) ^ r);
310
+ for (let e of a) blakeRound(c, s, e);
311
+ for (let t = 0; t < 8; t += 1) e[t] = (e[t] ?? 0n) ^ (c[t] ?? 0n) ^ (c[t + 8] ?? 0n);
312
+ } finally {
313
+ s.fill(0n), c.fill(0n);
314
+ }
315
+ }
316
+ function blake2b(e, t) {
317
+ let n = [...i], r = /* @__PURE__ */ new Uint8Array(128);
318
+ try {
319
+ n[0] = (n[0] ?? 0n) ^ (16842752n | BigInt(t));
320
+ let i = 0;
321
+ for (; e.length - i > 128;) blake2bCompress(n, e.subarray(i, i + 128), BigInt(i + 128), !1), i += 128;
322
+ r.set(e.subarray(i)), blake2bCompress(n, r, BigInt(e.length), !0);
323
+ let a = new Uint8Array(t);
324
+ for (let e = 0; e < t; e += 1) a[e] = Number((n[Math.floor(e / 8)] ?? 0n) >> BigInt(e % 8 * 8) & 255n);
325
+ return a;
326
+ } finally {
327
+ n.fill(0n), r.fill(0);
328
+ }
329
+ }
330
+ function blakeLong(e, t) {
331
+ let n = concat(Uint8Array.from([
332
+ t & 255,
333
+ t >>> 8 & 255,
334
+ t >>> 16 & 255,
335
+ t >>> 24
336
+ ]), e), r = /* @__PURE__ */ new Uint8Array();
337
+ try {
338
+ if (t <= 64) return blake2b(n, t);
339
+ r = blake2b(n, 64);
340
+ let e = new Uint8Array(t), i = 0;
341
+ for (; t - i > 64;) if (e.set(r.subarray(0, 32), i), i += 32, t - i > 64) {
342
+ let e = blake2b(r, 64);
343
+ r.fill(0), r = e;
344
+ }
345
+ let a = blake2b(r, t - i);
346
+ try {
347
+ return e.set(a, i), e;
348
+ } finally {
349
+ a.fill(0);
350
+ }
351
+ } finally {
352
+ n.fill(0), r.fill(0);
353
+ }
354
+ }
355
+ function initialHash(e, t) {
356
+ let n = e.password, r = e.salt, i = e.secret ?? /* @__PURE__ */ new Uint8Array(), a = e.associatedData ?? /* @__PURE__ */ new Uint8Array(), o = /* @__PURE__ */ new Uint8Array(28), s = [
357
+ e.parallelism,
358
+ e.outputBytes,
359
+ e.memoryKiB,
360
+ e.passes,
361
+ e.version,
362
+ t,
363
+ n.length
364
+ ], c = 0;
365
+ for (let e of s) write32(o, c, e), c += 4;
366
+ let l = /* @__PURE__ */ new Uint8Array(12);
367
+ write32(l, 0, r.length), write32(l, 4, i.length), write32(l, 8, a.length);
368
+ let u = concat(o.subarray(0, 28), n, l.subarray(0, 4), r, l.subarray(4, 8), i, l.subarray(8, 12), a);
369
+ try {
370
+ return blake2b(u, 64);
371
+ } finally {
372
+ u.fill(0);
373
+ }
374
+ }
375
+ function argonMix(t, n, r, i, a) {
376
+ let o = t[n] ?? 0, s = (t[n + 1] ?? 0) | 0, c = t[r] ?? 0, l = (t[r + 1] ?? 0) | 0, u = t[i] ?? 0, d = (t[i + 1] ?? 0) | 0, f = t[a] ?? 0, p = (t[a + 1] ?? 0) | 0, m, h, g, _;
377
+ m = Math.imul(o, c), h = o + c + (m << 1 >>> 0), s = s + l + (e(o, c, m) << 1 | m >>> 31) + (h / 4294967296 | 0) | 0, o = h >>> 0, g = f ^ o, _ = p ^ s, f = _ >>> 0, p = g | 0, m = Math.imul(u, f), h = u + f + (m << 1 >>> 0), d = d + p + (e(u, f, m) << 1 | m >>> 31) + (h / 4294967296 | 0) | 0, u = h >>> 0, g = c ^ u, _ = l ^ d, c = (g >>> 24 | _ << 8) >>> 0, l = _ >>> 24 | g << 8, m = Math.imul(o, c), h = o + c + (m << 1 >>> 0), s = s + l + (e(o, c, m) << 1 | m >>> 31) + (h / 4294967296 | 0) | 0, o = h >>> 0, g = f ^ o, _ = p ^ s, f = (g >>> 16 | _ << 16) >>> 0, p = _ >>> 16 | g << 16, m = Math.imul(u, f), h = u + f + (m << 1 >>> 0), d = d + p + (e(u, f, m) << 1 | m >>> 31) + (h / 4294967296 | 0) | 0, u = h >>> 0, g = c ^ u, _ = l ^ d, c = (g << 1 | _ >>> 31) >>> 0, l = _ << 1 | g >>> 31, t[n] = o, t[n + 1] = s, t[r] = c, t[r + 1] = l, t[i] = u, t[i + 1] = d, t[a] = f, t[a + 1] = p;
378
+ }
379
+ function argonRound(e, t, n, r) {
380
+ argonMix(e, t, t + 2 * n, t + 4 * n, t + 6 * n), argonMix(e, t + r, t + 2 * n + r, t + 4 * n + r, t + 6 * n + r), argonMix(e, t + n, t + 3 * n, t + 5 * n, t + 7 * n), argonMix(e, t + n + r, t + 3 * n + r, t + 5 * n + r, t + 7 * n + r), argonMix(e, t, t + 2 * n + r, t + 5 * n, t + 7 * n + r), argonMix(e, t + r, t + 3 * n, t + 5 * n + r, t + 6 * n), argonMix(e, t + n, t + 3 * n + r, t + 4 * n, t + 6 * n + r), argonMix(e, t + n + r, t + 2 * n, t + 4 * n + r, t + 7 * n);
381
+ }
382
+ function permuteBlock(e) {
383
+ for (let t = 0; t < 256; t += 32) argonRound(e, t, 4, 2);
384
+ for (let t = 0; t < 32; t += 4) argonRound(e, t, 32, 2);
385
+ }
386
+ function fillBlock(e, t, n, r, i, a, o) {
387
+ for (let r = 0; r < 256; r += 1) {
388
+ let i = (e[t + r] ?? 0) ^ (e[n + r] ?? 0);
389
+ a[r] = i, o[r] = i;
390
+ }
391
+ if (permuteBlock(o), i) for (let t = 0; t < 256; t += 1) e[r + t] = (a[t] ?? 0) ^ (o[t] ?? 0) ^ (e[r + t] ?? 0);
392
+ else for (let t = 0; t < 256; t += 1) e[r + t] = (a[t] ?? 0) ^ (o[t] ?? 0);
393
+ }
394
+ function indexAlpha(t, n, r, i, a, o, s) {
395
+ let c;
396
+ c = t === 0 ? n === 0 ? r - 1 : n * a + (i ? r - 1 : r === 0 ? -1 : 0) : o - a + (i ? r - 1 : r === 0 ? -1 : 0);
397
+ let l = e(s, s, Math.imul(s, s)), u = c - 1 - e(c, l, Math.imul(c, l));
398
+ return ((t === 0 || n === 3 ? 0 : (n + 1) * a) + u) % o;
399
+ }
400
+ function dataIndependent(e, t, n) {
401
+ return e === 1 || e === 2 && t === 0 && n < 2;
402
+ }
403
+ function compressBlocks(e, t, n, r, i) {
404
+ for (let n = 0; n < 256; n += 1) {
405
+ let a = (e[n] ?? 0) ^ (t[n] ?? 0);
406
+ r[n] = a, i[n] = a;
407
+ }
408
+ permuteBlock(i);
409
+ for (let e = 0; e < 256; e += 1) n[e] = (r[e] ?? 0) ^ (i[e] ?? 0);
410
+ }
411
+ function generateAddressBlock(e, t, n, r, i, a) {
412
+ e[12] = (e[12] ?? 0) + 1 >>> 0, compressBlocks(n, e, a, r, i), compressBlocks(n, a, t, r, i);
413
+ }
414
+ function toWords(e) {
415
+ let t = /* @__PURE__ */ new Uint32Array(256);
416
+ for (let n = 0; n < 256; n += 1) t[n] = read32(e, n * 4);
417
+ return t;
418
+ }
419
+ function fillIndexedBlock(e, t, n, r, i) {
420
+ let { pass: a, slice: o, lane: s } = n, { memory: c, laneLength: l, segmentLength: u, original: d, permuted: f } = t, p = s * l + o * u + r, m = (p % l === 0 ? p + l - 1 : p - 1) * 256, h = i === void 0 ? m : r % 128 * 2, g = i ?? c, _ = g[h] ?? 0, v = (g[h + 1] ?? 0) % e.parallelism;
421
+ a === 0 && o === 0 && (v = s);
422
+ let y = indexAlpha(a, o, r, v === s, u, l, _), b = p * 256;
423
+ fillBlock(c, m, (v * l + y) * 256, b, e.version !== 16 && a !== 0, d, f);
424
+ }
425
+ async function fillSegment(e, t, n, r) {
426
+ let { pass: i, slice: a, lane: o } = r, { memoryBlocks: s, segmentLength: c, original: l, permuted: u, zero: d, addressTemporary: f } = n, p = dataIndependent(t, i, a), m = /* @__PURE__ */ new Uint32Array(256), h = /* @__PURE__ */ new Uint32Array(256);
427
+ try {
428
+ p && (m[0] = i, m[2] = o, m[4] = a, m[6] = s, m[8] = e.passes, m[10] = t);
429
+ let g = i === 0 && a === 0 ? 2 : 0;
430
+ p && g !== 0 && generateAddressBlock(m, h, d, l, u, f);
431
+ for (let t = g; t < c; t += 512) {
432
+ let i = new Promise((e) => setTimeout(e, 0)), a = Math.min(t + 512, c);
433
+ for (let i = t; i < a; i += 1) p && i % 128 == 0 && generateAddressBlock(m, h, d, l, u, f), fillIndexedBlock(e, n, r, i, p ? h : void 0);
434
+ await i;
435
+ }
436
+ } finally {
437
+ m.fill(0), h.fill(0), f.fill(0);
438
+ }
439
+ }
440
+ async function deriveArgon2TypeScript(e) {
441
+ let t = {
442
+ argon2d: 0,
443
+ argon2i: 1,
444
+ argon2id: 2
445
+ }[e.algorithm], r = Math.floor(e.memoryKiB / (4 * e.parallelism)) * 4 * e.parallelism, i = r / e.parallelism, a = i / 4, o = /* @__PURE__ */ new Uint32Array(), s = /* @__PURE__ */ new Uint8Array(), c = /* @__PURE__ */ new Uint32Array(), l = /* @__PURE__ */ new Uint32Array(), u = /* @__PURE__ */ new Uint32Array(), d = /* @__PURE__ */ new Uint32Array(), f = /* @__PURE__ */ new Uint8Array(), p = /* @__PURE__ */ new Uint32Array();
446
+ try {
447
+ o = n.take(r * 256), s = initialHash(e, t), c = /* @__PURE__ */ new Uint32Array(256), l = /* @__PURE__ */ new Uint32Array(256), u = /* @__PURE__ */ new Uint32Array(256), d = /* @__PURE__ */ new Uint32Array(256);
448
+ for (let t = 0; t < e.parallelism; t += 1) for (let e = 0; e < 2; e += 1) {
449
+ let n = /* @__PURE__ */ new Uint8Array(8);
450
+ write32(n, 0, e), write32(n, 4, t);
451
+ let r = concat(s, n), a = /* @__PURE__ */ new Uint8Array(), c = /* @__PURE__ */ new Uint32Array();
452
+ try {
453
+ a = blakeLong(r, 1024), c = toWords(a), o.set(c, (t * i + e) * 256);
454
+ } finally {
455
+ r.fill(0), a.fill(0), c.fill(0);
456
+ }
457
+ }
458
+ let m = {
459
+ memory: o,
460
+ memoryBlocks: r,
461
+ laneLength: i,
462
+ segmentLength: a,
463
+ original: c,
464
+ permuted: l,
465
+ zero: u,
466
+ addressTemporary: d
467
+ };
468
+ for (let n = 0; n < e.passes; n += 1) for (let r = 0; r < 4; r += 1) for (let i = 0; i < e.parallelism; i += 1) await fillSegment(e, t, m, {
469
+ pass: n,
470
+ slice: r,
471
+ lane: i
472
+ });
473
+ f = /* @__PURE__ */ new Uint8Array(1024), p = toWords(f);
474
+ for (let t = 0; t < e.parallelism; t += 1) {
475
+ let e = (t * i + i - 1) * 256;
476
+ for (let t = 0; t < 256; t += 1) p[t] = (p[t] ?? 0) ^ (o[e + t] ?? 0);
477
+ }
478
+ for (let e = 0; e < 256; e += 1) write32(f, e * 4, p[e] ?? 0);
479
+ return blakeLong(f, e.outputBytes);
480
+ } finally {
481
+ s.fill(0), c.fill(0), l.fill(0), u.fill(0), d.fill(0), f.fill(0), p.fill(0), n.release(o);
482
+ }
483
+ }
484
+ export { deriveArgon2TypeScript };
485
+
486
+ //# sourceMappingURL=argon2-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argon2-core.js","names":["matrices","createMatrixPool","MASK_64","IV","SIGMA","ROUND_INDEXES","bytes","offset","value","index","parts","output","length","part","a","v","b","x","d","c","y","shift","bits","words","sigma","block","h","count","last","finalBlock","outputBytes","input","seed","next","password","salt","secret","associatedData","fields","values","type","tail","message","aLow","aHigh","bLow","bHigh","cLow","cHigh","dLow","dHigh","product","sum","low","high","multiplyHigh","stride","pair","memory","previousOffset","referenceOffset","permuted","withXor","destinationOffset","original","areaSize","pass","slice","segmentLength","sameLane","laneLength","squareHigh","pseudoRandom","relative","previous","reference","inputBlock","zero","addressTemporary","addressBlock","position","workspace","currentBlock","lane","pseudoOffset","pseudo","pseudoLow","referenceLane","referenceIndex","destinationBlock","independent","memoryBlocks","startingIndex","start","pause","resolve","end","h0","finalWords","suffix","lastOffset"],"sources":["../../src/kdf/argon2-core.ts"],"sourcesContent":["/**\n * Argon2 core: RFC 9106 sections 3.2–3.6, with version 0x10 compatibility.\n * BLAKE2b uses 64-bit BigInts; the memory matrix uses little-endian pairs of\n * 32-bit words. Each derivation owns its state and clears mutable work buffers.\n */\nimport type { Argon2Input } from '#micro509/kdf/argon2';\nimport { multiplyHigh } from '#micro509/kdf/argon2-arithmetic';\nimport { createMatrixPool } from '#micro509/kdf/argon2-memory';\n\nconst matrices = createMatrixPool();\n\nconst MASK_64 = 0xffff_ffff_ffff_ffffn;\nconst IV = [\n\t0x6a09e667f3bcc908n,\n\t0xbb67ae8584caa73bn,\n\t0x3c6ef372fe94f82bn,\n\t0xa54ff53a5f1d36f1n,\n\t0x510e527fade682d1n,\n\t0x9b05688c2b3e6c1fn,\n\t0x1f83d9abfb41bd6bn,\n\t0x5be0cd19137e2179n,\n];\nconst SIGMA = [\n\t[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],\n\t[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],\n\t[11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4],\n\t[7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8],\n\t[9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13],\n\t[2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9],\n\t[12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11],\n\t[13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10],\n\t[6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5],\n\t[10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0],\n\t[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],\n\t[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],\n];\n// Column and diagonal quarter-round indexes shared by BLAKE2b and BlaMka.\nconst ROUND_INDEXES = [\n\t[0, 4, 8, 12],\n\t[1, 5, 9, 13],\n\t[2, 6, 10, 14],\n\t[3, 7, 11, 15],\n\t[0, 5, 10, 15],\n\t[1, 6, 11, 12],\n\t[2, 7, 8, 13],\n\t[3, 4, 9, 14],\n] as const;\ntype MutableWords = { length: number; [index: number]: bigint };\n\nfunction read32(bytes: Uint8Array, offset: number): number {\n\treturn (\n\t\t((bytes[offset] ?? 0) |\n\t\t\t((bytes[offset + 1] ?? 0) << 8) |\n\t\t\t((bytes[offset + 2] ?? 0) << 16) |\n\t\t\t((bytes[offset + 3] ?? 0) << 24)) >>>\n\t\t0\n\t);\n}\n\nfunction write32(bytes: Uint8Array, offset: number, value: number): void {\n\tbytes[offset] = value & 0xff;\n\tbytes[offset + 1] = (value >>> 8) & 0xff;\n\tbytes[offset + 2] = (value >>> 16) & 0xff;\n\tbytes[offset + 3] = value >>> 24;\n}\n\nfunction read64(bytes: Uint8Array, offset: number): bigint {\n\tlet value = 0n;\n\tfor (let index = 7; index >= 0; index -= 1) {\n\t\tvalue = (value << 8n) | BigInt(bytes[offset + index] ?? 0);\n\t}\n\treturn value;\n}\n\nfunction concat(...parts: Uint8Array[]): Uint8Array {\n\tconst output = new Uint8Array(parts.reduce((length, part) => length + part.length, 0));\n\tlet offset = 0;\n\tfor (const part of parts) {\n\t\toutput.set(part, offset);\n\t\toffset += part.length;\n\t}\n\treturn output;\n}\n\nfunction blakeMix(\n\tv: MutableWords,\n\ta: number,\n\tb: number,\n\tc: number,\n\td: number,\n\tx: bigint,\n\ty: bigint,\n): void {\n\tv[a] = ((v[a] ?? 0n) + (v[b] ?? 0n) + x) & MASK_64;\n\tv[d] = rotateRight((v[d] ?? 0n) ^ (v[a] ?? 0n), 32);\n\tv[c] = ((v[c] ?? 0n) + (v[d] ?? 0n)) & MASK_64;\n\tv[b] = rotateRight((v[b] ?? 0n) ^ (v[c] ?? 0n), 24);\n\tv[a] = ((v[a] ?? 0n) + (v[b] ?? 0n) + y) & MASK_64;\n\tv[d] = rotateRight((v[d] ?? 0n) ^ (v[a] ?? 0n), 16);\n\tv[c] = ((v[c] ?? 0n) + (v[d] ?? 0n)) & MASK_64;\n\tv[b] = rotateRight((v[b] ?? 0n) ^ (v[c] ?? 0n), 63);\n}\n\nfunction rotateRight(value: bigint, bits: number): bigint {\n\tconst shift = BigInt(bits);\n\treturn ((value >> shift) | (value << (64n - shift))) & MASK_64;\n}\n\nfunction blakeRound(v: MutableWords, words: bigint[], sigma: number[]): void {\n\tfor (const [index, [a, b, c, d]] of ROUND_INDEXES.entries()) {\n\t\tblakeMix(\n\t\t\tv,\n\t\t\ta,\n\t\t\tb,\n\t\t\tc,\n\t\t\td,\n\t\t\twords[sigma[index * 2] ?? 0] ?? 0n,\n\t\t\twords[sigma[index * 2 + 1] ?? 0] ?? 0n,\n\t\t);\n\t}\n}\n\nfunction blake2bCompress(h: bigint[], block: Uint8Array, count: bigint, last: boolean): void {\n\tconst words = Array.from({ length: 16 }, (_, index) => read64(block, index * 8));\n\tconst v = [...h, ...IV];\n\ttry {\n\t\tv[12] = (v[12] ?? 0n) ^ (count & MASK_64);\n\t\tv[13] = (v[13] ?? 0n) ^ (count >> 64n);\n\t\tif (last) v[14] = (v[14] ?? 0n) ^ MASK_64;\n\t\tfor (const sigma of SIGMA) blakeRound(v, words, sigma);\n\t\tfor (let index = 0; index < 8; index += 1) {\n\t\t\th[index] = (h[index] ?? 0n) ^ (v[index] ?? 0n) ^ (v[index + 8] ?? 0n);\n\t\t}\n\t} finally {\n\t\twords.fill(0n);\n\t\tv.fill(0n);\n\t}\n}\n\nfunction blake2b(input: Uint8Array, outputBytes: number): Uint8Array {\n\tconst h = [...IV];\n\tconst finalBlock = new Uint8Array(128);\n\ttry {\n\t\th[0] = (h[0] ?? 0n) ^ (0x01010000n | BigInt(outputBytes));\n\t\tlet offset = 0;\n\t\twhile (input.length - offset > 128) {\n\t\t\tblake2bCompress(h, input.subarray(offset, offset + 128), BigInt(offset + 128), false);\n\t\t\toffset += 128;\n\t\t}\n\t\tfinalBlock.set(input.subarray(offset));\n\t\tblake2bCompress(h, finalBlock, BigInt(input.length), true);\n\t\tconst output = new Uint8Array(outputBytes);\n\t\tfor (let index = 0; index < outputBytes; index += 1) {\n\t\t\toutput[index] = Number(((h[Math.floor(index / 8)] ?? 0n) >> BigInt((index % 8) * 8)) & 0xffn);\n\t\t}\n\t\treturn output;\n\t} finally {\n\t\th.fill(0n);\n\t\tfinalBlock.fill(0);\n\t}\n}\n\nfunction blakeLong(input: Uint8Array, outputBytes: number): Uint8Array {\n\tconst seed = concat(\n\t\tUint8Array.from([\n\t\t\toutputBytes & 0xff,\n\t\t\t(outputBytes >>> 8) & 0xff,\n\t\t\t(outputBytes >>> 16) & 0xff,\n\t\t\toutputBytes >>> 24,\n\t\t]),\n\t\tinput,\n\t);\n\tlet value: Uint8Array<ArrayBufferLike> = new Uint8Array(0);\n\ttry {\n\t\tif (outputBytes <= 64) return blake2b(seed, outputBytes);\n\t\tvalue = blake2b(seed, 64);\n\t\tconst output = new Uint8Array(outputBytes);\n\t\tlet offset = 0;\n\t\twhile (outputBytes - offset > 64) {\n\t\t\toutput.set(value.subarray(0, 32), offset);\n\t\t\toffset += 32;\n\t\t\tif (outputBytes - offset > 64) {\n\t\t\t\tconst next = blake2b(value, 64);\n\t\t\t\tvalue.fill(0);\n\t\t\t\tvalue = next;\n\t\t\t}\n\t\t}\n\t\tconst last = blake2b(value, outputBytes - offset);\n\t\ttry {\n\t\t\toutput.set(last, offset);\n\t\t\treturn output;\n\t\t} finally {\n\t\t\tlast.fill(0);\n\t\t}\n\t} finally {\n\t\tseed.fill(0);\n\t\tvalue.fill(0);\n\t}\n}\n\nfunction initialHash(input: Argon2Input, type: number): Uint8Array {\n\tconst password = input.password;\n\tconst salt = input.salt;\n\tconst secret = input.secret ?? new Uint8Array();\n\tconst associatedData = input.associatedData ?? new Uint8Array();\n\tconst fields = new Uint8Array(28);\n\tconst values = [\n\t\tinput.parallelism,\n\t\tinput.outputBytes,\n\t\tinput.memoryKiB,\n\t\tinput.passes,\n\t\tinput.version,\n\t\ttype,\n\t\tpassword.length,\n\t];\n\tlet offset = 0;\n\tfor (const value of values) {\n\t\twrite32(fields, offset, value);\n\t\toffset += 4;\n\t}\n\tconst tail = new Uint8Array(12);\n\twrite32(tail, 0, salt.length);\n\twrite32(tail, 4, secret.length);\n\twrite32(tail, 8, associatedData.length);\n\tconst message = concat(\n\t\tfields.subarray(0, 28),\n\t\tpassword,\n\t\ttail.subarray(0, 4),\n\t\tsalt,\n\t\ttail.subarray(4, 8),\n\t\tsecret,\n\t\ttail.subarray(8, 12),\n\t\tassociatedData,\n\t);\n\ttry {\n\t\treturn blake2b(message, 64);\n\t} finally {\n\t\tmessage.fill(0);\n\t}\n}\n\n// Keep the four 64-bit registers local throughout the quarter round. The\n// scratch block is read once and written once, instead of at each add/rotate.\n// Low words stay unsigned for carry calculation; high words stay signed so\n// the JIT can use 32-bit addition. Storing into Uint32Array preserves the bits.\nfunction argonMix(words: Uint32Array, a: number, b: number, c: number, d: number): void {\n\tlet aLow = words[a] ?? 0;\n\tlet aHigh = (words[a + 1] ?? 0) | 0;\n\tlet bLow = words[b] ?? 0;\n\tlet bHigh = (words[b + 1] ?? 0) | 0;\n\tlet cLow = words[c] ?? 0;\n\tlet cHigh = (words[c + 1] ?? 0) | 0;\n\tlet dLow = words[d] ?? 0;\n\tlet dHigh = (words[d + 1] ?? 0) | 0;\n\tlet product: number;\n\tlet sum: number;\n\tlet low: number;\n\tlet high: number;\n\n\tproduct = Math.imul(aLow, bLow);\n\tsum = aLow + bLow + ((product << 1) >>> 0);\n\taHigh =\n\t\t(aHigh +\n\t\t\tbHigh +\n\t\t\t((multiplyHigh(aLow, bLow, product) << 1) | (product >>> 31)) +\n\t\t\t((sum / 0x1_0000_0000) | 0)) |\n\t\t0;\n\taLow = sum >>> 0;\n\tlow = dLow ^ aLow;\n\thigh = dHigh ^ aHigh;\n\tdLow = high >>> 0;\n\tdHigh = low | 0;\n\n\tproduct = Math.imul(cLow, dLow);\n\tsum = cLow + dLow + ((product << 1) >>> 0);\n\tcHigh =\n\t\t(cHigh +\n\t\t\tdHigh +\n\t\t\t((multiplyHigh(cLow, dLow, product) << 1) | (product >>> 31)) +\n\t\t\t((sum / 0x1_0000_0000) | 0)) |\n\t\t0;\n\tcLow = sum >>> 0;\n\tlow = bLow ^ cLow;\n\thigh = bHigh ^ cHigh;\n\tbLow = ((low >>> 24) | (high << 8)) >>> 0;\n\tbHigh = (high >>> 24) | (low << 8) | 0;\n\n\tproduct = Math.imul(aLow, bLow);\n\tsum = aLow + bLow + ((product << 1) >>> 0);\n\taHigh =\n\t\t(aHigh +\n\t\t\tbHigh +\n\t\t\t((multiplyHigh(aLow, bLow, product) << 1) | (product >>> 31)) +\n\t\t\t((sum / 0x1_0000_0000) | 0)) |\n\t\t0;\n\taLow = sum >>> 0;\n\tlow = dLow ^ aLow;\n\thigh = dHigh ^ aHigh;\n\tdLow = ((low >>> 16) | (high << 16)) >>> 0;\n\tdHigh = (high >>> 16) | (low << 16) | 0;\n\n\tproduct = Math.imul(cLow, dLow);\n\tsum = cLow + dLow + ((product << 1) >>> 0);\n\tcHigh =\n\t\t(cHigh +\n\t\t\tdHigh +\n\t\t\t((multiplyHigh(cLow, dLow, product) << 1) | (product >>> 31)) +\n\t\t\t((sum / 0x1_0000_0000) | 0)) |\n\t\t0;\n\tcLow = sum >>> 0;\n\tlow = bLow ^ cLow;\n\thigh = bHigh ^ cHigh;\n\tbLow = ((low << 1) | (high >>> 31)) >>> 0;\n\tbHigh = (high << 1) | (low >>> 31) | 0;\n\twords[a] = aLow;\n\twords[a + 1] = aHigh;\n\twords[b] = bLow;\n\twords[b + 1] = bHigh;\n\twords[c] = cLow;\n\twords[c + 1] = cHigh;\n\twords[d] = dLow;\n\twords[d + 1] = dHigh;\n}\n\n// Each round uses fixed word strides: contiguous rows, then paired columns.\n// Spell out the eight quarter rounds to avoid schedule-array loads in the hot loop.\nfunction argonRound(words: Uint32Array, offset: number, stride: number, pair: number): void {\n\targonMix(words, offset, offset + 2 * stride, offset + 4 * stride, offset + 6 * stride);\n\targonMix(\n\t\twords,\n\t\toffset + pair,\n\t\toffset + 2 * stride + pair,\n\t\toffset + 4 * stride + pair,\n\t\toffset + 6 * stride + pair,\n\t);\n\targonMix(words, offset + stride, offset + 3 * stride, offset + 5 * stride, offset + 7 * stride);\n\targonMix(\n\t\twords,\n\t\toffset + stride + pair,\n\t\toffset + 3 * stride + pair,\n\t\toffset + 5 * stride + pair,\n\t\toffset + 7 * stride + pair,\n\t);\n\targonMix(\n\t\twords,\n\t\toffset,\n\t\toffset + 2 * stride + pair,\n\t\toffset + 5 * stride,\n\t\toffset + 7 * stride + pair,\n\t);\n\targonMix(\n\t\twords,\n\t\toffset + pair,\n\t\toffset + 3 * stride,\n\t\toffset + 5 * stride + pair,\n\t\toffset + 6 * stride,\n\t);\n\targonMix(\n\t\twords,\n\t\toffset + stride,\n\t\toffset + 3 * stride + pair,\n\t\toffset + 4 * stride,\n\t\toffset + 6 * stride + pair,\n\t);\n\targonMix(\n\t\twords,\n\t\toffset + stride + pair,\n\t\toffset + 2 * stride,\n\t\toffset + 4 * stride + pair,\n\t\toffset + 7 * stride,\n\t);\n}\n\nfunction permuteBlock(words: Uint32Array): void {\n\tfor (let offset = 0; offset < 256; offset += 32) argonRound(words, offset, 4, 2);\n\tfor (let offset = 0; offset < 32; offset += 4) argonRound(words, offset, 32, 2);\n}\n\nfunction fillBlock(\n\tmemory: Uint32Array,\n\tpreviousOffset: number,\n\treferenceOffset: number,\n\tdestinationOffset: number,\n\twithXor: boolean,\n\toriginal: Uint32Array,\n\tpermuted: Uint32Array,\n): void {\n\tfor (let index = 0; index < 256; index += 1) {\n\t\tconst value = (memory[previousOffset + index] ?? 0) ^ (memory[referenceOffset + index] ?? 0);\n\t\toriginal[index] = value;\n\t\tpermuted[index] = value;\n\t}\n\tpermuteBlock(permuted);\n\tif (withXor) {\n\t\tfor (let index = 0; index < 256; index += 1) {\n\t\t\tmemory[destinationOffset + index] =\n\t\t\t\t(original[index] ?? 0) ^ (permuted[index] ?? 0) ^ (memory[destinationOffset + index] ?? 0);\n\t\t}\n\t} else {\n\t\tfor (let index = 0; index < 256; index += 1) {\n\t\t\tmemory[destinationOffset + index] = (original[index] ?? 0) ^ (permuted[index] ?? 0);\n\t\t}\n\t}\n}\n\nfunction indexAlpha(\n\tpass: number,\n\tslice: number,\n\tindex: number,\n\tsameLane: boolean,\n\tsegmentLength: number,\n\tlaneLength: number,\n\tpseudoRandom: number,\n): number {\n\tlet areaSize: number;\n\tif (pass === 0) {\n\t\tareaSize =\n\t\t\tslice === 0\n\t\t\t\t? index - 1\n\t\t\t\t: slice * segmentLength + (sameLane ? index - 1 : index === 0 ? -1 : 0);\n\t} else {\n\t\tareaSize = laneLength - segmentLength + (sameLane ? index - 1 : index === 0 ? -1 : 0);\n\t}\n\tconst squareHigh = multiplyHigh(\n\t\tpseudoRandom,\n\t\tpseudoRandom,\n\t\tMath.imul(pseudoRandom, pseudoRandom),\n\t);\n\tconst relative =\n\t\tareaSize - 1 - multiplyHigh(areaSize, squareHigh, Math.imul(areaSize, squareHigh));\n\tconst start = pass === 0 ? 0 : slice === 3 ? 0 : (slice + 1) * segmentLength;\n\treturn (start + relative) % laneLength;\n}\n\nfunction dataIndependent(type: number, pass: number, slice: number): boolean {\n\treturn type === 1 || (type === 2 && pass === 0 && slice < 2);\n}\n\nfunction compressBlocks(\n\tprevious: Uint32Array,\n\treference: Uint32Array,\n\toutput: Uint32Array,\n\toriginal: Uint32Array,\n\tpermuted: Uint32Array,\n): void {\n\tfor (let index = 0; index < 256; index += 1) {\n\t\tconst value = (previous[index] ?? 0) ^ (reference[index] ?? 0);\n\t\toriginal[index] = value;\n\t\tpermuted[index] = value;\n\t}\n\tpermuteBlock(permuted);\n\tfor (let index = 0; index < 256; index += 1) {\n\t\toutput[index] = (original[index] ?? 0) ^ (permuted[index] ?? 0);\n\t}\n}\n\nfunction generateAddressBlock(\n\tinputBlock: Uint32Array,\n\taddressBlock: Uint32Array,\n\tzero: Uint32Array,\n\toriginal: Uint32Array,\n\tpermuted: Uint32Array,\n\taddressTemporary: Uint32Array,\n): void {\n\tinputBlock[12] = ((inputBlock[12] ?? 0) + 1) >>> 0;\n\tcompressBlocks(zero, inputBlock, addressTemporary, original, permuted);\n\tcompressBlocks(zero, addressTemporary, addressBlock, original, permuted);\n}\n\nfunction toWords(bytes: Uint8Array): Uint32Array {\n\tconst words = new Uint32Array(256);\n\tfor (let index = 0; index < 256; index += 1) words[index] = read32(bytes, index * 4);\n\treturn words;\n}\n\ninterface Workspace {\n\treadonly memory: Uint32Array;\n\treadonly memoryBlocks: number;\n\treadonly laneLength: number;\n\treadonly segmentLength: number;\n\treadonly original: Uint32Array;\n\treadonly permuted: Uint32Array;\n\treadonly zero: Uint32Array;\n\treadonly addressTemporary: Uint32Array;\n}\n\nfunction fillIndexedBlock(\n\tinput: Argon2Input,\n\tworkspace: Workspace,\n\tposition: { pass: number; slice: number; lane: number },\n\tindex: number,\n\taddressBlock: Uint32Array | undefined,\n): void {\n\tconst { pass, slice, lane } = position;\n\tconst { memory, laneLength, segmentLength, original, permuted } = workspace;\n\tconst currentBlock = lane * laneLength + slice * segmentLength + index;\n\tconst previousBlock =\n\t\tcurrentBlock % laneLength === 0 ? currentBlock + laneLength - 1 : currentBlock - 1;\n\tconst previousOffset = previousBlock * 256;\n\tconst pseudoOffset = addressBlock === undefined ? previousOffset : (index % 128) * 2;\n\tconst pseudo = addressBlock ?? memory;\n\tconst pseudoLow = pseudo[pseudoOffset] ?? 0;\n\tconst pseudoHigh = pseudo[pseudoOffset + 1] ?? 0;\n\tlet referenceLane = pseudoHigh % input.parallelism;\n\tif (pass === 0 && slice === 0) referenceLane = lane;\n\tconst referenceIndex = indexAlpha(\n\t\tpass,\n\t\tslice,\n\t\tindex,\n\t\treferenceLane === lane,\n\t\tsegmentLength,\n\t\tlaneLength,\n\t\tpseudoLow,\n\t);\n\tconst destinationBlock = currentBlock * 256;\n\tfillBlock(\n\t\tmemory,\n\t\tpreviousOffset,\n\t\t(referenceLane * laneLength + referenceIndex) * 256,\n\t\tdestinationBlock,\n\t\tinput.version !== 0x10 && pass !== 0,\n\t\toriginal,\n\t\tpermuted,\n\t);\n}\n\nasync function fillSegment(\n\tinput: Argon2Input,\n\ttype: number,\n\tworkspace: Workspace,\n\tposition: { pass: number; slice: number; lane: number },\n): Promise<void> {\n\tconst { pass, slice, lane } = position;\n\tconst { memoryBlocks, segmentLength, original, permuted, zero, addressTemporary } = workspace;\n\tconst independent = dataIndependent(type, pass, slice);\n\tconst inputBlock = new Uint32Array(256);\n\tconst addressBlock = new Uint32Array(256);\n\ttry {\n\t\tif (independent) {\n\t\t\tinputBlock[0] = pass;\n\t\t\tinputBlock[2] = lane;\n\t\t\tinputBlock[4] = slice;\n\t\t\tinputBlock[6] = memoryBlocks;\n\t\t\tinputBlock[8] = input.passes;\n\t\t\tinputBlock[10] = type;\n\t\t}\n\t\tconst startingIndex = pass === 0 && slice === 0 ? 2 : 0;\n\t\tif (independent && startingIndex !== 0) {\n\t\t\tgenerateAddressBlock(inputBlock, addressBlock, zero, original, permuted, addressTemporary);\n\t\t}\n\t\tfor (let start = startingIndex; start < segmentLength; start += 512) {\n\t\t\t// Start the timer before computing so its delay overlaps useful work.\n\t\t\t// Awaiting it still yields to the event loop after at most 512 blocks.\n\t\t\tconst pause = new Promise<void>((resolve) => setTimeout(resolve, 0));\n\t\t\tconst end = Math.min(start + 512, segmentLength);\n\t\t\tfor (let index = start; index < end; index += 1) {\n\t\t\t\tif (independent && index % 128 === 0) {\n\t\t\t\t\tgenerateAddressBlock(\n\t\t\t\t\t\tinputBlock,\n\t\t\t\t\t\taddressBlock,\n\t\t\t\t\t\tzero,\n\t\t\t\t\t\toriginal,\n\t\t\t\t\t\tpermuted,\n\t\t\t\t\t\taddressTemporary,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tfillIndexedBlock(input, workspace, position, index, independent ? addressBlock : undefined);\n\t\t\t}\n\t\t\tawait pause;\n\t\t}\n\t} finally {\n\t\tinputBlock.fill(0);\n\t\taddressBlock.fill(0);\n\t\taddressTemporary.fill(0);\n\t}\n}\n\nexport async function deriveArgon2TypeScript(input: Argon2Input): Promise<Uint8Array> {\n\tconst type = { argon2d: 0, argon2i: 1, argon2id: 2 }[input.algorithm];\n\tconst memoryBlocks =\n\t\tMath.floor(input.memoryKiB / (4 * input.parallelism)) * 4 * input.parallelism;\n\tconst laneLength = memoryBlocks / input.parallelism;\n\tconst segmentLength = laneLength / 4;\n\tlet memory = new Uint32Array(0);\n\tlet h0: Uint8Array<ArrayBufferLike> = new Uint8Array(0);\n\tlet original = new Uint32Array(0);\n\tlet permuted = new Uint32Array(0);\n\tlet zero = new Uint32Array(0);\n\tlet addressTemporary = new Uint32Array(0);\n\tlet finalBlock: Uint8Array<ArrayBufferLike> = new Uint8Array(0);\n\tlet finalWords: Uint32Array<ArrayBufferLike> = new Uint32Array(0);\n\ttry {\n\t\tmemory = matrices.take(memoryBlocks * 256);\n\t\th0 = initialHash(input, type);\n\t\toriginal = new Uint32Array(256);\n\t\tpermuted = new Uint32Array(256);\n\t\tzero = new Uint32Array(256);\n\t\taddressTemporary = new Uint32Array(256);\n\t\tfor (let lane = 0; lane < input.parallelism; lane += 1) {\n\t\t\tfor (let block = 0; block < 2; block += 1) {\n\t\t\t\tconst suffix = new Uint8Array(8);\n\t\t\t\twrite32(suffix, 0, block);\n\t\t\t\twrite32(suffix, 4, lane);\n\t\t\t\tconst seed = concat(h0, suffix);\n\t\t\t\tlet bytes: Uint8Array<ArrayBufferLike> = new Uint8Array(0);\n\t\t\t\tlet words: Uint32Array<ArrayBufferLike> = new Uint32Array(0);\n\t\t\t\ttry {\n\t\t\t\t\tbytes = blakeLong(seed, 1024);\n\t\t\t\t\twords = toWords(bytes);\n\t\t\t\t\tmemory.set(words, (lane * laneLength + block) * 256);\n\t\t\t\t} finally {\n\t\t\t\t\tseed.fill(0);\n\t\t\t\t\tbytes.fill(0);\n\t\t\t\t\twords.fill(0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst workspace: Workspace = {\n\t\t\tmemory,\n\t\t\tmemoryBlocks,\n\t\t\tlaneLength,\n\t\t\tsegmentLength,\n\t\t\toriginal,\n\t\t\tpermuted,\n\t\t\tzero,\n\t\t\taddressTemporary,\n\t\t};\n\t\tfor (let pass = 0; pass < input.passes; pass += 1) {\n\t\t\tfor (let slice = 0; slice < 4; slice += 1) {\n\t\t\t\tfor (let lane = 0; lane < input.parallelism; lane += 1) {\n\t\t\t\t\tawait fillSegment(input, type, workspace, { pass, slice, lane });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinalBlock = new Uint8Array(1024);\n\t\tfinalWords = toWords(finalBlock);\n\t\tfor (let lane = 0; lane < input.parallelism; lane += 1) {\n\t\t\tconst lastOffset = (lane * laneLength + laneLength - 1) * 256;\n\t\t\tfor (let index = 0; index < 256; index += 1) {\n\t\t\t\tfinalWords[index] = (finalWords[index] ?? 0) ^ (memory[lastOffset + index] ?? 0);\n\t\t\t}\n\t\t}\n\t\tfor (let index = 0; index < 256; index += 1)\n\t\t\twrite32(finalBlock, index * 4, finalWords[index] ?? 0);\n\t\treturn blakeLong(finalBlock, input.outputBytes);\n\t} finally {\n\t\th0.fill(0);\n\t\toriginal.fill(0);\n\t\tpermuted.fill(0);\n\t\tzero.fill(0);\n\t\taddressTemporary.fill(0);\n\t\tfinalBlock.fill(0);\n\t\tfinalWords.fill(0);\n\t\tmatrices.release(memory);\n\t}\n}\n"],"mappings":";;;AASA,MAAMA,IAAWC,EAAiB,GAE5BC,IAAU,uBACVC,IAAK;CACV;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,GACMC,IAAQ;CACb;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAI;EAAI;EAAI;EAAI;EAAI;CAAE;CACrD;EAAC;EAAI;EAAI;EAAG;EAAG;EAAG;EAAI;EAAI;EAAG;EAAG;EAAI;EAAG;EAAG;EAAI;EAAG;EAAG;CAAC;CACrD;EAAC;EAAI;EAAG;EAAI;EAAG;EAAG;EAAG;EAAI;EAAI;EAAI;EAAI;EAAG;EAAG;EAAG;EAAG;EAAG;CAAC;CACrD;EAAC;EAAG;EAAG;EAAG;EAAG;EAAI;EAAI;EAAI;EAAI;EAAG;EAAG;EAAG;EAAI;EAAG;EAAG;EAAI;CAAC;CACrD;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAI;EAAI;EAAI;EAAG;EAAI;EAAI;EAAG;EAAG;EAAG;CAAE;CACrD;EAAC;EAAG;EAAI;EAAG;EAAI;EAAG;EAAI;EAAG;EAAG;EAAG;EAAI;EAAG;EAAG;EAAI;EAAI;EAAG;CAAC;CACrD;EAAC;EAAI;EAAG;EAAG;EAAI;EAAI;EAAI;EAAG;EAAI;EAAG;EAAG;EAA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,GAC/C,KAAK,IAAIoC,IAAQ,GAAGA,IAAQ,GAAG,KAAS,GACvC,KAAK,IAAIgB,IAAO,GAAGA,IAAOpD,EAAM,aAAa,KAAQ,GACpD,MAAM,YAAYA,GAAOS,GAAMyC,GAAW;GAAE;GAAM;GAAO;EAAK,CAAC;EAKlE,AADA,oBAAa,IAAI,WAAW,IAAI,GAChC,IAAa,QAAQpD,CAAU;EAC/B,KAAK,IAAIsD,IAAO,GAAGA,IAAOpD,EAAM,aAAa,KAAQ,GAAG;GACvD,IAAMqE,KAAcjB,IAAOb,IAAaA,IAAa,KAAK;GAC1D,KAAK,IAAI7D,IAAQ,GAAGA,IAAQ,KAAK,KAAS,GACzC,EAAWA,MAAUyF,EAAWzF,MAAU,MAAMiD,EAAO0C,IAAa3F,MAAU;EAEhF;EACA,KAAK,IAAIA,IAAQ,GAAGA,IAAQ,KAAK,KAAS,GACzC,QAAQoB,GAAYpB,IAAQ,GAAGyF,EAAWzF,MAAU,CAAC;EACtD,OAAO,UAAUoB,GAAYE,EAAM,WAAW;CAC/C,UAAU;EAQT,AAPAkE,EAAG,KAAK,CAAC,GACTjC,EAAS,KAAK,CAAC,GACfH,EAAS,KAAK,CAAC,GACfgB,EAAK,KAAK,CAAC,GACXC,EAAiB,KAAK,CAAC,GACvBjD,EAAW,KAAK,CAAC,GACjBqE,EAAW,KAAK,CAAC,GACjBlG,EAAS,QAAQ0D,CAAM;CACxB;AACD"}
@@ -0,0 +1,20 @@
1
+ // src/kdf/argon2-memory.ts
2
+ /** Reuse wiped matrices without preventing garbage collection of idle storage. */
3
+ function createMatrixPool() {
4
+ let e = [];
5
+ return {
6
+ take(t) {
7
+ for (let n = e.length - 1; n >= 0; --n) {
8
+ let r = e[n]?.deref();
9
+ if ((r === void 0 || r.length === t) && (e.splice(n, 1), r !== void 0)) return r;
10
+ }
11
+ return new Uint32Array(t);
12
+ },
13
+ release(t) {
14
+ t.fill(0), t.length !== 0 && (e.length === 4 && e.shift(), e.push(new WeakRef(t)));
15
+ }
16
+ };
17
+ }
18
+ export { createMatrixPool };
19
+
20
+ //# sourceMappingURL=argon2-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argon2-memory.js","names":["idle","index","matrix","words"],"sources":["../../src/kdf/argon2-memory.ts"],"sourcesContent":["interface MatrixPool {\n\treadonly take: (words: number) => Uint32Array<ArrayBuffer>;\n\treadonly release: (matrix: Uint32Array<ArrayBuffer>) => void;\n}\n\n/** Reuse wiped matrices without preventing garbage collection of idle storage. */\nexport function createMatrixPool(): MatrixPool {\n\tconst idle: WeakRef<Uint32Array<ArrayBuffer>>[] = [];\n\treturn {\n\t\ttake(words) {\n\t\t\tfor (let index = idle.length - 1; index >= 0; index -= 1) {\n\t\t\t\tconst matrix = idle[index]?.deref();\n\t\t\t\tif (matrix === undefined || matrix.length === words) {\n\t\t\t\t\tidle.splice(index, 1);\n\t\t\t\t\tif (matrix !== undefined) return matrix;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new Uint32Array(words);\n\t\t},\n\t\trelease(matrix) {\n\t\t\tmatrix.fill(0);\n\t\t\tif (matrix.length === 0) return;\n\t\t\tif (idle.length === 4) idle.shift();\n\t\t\tidle.push(new WeakRef(matrix));\n\t\t},\n\t};\n}\n"],"mappings":";;AAMA,SAAgB,mBAA+B;CAC9C,IAAMA,IAA4C,CAAC;CACnD,OAAO;EACN,KAAK,GAAO;GACX,KAAK,IAAIC,IAAQD,EAAK,SAAS,GAAGC,KAAS,GAAG,KAAY;IACzD,IAAMC,IAASF,EAAKC,EAAM,EAAE,MAAM;IAClC,KAAIC,MAAW,KAAA,KAAaA,EAAO,WAAWC,OAC7CH,EAAK,OAAOC,GAAO,CAAC,GAChBC,MAAW,KAAA,IAAW,OAAOA;GAEnC;GACA,OAAO,IAAI,YAAYC,CAAK;EAC7B;EACA,QAAQ,GAAQ;GAEf,AADAD,EAAO,KAAK,CAAC,GACTA,EAAO,WAAW,MAClBF,EAAK,WAAW,KAAGA,EAAK,MAAM,GAClCA,EAAK,KAAK,IAAI,QAAQE,CAAM,CAAC;EAC9B;CACD;AACD"}
@@ -0,0 +1,18 @@
1
+ import { deriveArgon2TypeScript as e } from "./argon2-core.js";
2
+ // src/kdf/argon2-portable.ts
3
+ /** Internal TypeScript backend; the public boundary validates inputs and limits. */
4
+ async function portableArgon2(t) {
5
+ return t.memoryKiB * 1024 + t.outputBytes + t.password.byteLength + t.salt.byteLength + (t.secret?.byteLength ?? 0) + (t.associatedData?.byteLength ?? 0) >= 2147483648 ? {
6
+ ok: !1,
7
+ error: {
8
+ code: "unsupported",
9
+ message: "Request exceeds portable Argon2 address space"
10
+ }
11
+ } : {
12
+ ok: !0,
13
+ value: await e(t)
14
+ };
15
+ }
16
+ export { portableArgon2 };
17
+
18
+ //# sourceMappingURL=argon2-portable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argon2-portable.js","names":["input","deriveArgon2TypeScript"],"sources":["../../src/kdf/argon2-portable.ts"],"sourcesContent":["import type { Argon2Input, Argon2Result } from '#micro509/kdf/argon2';\nimport { deriveArgon2TypeScript } from '#micro509/kdf/argon2-core';\n\n/** Internal TypeScript backend; the public boundary validates inputs and limits. */\nexport async function portableArgon2(input: Argon2Input): Promise<Argon2Result> {\n\tconst bytes =\n\t\tinput.memoryKiB * 1024 +\n\t\tinput.outputBytes +\n\t\tinput.password.byteLength +\n\t\tinput.salt.byteLength +\n\t\t(input.secret?.byteLength ?? 0) +\n\t\t(input.associatedData?.byteLength ?? 0);\n\tif (bytes >= 0x80000000) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: { code: 'unsupported', message: 'Request exceeds portable Argon2 address space' },\n\t\t};\n\t}\n\treturn { ok: true, value: await deriveArgon2TypeScript(input) };\n}\n"],"mappings":";;;AAIA,eAAsB,eAAe,GAA2C;CAc/E,OAZCA,EAAM,YAAY,OAClBA,EAAM,cACNA,EAAM,SAAS,aACfA,EAAM,KAAK,cACVA,EAAM,QAAQ,cAAc,MAC5BA,EAAM,gBAAgB,cAAc,MACzB,aACL;EACN,IAAI;EACJ,OAAO;GAAE,MAAM;GAAe,SAAS;EAAgD;CACxF,IAEM;EAAE,IAAI;EAAM,OAAO,MAAMC,EAAuBD,CAAK;CAAE;AAC/D"}
@@ -1,6 +1,12 @@
1
+ /**
2
+ * Argon2 derivation and resource-policy boundary. The default backend prefers
3
+ * native WebCrypto and uses the TypeScript implementation when unsupported.
4
+ *
5
+ * @module
6
+ */
1
7
  import { Micro509Error, Result } from "../result/result.js";
2
- /** Argon2id for new uses, or Argon2d for compatibility with existing formats. */
3
- export type Argon2Algorithm = "argon2id" | "argon2d";
8
+ /** RFC 9106 Argon2 variants. Use Argon2id for new password-based applications. */
9
+ export type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
4
10
  /** Argon2 versions used by KDBX. The native backend supports only 0x13. */
5
11
  export type Argon2Version = 0x10 | 0x13;
6
12
  /** Exact derivation inputs. Password encoding and format preprocessing belong to the caller. */
@@ -11,7 +17,7 @@ export interface Argon2Input {
11
17
  readonly version: Argon2Version;
12
18
  /** Password or format-preprocessed input bytes. */
13
19
  readonly password: Uint8Array;
14
- /** Salt bytes. The native backend requires at least eight bytes. */
20
+ /** Salt bytes. RFC 9106 recommends 16 bytes; the native backend requires at least eight. */
15
21
  readonly salt: Uint8Array;
16
22
  /** Total memory in kibibytes, at least eight times parallelism. */
17
23
  readonly memoryKiB: number;
@@ -57,22 +63,27 @@ export type Argon2Backend = (input: Argon2Input) => Promise<Argon2Result>;
57
63
  export interface Argon2Options {
58
64
  /** Per-call ceilings. Applications must separately bound concurrent calls. */
59
65
  readonly limits?: Argon2Limits;
60
- /** Explicit trusted backend. Omit to use native WebCrypto version 0x13. */
61
- readonly backend?: Argon2Backend;
66
+ /**
67
+ * Omit to prefer native WebCrypto, then the TypeScript implementation on `unsupported` only.
68
+ * Select `native` or `portable` to require that implementation, or supply a
69
+ * trusted callback. Explicit selections never fall back to another backend.
70
+ */
71
+ readonly backend?: Argon2Backend | "native" | "portable";
62
72
  }
63
73
  /**
64
74
  * Derives raw Argon2 bytes after validating parameters and resource ceilings.
65
75
  *
66
- * The default native WebCrypto adapter implements version 0x13. Runtime support
67
- * is detected by the import/derive operations, without an extra trial derivation.
68
- * Supply an explicit backend for other environments or version 0x10. There is
69
- * no fallback between variants, versions, or implementations.
76
+ * Native WebCrypto is preferred for version 0x13. An unsupported request uses
77
+ * the TypeScript implementation for the exact variant and version, including
78
+ * 0x10. Other native failures are returned without retrying. Explicit
79
+ * backends never fall back. No algorithm, version, or parameter is substituted.
70
80
  *
71
81
  * Caller buffers are copied synchronously before the first await and never
72
82
  * modified. Owned temporary arrays are zeroed on completion. Native key storage
73
83
  * and runtime copies cannot be explicitly erased by JavaScript. The returned
74
84
  * output is caller-owned. Calls cannot cancel native work once dispatched.
85
+ * TypeScript work yields while filling memory blocks. Its private memory matrix
86
+ * is erased on completion or failure.
75
87
  * Limits apply per call, not to concurrent invocations.
76
88
  */
77
- export declare function deriveArgon2(input: Argon2Input, options?: Argon2Options): Promise<Argon2Result>;
78
- //# sourceMappingURL=argon2.d.ts.map
89
+ export declare function deriveArgon2(input: Argon2Input, options?: Argon2Options): Promise<Argon2Result>;