@amritk/nish-aarch64-linux 0.35.0 → 0.37.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.
- package/INSTALL.md +73 -59
- package/bin/nish +0 -0
- package/docs/AI.md +50 -4
- package/package.json +1 -1
- package/runtime/async.d.mts +2 -0
- package/runtime/async.mjs +7 -0
- package/runtime/nish.d.ts +4849 -430
- package/runtime/nish.h +25 -0
- package/runtime/page.d.ts +53 -0
- package/runtime/page.mjs +146 -0
- package/runtime/runtime-async.c +557 -0
- package/runtime/runtime-wasm.c +63 -7
- package/runtime/vite.d.ts +30 -0
- package/runtime/vite.mjs +150 -0
- package/scripts/build.sh +252 -15
- package/std/README.md +107 -82
- package/std/base64.ts +34 -5
- package/std/bytes.ts +279 -59
- package/std/cli-args.ts +296 -70
- package/std/cli-flags.ts +184 -19
- package/std/cli.ts +475 -54
- package/std/collections.ts +121 -23
- package/std/compress/checksum.ts +44 -14
- package/std/compress/deflate.ts +224 -111
- package/std/compress/gzip.ts +217 -53
- package/std/compress/zlib.ts +63 -7
- package/std/crypto/aes.ts +128 -52
- package/std/crypto/base64url.ts +29 -5
- package/std/crypto/bcrypt-batch.ts +101 -34
- package/std/crypto/bcrypt.ts +93 -27
- package/std/crypto/chacha20poly1305.ts +69 -14
- package/std/crypto/ct.ts +32 -13
- package/std/crypto/ed25519.ts +66 -16
- package/std/crypto/hkdf.ts +198 -13
- package/std/crypto/hmac.ts +242 -37
- package/std/crypto/jwt.ts +204 -72
- package/std/crypto/p256.ts +222 -72
- package/std/crypto/p384.ts +51 -23
- package/std/crypto/pki-roots.ts +32 -2
- package/std/crypto/pki.ts +99 -30
- package/std/crypto/rsa.ts +56 -22
- package/std/crypto/sha1.ts +3 -0
- package/std/crypto/sha256.ts +24 -1
- package/std/crypto/sha512.ts +99 -14
- package/std/crypto/x25519.ts +163 -24
- package/std/crypto/x509-random.ts +10 -0
- package/std/crypto/x509.ts +133 -66
- package/std/host/ring.ts +124 -0
- package/std/json-equal.ts +31 -11
- package/std/json-format.ts +112 -13
- package/std/json-number.ts +76 -26
- package/std/json-pointer.ts +23 -1
- package/std/json-tokenizer.ts +126 -51
- package/std/json-typed.ts +757 -96
- package/std/json-value.ts +438 -157
- package/std/json.ts +170 -38
- package/std/map.ts +25 -7
- package/std/math.ts +36 -4
- package/std/net/buffer-pool.ts +42 -11
- package/std/net/dns-config.ts +109 -23
- package/std/net/dns-message.ts +62 -7
- package/std/net/dns-resolver.ts +247 -53
- package/std/net/dns.ts +203 -35
- package/std/net/fetch.ts +1267 -290
- package/std/net/handler.ts +296 -80
- package/std/net/hpack.ts +290 -77
- package/std/net/http-compress.ts +152 -36
- package/std/net/http-fields.ts +85 -9
- package/std/net/http1-client-codec.ts +129 -44
- package/std/net/http1-codec.ts +279 -114
- package/std/net/http1-server.ts +409 -139
- package/std/net/http2-frame.ts +289 -51
- package/std/net/http2-tls.ts +152 -49
- package/std/net/http2.ts +314 -160
- package/std/net/http3-frame.ts +165 -27
- package/std/net/http3-server.ts +282 -131
- package/std/net/http3.ts +377 -173
- package/std/net/outbound.ts +37 -3
- package/std/net/postgres-carrier.ts +144 -8
- package/std/net/postgres.ts +898 -260
- package/std/net/prefork.ts +202 -65
- package/std/net/qpack.ts +120 -32
- package/std/net/quic-conn-ack.ts +60 -12
- package/std/net/quic-conn-cid.ts +135 -27
- package/std/net/quic-conn-params.ts +109 -22
- package/std/net/quic-datagram.ts +50 -3
- package/std/net/quic-frame.ts +333 -23
- package/std/net/quic-listener.ts +161 -75
- package/std/net/quic-packet.ts +373 -73
- package/std/net/quic-recovery.ts +287 -65
- package/std/net/quic-stream.ts +436 -146
- package/std/net/quic.ts +693 -323
- package/std/net/router.ts +87 -40
- package/std/net/tls/client.ts +167 -51
- package/std/net/tls/codec.ts +494 -68
- package/std/net/tls/record-client.ts +140 -73
- package/std/net/tls/record-server.ts +233 -105
- package/std/net/tls/record.ts +142 -36
- package/std/net/tls/schedule.ts +235 -26
- package/std/net/tls/ticket.ts +161 -40
- package/std/net/tls/verify.ts +57 -10
- package/std/net/tls-tcp.ts +308 -95
- package/std/net/tls.ts +276 -102
- package/std/net/upstream.ts +81 -45
- package/std/net/url.ts +109 -22
- package/std/net/websocket.ts +140 -26
- package/std/net/webtransport.ts +243 -106
- package/std/pair.ts +10 -2
- package/std/random.ts +42 -15
- package/std/regex.ts +422 -257
- package/std/region.ts +70 -15
- package/std/secret.ts +52 -11
- package/std/sort.ts +17 -2
- package/std/sqlite.ts +256 -35
- package/std/sync/ring.ts +229 -56
- package/std/sync/shm.ts +203 -23
- package/std/term-io.ts +154 -78
- package/std/term-pixels.ts +144 -19
- package/std/term-probe.ts +77 -35
- package/std/term-rate.ts +199 -118
- package/std/term.ts +400 -175
- package/std/testing.ts +130 -32
- package/std/text.ts +84 -17
- package/std/threads.ts +248 -56
- package/std/yaml-json.ts +111 -97
- package/std/yaml-lines.ts +47 -15
- package/std/yaml-write.ts +45 -30
- package/std/yaml.ts +764 -384
package/std/crypto/hkdf.ts
CHANGED
|
@@ -136,10 +136,24 @@ const hkdfAppend = (out: u8[], at: i32, block: u8[]): i32 => {
|
|
|
136
136
|
return at + k
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* HKDF-Extract with HMAC-SHA-256 (RFC 5869 §2.2): the 32-byte PRK.
|
|
141
|
+
*
|
|
142
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
143
|
+
* (§2.2).
|
|
144
|
+
* @param ikm The input keying material; it is read, not kept.
|
|
145
|
+
* @returns A fresh 32-byte PRK, which the caller owns and wipes.
|
|
146
|
+
*/
|
|
140
147
|
export const hkdfExtractSha256 = (salt: u8[], ikm: u8[]): u8[] => hmacSha256(hkdfSalt(salt, SHA256_SIZE), ikm)
|
|
141
148
|
|
|
142
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* HKDF-Extract with HMAC-SHA-384 (RFC 5869 §2.2): the 48-byte PRK.
|
|
151
|
+
*
|
|
152
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
153
|
+
* (§2.2).
|
|
154
|
+
* @param ikm The input keying material; it is read, not kept.
|
|
155
|
+
* @returns A fresh 48-byte PRK, which the caller owns and wipes.
|
|
156
|
+
*/
|
|
143
157
|
export const hkdfExtractSha384 = (salt: u8[], ikm: u8[]): u8[] => hmacSha384(hkdfSalt(salt, SHA384_SIZE), ikm)
|
|
144
158
|
|
|
145
159
|
/**
|
|
@@ -147,6 +161,12 @@ export const hkdfExtractSha384 = (salt: u8[], ikm: u8[]): u8[] => hmacSha384(hkd
|
|
|
147
161
|
* keying material from `prk` and `info`, or `null` when `length` is negative
|
|
148
162
|
* or past 255 × 32, when `info` is longer than 2^31 - 1 bytes, or when `prk`
|
|
149
163
|
* is shorter than 32 bytes.
|
|
164
|
+
*
|
|
165
|
+
* @param prk The pseudorandom key, at least 32 bytes; it is read, not kept.
|
|
166
|
+
* @param info The public context the output is bound to; may be empty.
|
|
167
|
+
* @param length How many bytes to derive, 0 to 8160.
|
|
168
|
+
* @returns A fresh array of `length` bytes, which the caller owns and wipes, or
|
|
169
|
+
* `null` for bad input.
|
|
150
170
|
*/
|
|
151
171
|
export const hkdfExpandSha256 = (prk: u8[], info: u8[], length: i32): u8[] | null => {
|
|
152
172
|
if (
|
|
@@ -184,6 +204,12 @@ export const hkdfExpandSha256 = (prk: u8[], info: u8[], length: i32): u8[] | nul
|
|
|
184
204
|
* keying material from `prk` and `info`, or `null` when `length` is negative
|
|
185
205
|
* or past 255 × 48, when `info` is longer than 2^31 - 1 bytes, or when `prk`
|
|
186
206
|
* is shorter than 48 bytes.
|
|
207
|
+
*
|
|
208
|
+
* @param prk The pseudorandom key, at least 48 bytes; it is read, not kept.
|
|
209
|
+
* @param info The public context the output is bound to; may be empty.
|
|
210
|
+
* @param length How many bytes to derive, 0 to 12240.
|
|
211
|
+
* @returns A fresh array of `length` bytes, which the caller owns and wipes, or
|
|
212
|
+
* `null` for bad input.
|
|
187
213
|
*/
|
|
188
214
|
export const hkdfExpandSha384 = (prk: u8[], info: u8[], length: i32): u8[] | null => {
|
|
189
215
|
if (
|
|
@@ -247,21 +273,43 @@ const hkdfExpandSha256Exposed = (prk: u8[], request: HkdfExpandRequest): u8[] |
|
|
|
247
273
|
const hkdfExpandSha384Exposed = (prk: u8[], request: HkdfExpandRequest): u8[] | null =>
|
|
248
274
|
hkdfExpandSha384(prk, request.info, request.length)
|
|
249
275
|
|
|
250
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* `hkdfExtractSha256` on input keying material held as a `Secret`.
|
|
278
|
+
*
|
|
279
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
280
|
+
* (§2.2).
|
|
281
|
+
* @param ikm The input keying material, read only inside `exposeWith`; the
|
|
282
|
+
* caller still owns and wipes it.
|
|
283
|
+
* @returns The 32-byte PRK, held as a `Secret` the caller wipes.
|
|
284
|
+
*/
|
|
251
285
|
export const hkdfExtractSha256Secret = (salt: u8[], ikm: Secret<u8[]>): Secret<u8[]> => {
|
|
252
286
|
const prk: u8[] = exposeWith(ikm, salt, hkdfExtractSha256Exposed)
|
|
253
287
|
return secret(prk)
|
|
254
288
|
}
|
|
255
289
|
|
|
256
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* `hkdfExtractSha384` on input keying material held as a `Secret`.
|
|
292
|
+
*
|
|
293
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
294
|
+
* (§2.2).
|
|
295
|
+
* @param ikm The input keying material, read only inside `exposeWith`; the
|
|
296
|
+
* caller still owns and wipes it.
|
|
297
|
+
* @returns The 48-byte PRK, held as a `Secret` the caller wipes.
|
|
298
|
+
*/
|
|
257
299
|
export const hkdfExtractSha384Secret = (salt: u8[], ikm: Secret<u8[]>): Secret<u8[]> => {
|
|
258
300
|
const prk: u8[] = exposeWith(ikm, salt, hkdfExtractSha384Exposed)
|
|
259
301
|
return secret(prk)
|
|
260
302
|
}
|
|
261
303
|
|
|
262
304
|
/**
|
|
263
|
-
* `hkdfExpandSha256` on a PRK held as a `Secret
|
|
264
|
-
*
|
|
305
|
+
* `hkdfExpandSha256` on a PRK held as a `Secret`.
|
|
306
|
+
*
|
|
307
|
+
* @param prk The pseudorandom key, at least 32 bytes, read only inside
|
|
308
|
+
* `exposeWith`.
|
|
309
|
+
* @param info The public context the output is bound to; may be empty.
|
|
310
|
+
* @param length How many bytes to derive, 0 to 8160.
|
|
311
|
+
* @returns The `length` bytes, held as a `Secret` the caller wipes, or `null`
|
|
312
|
+
* for bad input.
|
|
265
313
|
*/
|
|
266
314
|
export const hkdfExpandSha256Secret = (prk: Secret<u8[]>, info: u8[], length: i32): Secret<u8[]> | null => {
|
|
267
315
|
const request: HkdfExpandRequest = { info: info, length: length }
|
|
@@ -273,8 +321,14 @@ export const hkdfExpandSha256Secret = (prk: Secret<u8[]>, info: u8[], length: i3
|
|
|
273
321
|
}
|
|
274
322
|
|
|
275
323
|
/**
|
|
276
|
-
* `hkdfExpandSha384` on a PRK held as a `Secret
|
|
277
|
-
*
|
|
324
|
+
* `hkdfExpandSha384` on a PRK held as a `Secret`.
|
|
325
|
+
*
|
|
326
|
+
* @param prk The pseudorandom key, at least 48 bytes, read only inside
|
|
327
|
+
* `exposeWith`.
|
|
328
|
+
* @param info The public context the output is bound to; may be empty.
|
|
329
|
+
* @param length How many bytes to derive, 0 to 12240.
|
|
330
|
+
* @returns The `length` bytes, held as a `Secret` the caller wipes, or `null`
|
|
331
|
+
* for bad input.
|
|
278
332
|
*/
|
|
279
333
|
export const hkdfExpandSha384Secret = (prk: Secret<u8[]>, info: u8[], length: i32): Secret<u8[]> | null => {
|
|
280
334
|
const request: HkdfExpandRequest = { info: info, length: length }
|
|
@@ -289,6 +343,15 @@ export const hkdfExpandSha384Secret = (prk: Secret<u8[]>, info: u8[], length: i3
|
|
|
289
343
|
* HKDF with HMAC-SHA-256, both steps (RFC 5869 §2): `length` bytes from `salt`,
|
|
290
344
|
* the `Secret` input keying material and `info`, held as a `Secret`, or `null`
|
|
291
345
|
* where `hkdfExpandSha256` answers `null`. The PRK is wiped before it returns.
|
|
346
|
+
*
|
|
347
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
348
|
+
* (§2.2).
|
|
349
|
+
* @param ikm The input keying material, read only inside `exposeWith`; the
|
|
350
|
+
* caller still owns and wipes it.
|
|
351
|
+
* @param info The public context the output is bound to; may be empty.
|
|
352
|
+
* @param length How many bytes to derive, 0 to 8160.
|
|
353
|
+
* @returns The `length` bytes, held as a `Secret` the caller wipes, or `null`
|
|
354
|
+
* for bad input.
|
|
292
355
|
*/
|
|
293
356
|
export const hkdfSha256Secret = (
|
|
294
357
|
salt: u8[],
|
|
@@ -302,7 +365,19 @@ export const hkdfSha256Secret = (
|
|
|
302
365
|
return okm
|
|
303
366
|
}
|
|
304
367
|
|
|
305
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* `hkdfSha256Secret` with HMAC-SHA-384: the PRK is 48 bytes, and wiped before
|
|
370
|
+
* it returns.
|
|
371
|
+
*
|
|
372
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
373
|
+
* (§2.2).
|
|
374
|
+
* @param ikm The input keying material, read only inside `exposeWith`; the
|
|
375
|
+
* caller still owns and wipes it.
|
|
376
|
+
* @param info The public context the output is bound to; may be empty.
|
|
377
|
+
* @param length How many bytes to derive, 0 to 12240.
|
|
378
|
+
* @returns The `length` bytes, held as a `Secret` the caller wipes, or `null`
|
|
379
|
+
* for bad input.
|
|
380
|
+
*/
|
|
306
381
|
export const hkdfSha384Secret = (
|
|
307
382
|
salt: u8[],
|
|
308
383
|
ikm: Secret<u8[]>,
|
|
@@ -359,6 +434,13 @@ const hkdfLabel = (caller: string, label: string, context: u8[], length: i32): u
|
|
|
359
434
|
* HKDF-Expand-Label with HMAC-SHA-256 (RFC 8446 §7.1): `length` bytes from
|
|
360
435
|
* `prk` (RFC 8446's Secret), `"tls13 " + label` and `context`. Panics on an argument out of the
|
|
361
436
|
* range the module docs give, a secret shorter than 32 bytes among them.
|
|
437
|
+
*
|
|
438
|
+
* @param prk RFC 8446's Secret, at least 32 bytes; it is read, not kept.
|
|
439
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
440
|
+
* @param context The public context, often a transcript hash; at most 255
|
|
441
|
+
* bytes.
|
|
442
|
+
* @param length How many bytes to derive, 0 to 255.
|
|
443
|
+
* @returns A fresh array of `length` bytes, which the caller owns.
|
|
362
444
|
*/
|
|
363
445
|
export const hkdfExpandLabelSha256 = (prk: u8[], label: string, context: u8[], length: i32): u8[] => {
|
|
364
446
|
const okm: u8[] | null = hkdfExpandSha256(
|
|
@@ -376,6 +458,13 @@ export const hkdfExpandLabelSha256 = (prk: u8[], label: string, context: u8[], l
|
|
|
376
458
|
* HKDF-Expand-Label with HMAC-SHA-384 (RFC 8446 §7.1): `length` bytes from
|
|
377
459
|
* `prk` (RFC 8446's Secret), `"tls13 " + label` and `context`. Panics on an argument out of the
|
|
378
460
|
* range the module docs give, a secret shorter than 48 bytes among them.
|
|
461
|
+
*
|
|
462
|
+
* @param prk RFC 8446's Secret, at least 48 bytes; it is read, not kept.
|
|
463
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
464
|
+
* @param context The public context, often a transcript hash; at most 255
|
|
465
|
+
* bytes.
|
|
466
|
+
* @param length How many bytes to derive, 0 to 255.
|
|
467
|
+
* @returns A fresh array of `length` bytes, which the caller owns.
|
|
379
468
|
*/
|
|
380
469
|
export const hkdfExpandLabelSha384 = (prk: u8[], label: string, context: u8[], length: i32): u8[] => {
|
|
381
470
|
const okm: u8[] | null = hkdfExpandSha384(
|
|
@@ -394,6 +483,14 @@ export const hkdfExpandLabelSha384 = (prk: u8[], label: string, context: u8[], l
|
|
|
394
483
|
* held as one. The label is built outside `expose`, since the label and the
|
|
395
484
|
* context are not secret, and the PRK is read only inside it. Panics as
|
|
396
485
|
* `hkdfExpandLabelSha256` does.
|
|
486
|
+
*
|
|
487
|
+
* @param prk RFC 8446's Secret, at least 32 bytes, read only inside
|
|
488
|
+
* `exposeWith`.
|
|
489
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
490
|
+
* @param context The public context, often a transcript hash; at most 255
|
|
491
|
+
* bytes.
|
|
492
|
+
* @param length How many bytes to derive, 0 to 255.
|
|
493
|
+
* @returns The `length` bytes, held as a `Secret` the caller wipes.
|
|
397
494
|
*/
|
|
398
495
|
export const hkdfExpandLabelSha256Secret = (
|
|
399
496
|
prk: Secret<u8[]>,
|
|
@@ -412,7 +509,18 @@ export const hkdfExpandLabelSha256Secret = (
|
|
|
412
509
|
return okm
|
|
413
510
|
}
|
|
414
511
|
|
|
415
|
-
/**
|
|
512
|
+
/**
|
|
513
|
+
* `hkdfExpandLabelSha256Secret` with HMAC-SHA-384: panics as
|
|
514
|
+
* `hkdfExpandLabelSha384` does.
|
|
515
|
+
*
|
|
516
|
+
* @param prk RFC 8446's Secret, at least 48 bytes, read only inside
|
|
517
|
+
* `exposeWith`.
|
|
518
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
519
|
+
* @param context The public context, often a transcript hash; at most 255
|
|
520
|
+
* bytes.
|
|
521
|
+
* @param length How many bytes to derive, 0 to 255.
|
|
522
|
+
* @returns The `length` bytes, held as a `Secret` the caller wipes.
|
|
523
|
+
*/
|
|
416
524
|
export const hkdfExpandLabelSha384Secret = (
|
|
417
525
|
prk: Secret<u8[]>,
|
|
418
526
|
label: string,
|
|
@@ -442,15 +550,35 @@ const HKDF_LABEL_MAX: i32 = 514
|
|
|
442
550
|
* hand it to every derivation; it carries nothing from one call to the next.
|
|
443
551
|
*/
|
|
444
552
|
export class HkdfScratch {
|
|
553
|
+
/**
|
|
554
|
+
* The HMAC the `*Into` functions run when `hashLength` is 32; wiped before
|
|
555
|
+
* a call that ran it returns.
|
|
556
|
+
*/
|
|
445
557
|
sha256: HmacSha256Scratch
|
|
558
|
+
/**
|
|
559
|
+
* The HMAC the `*Into` functions run when `hashLength` is 48; wiped before
|
|
560
|
+
* a call that ran it returns.
|
|
561
|
+
*/
|
|
446
562
|
sha384: HmacSha384Scratch
|
|
447
563
|
/** T(i - 1), HashLen bytes of it; wiped before every function returns. */
|
|
448
564
|
previous: u8[]
|
|
449
|
-
/**
|
|
565
|
+
/**
|
|
566
|
+
* The one-byte block counter `i`.
|
|
567
|
+
*
|
|
568
|
+
* @internal Written by this module's `*Into` functions.
|
|
569
|
+
*/
|
|
450
570
|
counter: u8[]
|
|
451
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* HKDF-Expand-Label's `info`, built here: public, so it is not wiped.
|
|
573
|
+
*
|
|
574
|
+
* @internal Written by this module's `*Into` functions.
|
|
575
|
+
*/
|
|
452
576
|
label: u8[]
|
|
453
577
|
|
|
578
|
+
/**
|
|
579
|
+
* Allocates the HMAC scratch for both hashes and the buffers every derivation
|
|
580
|
+
* reuses.
|
|
581
|
+
*/
|
|
454
582
|
constructor() {
|
|
455
583
|
this.sha256 = new HmacSha256Scratch()
|
|
456
584
|
this.sha384 = new HmacSha384Scratch()
|
|
@@ -524,6 +652,14 @@ const hkdfMacFinish = (s: HkdfScratch, hashLength: i32, out: u8[], at: i32): voi
|
|
|
524
652
|
* which HMAC pads to the block with zeros, exactly as the HashLen zeros §2.2
|
|
525
653
|
* asks for would be. An `ikm` longer than 2^31 - 1 bytes panics, as
|
|
526
654
|
* `hmacSha256` does.
|
|
655
|
+
*
|
|
656
|
+
* @param s The scratch to compute in; what the call leaves in it is wiped.
|
|
657
|
+
* @param hashLength 32 for HMAC-SHA-256, 48 for HMAC-SHA-384.
|
|
658
|
+
* @param salt The public salt; an empty one stands for HashLen zero bytes
|
|
659
|
+
* (§2.2).
|
|
660
|
+
* @param ikm The input keying material; it is read, not kept.
|
|
661
|
+
* @param out The caller's array the PRK is written into.
|
|
662
|
+
* @param at Where the `hashLength` PRK bytes start in `out`.
|
|
527
663
|
*/
|
|
528
664
|
export const hkdfExtractInto = (
|
|
529
665
|
s: HkdfScratch,
|
|
@@ -586,6 +722,18 @@ const hkdfExpandWindow = (
|
|
|
586
722
|
* where `hkdfExpandSha256` answers `null`: a `length` negative or past
|
|
587
723
|
* 255 × HashLen, an `info` longer than 2^31 - 1 bytes, or a `prk` shorter than
|
|
588
724
|
* HashLen.
|
|
725
|
+
*
|
|
726
|
+
* @param s The scratch to compute in; what the call leaves in it is wiped.
|
|
727
|
+
* @param hashLength 32 for HMAC-SHA-256, 48 for HMAC-SHA-384.
|
|
728
|
+
* @param prk The pseudorandom key, at least `hashLength` bytes; it is read, not
|
|
729
|
+
* kept.
|
|
730
|
+
* @param info The public context the output is bound to; may be empty.
|
|
731
|
+
* @param out The caller's array the output is written into.
|
|
732
|
+
* @param at Where the output starts in `out`.
|
|
733
|
+
* @param length How many bytes to derive, 0 to 255 × `hashLength`.
|
|
734
|
+
* @returns `true` once the bytes are written; `false`, with `out` untouched,
|
|
735
|
+
* for bad input. A `hashLength` other than 32 or 48, or an output window
|
|
736
|
+
* outside `out`, panics instead, before anything is written.
|
|
589
737
|
*/
|
|
590
738
|
export const hkdfExpandInto = (
|
|
591
739
|
s: HkdfScratch,
|
|
@@ -617,6 +765,18 @@ export const hkdfExpandInto = (
|
|
|
617
765
|
* panics where `hkdfExpandLabelSha256` does — a length outside 0 to 255, a
|
|
618
766
|
* label empty or past 249 bytes, a context past 255, a secret shorter than
|
|
619
767
|
* HashLen — and on a context window outside its array.
|
|
768
|
+
*
|
|
769
|
+
* @param s The scratch to compute in; what the call leaves in it is wiped.
|
|
770
|
+
* @param hashLength 32 for HMAC-SHA-256, 48 for HMAC-SHA-384.
|
|
771
|
+
* @param prk RFC 8446's Secret, at least `hashLength` bytes; it is read, not
|
|
772
|
+
* kept.
|
|
773
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
774
|
+
* @param context The buffer holding the context.
|
|
775
|
+
* @param contextOff Where the context starts in `context`.
|
|
776
|
+
* @param contextLen The context's length, at most 255 bytes.
|
|
777
|
+
* @param out The caller's array the output is written into.
|
|
778
|
+
* @param at Where the output starts in `out`.
|
|
779
|
+
* @param length How many bytes to derive, 0 to 255.
|
|
620
780
|
*/
|
|
621
781
|
export const hkdfExpandLabelInto = (
|
|
622
782
|
s: HkdfScratch,
|
|
@@ -743,6 +903,13 @@ const hkdfHeld = (
|
|
|
743
903
|
* derived from `prk`, the label and `context` and written over `dst`'s in
|
|
744
904
|
* place. `dst` may be `prk` itself, since the output is whole before it is
|
|
745
905
|
* copied: that is a ratchet. Panics as `hkdfExpandLabelSha256` does.
|
|
906
|
+
*
|
|
907
|
+
* @param dst The `Secret` to overwrite; its length is the length derived. It
|
|
908
|
+
* may be `prk`.
|
|
909
|
+
* @param prk RFC 8446's Secret, read only inside `exposeWith`.
|
|
910
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
911
|
+
* @param context The public context, often a transcript hash; at most 255
|
|
912
|
+
* bytes.
|
|
746
913
|
*/
|
|
747
914
|
export const hkdfExpandLabelSha256Held = (
|
|
748
915
|
dst: Secret<u8[]>,
|
|
@@ -753,7 +920,17 @@ export const hkdfExpandLabelSha256Held = (
|
|
|
753
920
|
hkdfHeld("hkdfExpandLabelSha256Held", SHA256_SIZE, dst, prk, label, context)
|
|
754
921
|
}
|
|
755
922
|
|
|
756
|
-
/**
|
|
923
|
+
/**
|
|
924
|
+
* `hkdfExpandLabelSha256Held` with HMAC-SHA-384: panics as
|
|
925
|
+
* `hkdfExpandLabelSha384` does.
|
|
926
|
+
*
|
|
927
|
+
* @param dst The `Secret` to overwrite; its length is the length derived. It
|
|
928
|
+
* may be `prk`.
|
|
929
|
+
* @param prk RFC 8446's Secret, read only inside `exposeWith`.
|
|
930
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
931
|
+
* @param context The public context, often a transcript hash; at most 255
|
|
932
|
+
* bytes.
|
|
933
|
+
*/
|
|
757
934
|
export const hkdfExpandLabelSha384Held = (
|
|
758
935
|
dst: Secret<u8[]>,
|
|
759
936
|
prk: Secret<u8[]>,
|
|
@@ -768,6 +945,14 @@ export const hkdfExpandLabelSha384Held = (
|
|
|
768
945
|
* plain array: `length` bytes written at `out[at]`. This is for output that is
|
|
769
946
|
* kept plain by design, a record layer's AEAD key and IV, say, which live in
|
|
770
947
|
* the arrays the cipher reads. Panics as `hkdfExpandLabelInto` does.
|
|
948
|
+
*
|
|
949
|
+
* @param hashLength 32 for HMAC-SHA-256, 48 for HMAC-SHA-384.
|
|
950
|
+
* @param prk RFC 8446's Secret, read only inside `exposeWith`.
|
|
951
|
+
* @param label The label without the `"tls13 "` prefix, 1 to 249 bytes.
|
|
952
|
+
* @param context The public context, at most 255 bytes.
|
|
953
|
+
* @param out The caller's plain array the output is written into.
|
|
954
|
+
* @param at Where the output starts in `out`.
|
|
955
|
+
* @param length How many bytes to derive, 0 to 255.
|
|
771
956
|
*/
|
|
772
957
|
export const hkdfExpandLabelHeldInto = (
|
|
773
958
|
hashLength: i32,
|