hpke 1.1.2 → 1.1.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 +1 -1
- package/index.d.ts +10 -2
- package/index.d.ts.map +1 -1
- package/index.js +67 -29
- package/index.ts +74 -36
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ Below are the algorithms built in (based on Web Cryptography) and their runtime
|
|
|
95
95
|
| DHKEM(P-384, HKDF-SHA384) <sub>`0x0011`</sub> | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
96
96
|
| DHKEM(P-521, HKDF-SHA512) <sub>`0x0012`</sub> | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
97
97
|
| DHKEM(X25519, HKDF-SHA256) <sub>`0x0020`</sub> | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
98
|
-
| DHKEM(X448, HKDF-SHA512) <sub>`0x0021`</sub> | ✓ |
|
|
98
|
+
| DHKEM(X448, HKDF-SHA512) <sub>`0x0021`</sub> | ✓ | ✓ | | | | ✓ |
|
|
99
99
|
| ML-KEM-512 <sub>`0x0040`</sub> | ✓ | ✓ | | | | ✓ |
|
|
100
100
|
| ML-KEM-768 <sub>`0x0041`</sub> | ✓ | ✓ | | | | ✓ |
|
|
101
101
|
| ML-KEM-1024 <sub>`0x0042`</sub> | ✓ | ✓ | | | | ✓ |
|
package/index.d.ts
CHANGED
|
@@ -68,7 +68,8 @@ declare class SenderContext {
|
|
|
68
68
|
/**
|
|
69
69
|
* @returns The sequence number for this context's next {@link Seal}, initially zero, increments
|
|
70
70
|
* automatically with each successful {@link Seal}. The sequence number provides AEAD nonce
|
|
71
|
-
* uniqueness. The maximum supported sequence number
|
|
71
|
+
* uniqueness. The maximum supported sequence number is the lower of the AEAD nonce-size limit
|
|
72
|
+
* and `2^53-1`.
|
|
72
73
|
*/
|
|
73
74
|
get seq(): number;
|
|
74
75
|
/**
|
|
@@ -160,7 +161,8 @@ declare class RecipientContext {
|
|
|
160
161
|
/**
|
|
161
162
|
* @returns The sequence number for this context's next {@link Open}, initially zero, increments
|
|
162
163
|
* automatically with each successful {@link Open}. The sequence number provides AEAD nonce
|
|
163
|
-
* uniqueness. The maximum supported sequence number
|
|
164
|
+
* uniqueness. The maximum supported sequence number is the lower of the AEAD nonce-size limit
|
|
165
|
+
* and `2^53-1`.
|
|
164
166
|
*/
|
|
165
167
|
get seq(): number;
|
|
166
168
|
/**
|
|
@@ -1434,12 +1436,18 @@ export interface AEAD {
|
|
|
1434
1436
|
/**
|
|
1435
1437
|
* Encrypts and authenticates plaintext with associated data.
|
|
1436
1438
|
*
|
|
1439
|
+
* Implementations must enforce the AEAD algorithm's per-invocation plaintext length limit (P_MAX)
|
|
1440
|
+
* before encryption. HPKE's explicit error list maps `MessageLimitReachedError` to context
|
|
1441
|
+
* sequence number overflow; it does not prescribe a specific error for P_MAX violations. Report
|
|
1442
|
+
* them as ordinary input range errors, such as `RangeError`.
|
|
1443
|
+
*
|
|
1437
1444
|
* @param key - The encryption key of {@link Nk} bytes
|
|
1438
1445
|
* @param nonce - The nonce of {@link Nn} bytes
|
|
1439
1446
|
* @param aad - Additional authenticated data
|
|
1440
1447
|
* @param pt - Plaintext to encrypt
|
|
1441
1448
|
*
|
|
1442
1449
|
* @returns A promise resolving to the ciphertext with authentication tag appended
|
|
1450
|
+
* @see [Context.Seal P_MAX handling](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-5.2)
|
|
1443
1451
|
*/
|
|
1444
1452
|
Seal(key: Uint8Array, nonce: Uint8Array, aad: Uint8Array, pt: Uint8Array): Promise<Uint8Array>;
|
|
1445
1453
|
/**
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAk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AAM,0BAA0B,EAAE,UAoBxC,CAAA;AAeD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,EAAE,UAoBxC,CAAA;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,4BAA4B,EAAE,UAyB1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,EAAE,UAyBxC,CAAA;AAqGD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,cAAc,EAAE,UAmB5B,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,EAAE,UAmB5B,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,EAAE,UAmB7B,CAAA;AA2ED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAY9B,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAY9B,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAanC,CAAA;AAmXD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAoCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAmC/B,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAoChC,CAAA"}
|
package/index.js
CHANGED
|
@@ -57,12 +57,15 @@ function ComputeNonce(base_nonce , seq , Nn )
|
|
|
57
57
|
return nonce
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
function MaxSeq(Nn ) {
|
|
60
61
|
|
|
61
|
-
function IncrementSeq(seq ) {
|
|
62
62
|
|
|
63
|
+
return Math.min(2 ** (8 * Nn) - 1, Number.MAX_SAFE_INTEGER)
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
function IncrementSeq(seq , maxSeq ) {
|
|
68
|
+
if (seq >= maxSeq) {
|
|
66
69
|
throw new MessageLimitReachedError('Sequence number overflow')
|
|
67
70
|
}
|
|
68
71
|
return ++seq
|
|
@@ -128,6 +131,7 @@ class SenderContext {
|
|
|
128
131
|
#exporter_secret
|
|
129
132
|
#mode
|
|
130
133
|
#seq = 0
|
|
134
|
+
#max_seq
|
|
131
135
|
#mutex
|
|
132
136
|
|
|
133
137
|
constructor(
|
|
@@ -142,6 +146,7 @@ class SenderContext {
|
|
|
142
146
|
this.#key = key
|
|
143
147
|
this.#base_nonce = base_nonce
|
|
144
148
|
this.#exporter_secret = exporter_secret
|
|
149
|
+
this.#max_seq = MaxSeq(suite.AEAD.Nn)
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
|
|
@@ -158,6 +163,7 @@ class SenderContext {
|
|
|
158
163
|
|
|
159
164
|
|
|
160
165
|
|
|
166
|
+
|
|
161
167
|
get seq() {
|
|
162
168
|
return this.#seq
|
|
163
169
|
}
|
|
@@ -206,7 +212,7 @@ class SenderContext {
|
|
|
206
212
|
aad,
|
|
207
213
|
plaintext,
|
|
208
214
|
)
|
|
209
|
-
this.#seq = IncrementSeq(this.#seq)
|
|
215
|
+
this.#seq = IncrementSeq(this.#seq, this.#max_seq)
|
|
210
216
|
return ct
|
|
211
217
|
} finally {
|
|
212
218
|
release()
|
|
@@ -276,6 +282,7 @@ class RecipientContext {
|
|
|
276
282
|
#exporter_secret
|
|
277
283
|
#mode
|
|
278
284
|
#seq = 0
|
|
285
|
+
#max_seq
|
|
279
286
|
#mutex
|
|
280
287
|
|
|
281
288
|
constructor(
|
|
@@ -290,6 +297,7 @@ class RecipientContext {
|
|
|
290
297
|
this.#key = key
|
|
291
298
|
this.#base_nonce = base_nonce
|
|
292
299
|
this.#exporter_secret = exporter_secret
|
|
300
|
+
this.#max_seq = MaxSeq(suite.AEAD.Nn)
|
|
293
301
|
}
|
|
294
302
|
|
|
295
303
|
|
|
@@ -306,6 +314,7 @@ class RecipientContext {
|
|
|
306
314
|
|
|
307
315
|
|
|
308
316
|
|
|
317
|
+
|
|
309
318
|
get seq() {
|
|
310
319
|
return this.#seq
|
|
311
320
|
}
|
|
@@ -364,7 +373,7 @@ class RecipientContext {
|
|
|
364
373
|
|
|
365
374
|
throw new OpenError('AEAD decryption failed', { cause })
|
|
366
375
|
}
|
|
367
|
-
this.#seq = IncrementSeq(this.#seq)
|
|
376
|
+
this.#seq = IncrementSeq(this.#seq, this.#max_seq)
|
|
368
377
|
return pt
|
|
369
378
|
} finally {
|
|
370
379
|
release()
|
|
@@ -2188,6 +2197,12 @@ function isKey(key , type , extractable )
|
|
|
2188
2197
|
|
|
2189
2198
|
|
|
2190
2199
|
|
|
2200
|
+
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
|
|
2191
2206
|
|
|
2192
2207
|
|
|
2193
2208
|
|
|
@@ -2266,6 +2281,8 @@ const NotApplicable = () => {
|
|
|
2266
2281
|
}
|
|
2267
2282
|
|
|
2268
2283
|
const EXPORT_ONLY = 0xffff
|
|
2284
|
+
const AES_GCM_P_MAX = 2 ** 36 - 31
|
|
2285
|
+
const CHACHA20_POLY1305_P_MAX = 2 ** 38 - 64
|
|
2269
2286
|
|
|
2270
2287
|
|
|
2271
2288
|
|
|
@@ -2693,21 +2710,18 @@ function b64u(input ) {
|
|
|
2693
2710
|
|
|
2694
2711
|
|
|
2695
2712
|
|
|
2696
|
-
async function
|
|
2713
|
+
async function DeriveKeyPairBytes(
|
|
2697
2714
|
DHKEM ,
|
|
2698
|
-
suite_id ,
|
|
2699
2715
|
ikm ,
|
|
2700
|
-
|
|
2716
|
+
label ,
|
|
2717
|
+
context ,
|
|
2701
2718
|
) {
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
I2OSP(counter, 1),
|
|
2709
|
-
DHKEM.Nsk,
|
|
2710
|
-
)
|
|
2719
|
+
if (KDFStages(DHKEM.kdf) === 1) {
|
|
2720
|
+
return await LabeledDerive(DHKEM.kdf, DHKEM.suite_id, ikm, label, context, DHKEM.Nsk)
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
const dkp_prk = await LabeledExtract(DHKEM.kdf, DHKEM.suite_id, new Uint8Array(), L_dkp_prk, ikm)
|
|
2724
|
+
return await LabeledExpand(DHKEM.kdf, DHKEM.suite_id, dkp_prk, label, context, DHKEM.Nsk)
|
|
2711
2725
|
}
|
|
2712
2726
|
|
|
2713
2727
|
function OS2IP(x ) {
|
|
@@ -2753,6 +2767,22 @@ function assertCryptoKey(key ) {
|
|
|
2753
2767
|
}
|
|
2754
2768
|
|
|
2755
2769
|
|
|
2770
|
+
async function ExtractAndExpand_OneStage(
|
|
2771
|
+
DHKEM ,
|
|
2772
|
+
dh ,
|
|
2773
|
+
kem_context ,
|
|
2774
|
+
) {
|
|
2775
|
+
return await LabeledDerive(
|
|
2776
|
+
DHKEM.kdf,
|
|
2777
|
+
DHKEM.suite_id,
|
|
2778
|
+
dh,
|
|
2779
|
+
L_shared_secret,
|
|
2780
|
+
kem_context,
|
|
2781
|
+
DHKEM.Nsecret,
|
|
2782
|
+
)
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
|
|
2756
2786
|
async function ExtractAndExpand_TwoStage(
|
|
2757
2787
|
DHKEM ,
|
|
2758
2788
|
dh ,
|
|
@@ -2770,6 +2800,16 @@ async function ExtractAndExpand_TwoStage(
|
|
|
2770
2800
|
}
|
|
2771
2801
|
|
|
2772
2802
|
|
|
2803
|
+
async function ExtractAndExpand(
|
|
2804
|
+
DHKEM ,
|
|
2805
|
+
dh ,
|
|
2806
|
+
kem_context ,
|
|
2807
|
+
) {
|
|
2808
|
+
const Fn = KDFStages(DHKEM.kdf) === 1 ? ExtractAndExpand_OneStage : ExtractAndExpand_TwoStage
|
|
2809
|
+
return await Fn(DHKEM, dh, kem_context)
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
|
|
2773
2813
|
|
|
2774
2814
|
|
|
2775
2815
|
|
|
@@ -2819,7 +2859,7 @@ function DHKEM_SHARED()
|
|
|
2819
2859
|
const enc = await this.SerializePublicKey(pkE)
|
|
2820
2860
|
const pkRm = await this.SerializePublicKey(pkR)
|
|
2821
2861
|
const kem_context = concat(enc, pkRm)
|
|
2822
|
-
const shared_secret = await
|
|
2862
|
+
const shared_secret = await ExtractAndExpand(this, dh, kem_context)
|
|
2823
2863
|
return { shared_secret, enc }
|
|
2824
2864
|
},
|
|
2825
2865
|
async Decap( enc, skR, pkR) {
|
|
@@ -2846,7 +2886,7 @@ function DHKEM_SHARED()
|
|
|
2846
2886
|
|
|
2847
2887
|
const pkRm = await this.SerializePublicKey(pkR)
|
|
2848
2888
|
const kem_context = concat(enc, pkRm)
|
|
2849
|
-
const shared_secret = await
|
|
2889
|
+
const shared_secret = await ExtractAndExpand(this, dh, kem_context)
|
|
2850
2890
|
return shared_secret
|
|
2851
2891
|
},
|
|
2852
2892
|
}
|
|
@@ -3070,7 +3110,7 @@ async function DeriveKeyPairNist(
|
|
|
3070
3110
|
if (counter > 255) {
|
|
3071
3111
|
throw new DeriveKeyPairError('Key derivation exceeded maximum iterations')
|
|
3072
3112
|
}
|
|
3073
|
-
candidate = await
|
|
3113
|
+
candidate = await DeriveKeyPairBytes(this, ikm, L_candidate, I2OSP(counter, 1))
|
|
3074
3114
|
candidate[0] = candidate[0] & this.bitmask
|
|
3075
3115
|
sk = OS2IP(candidate)
|
|
3076
3116
|
counter = counter + 1
|
|
@@ -3107,8 +3147,7 @@ async function GetKeyPairNist(
|
|
|
3107
3147
|
|
|
3108
3148
|
|
|
3109
3149
|
async function DeriveKeyPairX( ikm , extractable ) {
|
|
3110
|
-
const
|
|
3111
|
-
const sk = await LabeledExpand(this.kdf, this.suite_id, dkp_prk, L_sk, new Uint8Array(), this.Nsk)
|
|
3150
|
+
const sk = await DeriveKeyPairBytes(this, ikm, L_sk, new Uint8Array())
|
|
3112
3151
|
return await createKeyPairFromPrivateKey(this, sk, extractable)
|
|
3113
3152
|
}
|
|
3114
3153
|
|
|
@@ -3607,11 +3646,7 @@ export const KEM_ML_KEM_1024 = function () {
|
|
|
3607
3646
|
|
|
3608
3647
|
|
|
3609
3648
|
|
|
3610
|
-
function AEAD_SHARED() {
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3649
|
+
function AEAD_SHARED(P_MAX ) {
|
|
3615
3650
|
|
|
3616
3651
|
|
|
3617
3652
|
|
|
@@ -3630,6 +3665,9 @@ function AEAD_SHARED() {
|
|
|
3630
3665
|
}
|
|
3631
3666
|
return {
|
|
3632
3667
|
async Seal( key, nonce, aad, pt) {
|
|
3668
|
+
if (pt.byteLength > P_MAX) {
|
|
3669
|
+
throw new RangeError('"pt" exceeds P_MAX')
|
|
3670
|
+
}
|
|
3633
3671
|
const cryptoKey =
|
|
3634
3672
|
cache.get(key) ?? (await cacheValue(cache, key, () => importKey.call(this, key)))
|
|
3635
3673
|
return new Uint8Array(
|
|
@@ -3702,7 +3740,7 @@ export const AEAD_AES_128_GCM = function () {
|
|
|
3702
3740
|
Nt: 16,
|
|
3703
3741
|
algorithm: 'AES-GCM',
|
|
3704
3742
|
keyFormat: 'raw',
|
|
3705
|
-
...AEAD_SHARED(),
|
|
3743
|
+
...AEAD_SHARED(AES_GCM_P_MAX),
|
|
3706
3744
|
}
|
|
3707
3745
|
}
|
|
3708
3746
|
|
|
@@ -3734,7 +3772,7 @@ export const AEAD_AES_256_GCM = function () {
|
|
|
3734
3772
|
Nt: 16,
|
|
3735
3773
|
algorithm: 'AES-GCM',
|
|
3736
3774
|
keyFormat: 'raw',
|
|
3737
|
-
...AEAD_SHARED(),
|
|
3775
|
+
...AEAD_SHARED(AES_GCM_P_MAX),
|
|
3738
3776
|
}
|
|
3739
3777
|
}
|
|
3740
3778
|
|
|
@@ -3767,7 +3805,7 @@ export const AEAD_ChaCha20Poly1305 = function AEAD_ChaCha20Poly1305
|
|
|
3767
3805
|
algorithm: 'ChaCha20-Poly1305',
|
|
3768
3806
|
|
|
3769
3807
|
keyFormat: 'raw-secret',
|
|
3770
|
-
...AEAD_SHARED(),
|
|
3808
|
+
...AEAD_SHARED(CHACHA20_POLY1305_P_MAX),
|
|
3771
3809
|
}
|
|
3772
3810
|
}
|
|
3773
3811
|
|
package/index.ts
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
function ComputeNonce(base_nonce: Uint8Array, seq: number, Nn: number): Uint8Array {
|
|
47
47
|
// Equivalent to xor(base_nonce, I2OSP(seq, Nn)) but avoids allocating the
|
|
48
48
|
// intermediate seq_bytes array and fuses the two byte-wise passes into one.
|
|
49
|
-
// seq
|
|
49
|
+
// seq stays exact because IncrementSeq caps it at Number.MAX_SAFE_INTEGER.
|
|
50
50
|
const nonce = new Uint8Array(Nn)
|
|
51
51
|
nonce.set(base_nonce)
|
|
52
52
|
let s = seq
|
|
@@ -57,12 +57,15 @@ function ComputeNonce(base_nonce: Uint8Array, seq: number, Nn: number): Uint8Arr
|
|
|
57
57
|
return nonce
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
function MaxSeq(Nn: number): number {
|
|
61
|
+
// HPKE limits seq to the largest integer encodable in Nn bytes. This
|
|
62
|
+
// implementation stores seq as a JS number, so it uses the stricter limit.
|
|
63
|
+
return Math.min(2 ** (8 * Nn) - 1, Number.MAX_SAFE_INTEGER)
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
/** @see [Context.IncrementSeq](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-5.2) */
|
|
61
|
-
function IncrementSeq(seq: number): number {
|
|
62
|
-
|
|
63
|
-
// 1. Initial value is 0
|
|
64
|
-
// 2. This function throws at MAX_SAFE_INTEGER
|
|
65
|
-
if (seq >= Number.MAX_SAFE_INTEGER) {
|
|
67
|
+
function IncrementSeq(seq: number, maxSeq: number): number {
|
|
68
|
+
if (seq >= maxSeq) {
|
|
66
69
|
throw new MessageLimitReachedError('Sequence number overflow')
|
|
67
70
|
}
|
|
68
71
|
return ++seq
|
|
@@ -128,6 +131,7 @@ class SenderContext {
|
|
|
128
131
|
#exporter_secret: Uint8Array
|
|
129
132
|
#mode: typeof MODE_BASE | typeof MODE_PSK
|
|
130
133
|
#seq: number = 0
|
|
134
|
+
#max_seq: number
|
|
131
135
|
#mutex?: Mutex
|
|
132
136
|
|
|
133
137
|
constructor(
|
|
@@ -142,6 +146,7 @@ class SenderContext {
|
|
|
142
146
|
this.#key = key
|
|
143
147
|
this.#base_nonce = base_nonce
|
|
144
148
|
this.#exporter_secret = exporter_secret
|
|
149
|
+
this.#max_seq = MaxSeq(suite.AEAD.Nn)
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
/**
|
|
@@ -156,7 +161,8 @@ class SenderContext {
|
|
|
156
161
|
/**
|
|
157
162
|
* @returns The sequence number for this context's next {@link Seal}, initially zero, increments
|
|
158
163
|
* automatically with each successful {@link Seal}. The sequence number provides AEAD nonce
|
|
159
|
-
* uniqueness. The maximum supported sequence number
|
|
164
|
+
* uniqueness. The maximum supported sequence number is the lower of the AEAD nonce-size limit
|
|
165
|
+
* and `2^53-1`.
|
|
160
166
|
*/
|
|
161
167
|
get seq(): number {
|
|
162
168
|
return this.#seq
|
|
@@ -206,7 +212,7 @@ class SenderContext {
|
|
|
206
212
|
aad,
|
|
207
213
|
plaintext,
|
|
208
214
|
)
|
|
209
|
-
this.#seq = IncrementSeq(this.#seq)
|
|
215
|
+
this.#seq = IncrementSeq(this.#seq, this.#max_seq)
|
|
210
216
|
return ct
|
|
211
217
|
} finally {
|
|
212
218
|
release()
|
|
@@ -276,6 +282,7 @@ class RecipientContext {
|
|
|
276
282
|
#exporter_secret: Uint8Array
|
|
277
283
|
#mode: typeof MODE_BASE | typeof MODE_PSK
|
|
278
284
|
#seq: number = 0
|
|
285
|
+
#max_seq: number
|
|
279
286
|
#mutex?: Mutex
|
|
280
287
|
|
|
281
288
|
constructor(
|
|
@@ -290,6 +297,7 @@ class RecipientContext {
|
|
|
290
297
|
this.#key = key
|
|
291
298
|
this.#base_nonce = base_nonce
|
|
292
299
|
this.#exporter_secret = exporter_secret
|
|
300
|
+
this.#max_seq = MaxSeq(suite.AEAD.Nn)
|
|
293
301
|
}
|
|
294
302
|
|
|
295
303
|
/**
|
|
@@ -304,7 +312,8 @@ class RecipientContext {
|
|
|
304
312
|
/**
|
|
305
313
|
* @returns The sequence number for this context's next {@link Open}, initially zero, increments
|
|
306
314
|
* automatically with each successful {@link Open}. The sequence number provides AEAD nonce
|
|
307
|
-
* uniqueness. The maximum supported sequence number
|
|
315
|
+
* uniqueness. The maximum supported sequence number is the lower of the AEAD nonce-size limit
|
|
316
|
+
* and `2^53-1`.
|
|
308
317
|
*/
|
|
309
318
|
get seq(): number {
|
|
310
319
|
return this.#seq
|
|
@@ -364,7 +373,7 @@ class RecipientContext {
|
|
|
364
373
|
|
|
365
374
|
throw new OpenError('AEAD decryption failed', { cause })
|
|
366
375
|
}
|
|
367
|
-
this.#seq = IncrementSeq(this.#seq)
|
|
376
|
+
this.#seq = IncrementSeq(this.#seq, this.#max_seq)
|
|
368
377
|
return pt
|
|
369
378
|
} finally {
|
|
370
379
|
release()
|
|
@@ -2157,12 +2166,18 @@ export interface AEAD {
|
|
|
2157
2166
|
/**
|
|
2158
2167
|
* Encrypts and authenticates plaintext with associated data.
|
|
2159
2168
|
*
|
|
2169
|
+
* Implementations must enforce the AEAD algorithm's per-invocation plaintext length limit (P_MAX)
|
|
2170
|
+
* before encryption. HPKE's explicit error list maps `MessageLimitReachedError` to context
|
|
2171
|
+
* sequence number overflow; it does not prescribe a specific error for P_MAX violations. Report
|
|
2172
|
+
* them as ordinary input range errors, such as `RangeError`.
|
|
2173
|
+
*
|
|
2160
2174
|
* @param key - The encryption key of {@link Nk} bytes
|
|
2161
2175
|
* @param nonce - The nonce of {@link Nn} bytes
|
|
2162
2176
|
* @param aad - Additional authenticated data
|
|
2163
2177
|
* @param pt - Plaintext to encrypt
|
|
2164
2178
|
*
|
|
2165
2179
|
* @returns A promise resolving to the ciphertext with authentication tag appended
|
|
2180
|
+
* @see [Context.Seal P_MAX handling](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-5.2)
|
|
2166
2181
|
*/
|
|
2167
2182
|
Seal(key: Uint8Array, nonce: Uint8Array, aad: Uint8Array, pt: Uint8Array): Promise<Uint8Array>
|
|
2168
2183
|
|
|
@@ -2266,6 +2281,8 @@ const NotApplicable = () => {
|
|
|
2266
2281
|
}
|
|
2267
2282
|
|
|
2268
2283
|
const EXPORT_ONLY = 0xffff
|
|
2284
|
+
const AES_GCM_P_MAX = 2 ** 36 - 31
|
|
2285
|
+
const CHACHA20_POLY1305_P_MAX = 2 ** 38 - 64
|
|
2269
2286
|
/**
|
|
2270
2287
|
* Export-only AEAD mode.
|
|
2271
2288
|
*
|
|
@@ -2692,22 +2709,19 @@ function b64u(input: string): Uint8Array {
|
|
|
2692
2709
|
// KEM (Key Encapsulation Mechanism) - DHKEM Helper Functions
|
|
2693
2710
|
// ============================================================================
|
|
2694
2711
|
|
|
2695
|
-
/** @see [DeriveKeyPair
|
|
2696
|
-
async function
|
|
2712
|
+
/** @see [DeriveKeyPair](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-7.1.3) */
|
|
2713
|
+
async function DeriveKeyPairBytes(
|
|
2697
2714
|
DHKEM: DHKEM,
|
|
2698
|
-
suite_id: Uint8Array,
|
|
2699
2715
|
ikm: Uint8Array,
|
|
2700
|
-
|
|
2716
|
+
label: Uint8Array,
|
|
2717
|
+
context: Uint8Array,
|
|
2701
2718
|
) {
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
I2OSP(counter, 1),
|
|
2709
|
-
DHKEM.Nsk,
|
|
2710
|
-
)
|
|
2719
|
+
if (KDFStages(DHKEM.kdf) === 1) {
|
|
2720
|
+
return await LabeledDerive(DHKEM.kdf, DHKEM.suite_id, ikm, label, context, DHKEM.Nsk)
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
const dkp_prk = await LabeledExtract(DHKEM.kdf, DHKEM.suite_id, new Uint8Array(), L_dkp_prk, ikm)
|
|
2724
|
+
return await LabeledExpand(DHKEM.kdf, DHKEM.suite_id, dkp_prk, label, context, DHKEM.Nsk)
|
|
2711
2725
|
}
|
|
2712
2726
|
|
|
2713
2727
|
function OS2IP(x: Uint8Array): bigint {
|
|
@@ -2752,6 +2766,22 @@ function assertCryptoKey(key: Key): asserts key is CryptoKey {
|
|
|
2752
2766
|
}
|
|
2753
2767
|
}
|
|
2754
2768
|
|
|
2769
|
+
/** @see [ExtractAndExpand](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-4.5) */
|
|
2770
|
+
async function ExtractAndExpand_OneStage(
|
|
2771
|
+
DHKEM: DHKEM,
|
|
2772
|
+
dh: Uint8Array,
|
|
2773
|
+
kem_context: Uint8Array,
|
|
2774
|
+
): Promise<Uint8Array> {
|
|
2775
|
+
return await LabeledDerive(
|
|
2776
|
+
DHKEM.kdf,
|
|
2777
|
+
DHKEM.suite_id,
|
|
2778
|
+
dh,
|
|
2779
|
+
L_shared_secret,
|
|
2780
|
+
kem_context,
|
|
2781
|
+
DHKEM.Nsecret,
|
|
2782
|
+
)
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2755
2785
|
/** @see [ExtractAndExpand](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-4.5) */
|
|
2756
2786
|
async function ExtractAndExpand_TwoStage(
|
|
2757
2787
|
DHKEM: DHKEM,
|
|
@@ -2769,6 +2799,16 @@ async function ExtractAndExpand_TwoStage(
|
|
|
2769
2799
|
)
|
|
2770
2800
|
}
|
|
2771
2801
|
|
|
2802
|
+
/** @see [ExtractAndExpand](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-4.5) */
|
|
2803
|
+
async function ExtractAndExpand(
|
|
2804
|
+
DHKEM: DHKEM,
|
|
2805
|
+
dh: Uint8Array,
|
|
2806
|
+
kem_context: Uint8Array,
|
|
2807
|
+
): Promise<Uint8Array> {
|
|
2808
|
+
const Fn = KDFStages(DHKEM.kdf) === 1 ? ExtractAndExpand_OneStage : ExtractAndExpand_TwoStage
|
|
2809
|
+
return await Fn(DHKEM, dh, kem_context)
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2772
2812
|
// ============================================================================
|
|
2773
2813
|
// KEM (Key Encapsulation Mechanism) - DHKEM Shared Implementation
|
|
2774
2814
|
// ============================================================================
|
|
@@ -2819,7 +2859,7 @@ function DHKEM_SHARED(): Required<Omit<KEM_BASE, 'DeriveKeyPair' | 'DeserializeP
|
|
|
2819
2859
|
const enc = await this.SerializePublicKey(pkE)
|
|
2820
2860
|
const pkRm = await this.SerializePublicKey(pkR)
|
|
2821
2861
|
const kem_context = concat(enc, pkRm)
|
|
2822
|
-
const shared_secret = await
|
|
2862
|
+
const shared_secret = await ExtractAndExpand(this, dh, kem_context)
|
|
2823
2863
|
return { shared_secret, enc }
|
|
2824
2864
|
},
|
|
2825
2865
|
async Decap(this: DHKEM, enc, skR, pkR) {
|
|
@@ -2846,7 +2886,7 @@ function DHKEM_SHARED(): Required<Omit<KEM_BASE, 'DeriveKeyPair' | 'DeserializeP
|
|
|
2846
2886
|
|
|
2847
2887
|
const pkRm = await this.SerializePublicKey(pkR)
|
|
2848
2888
|
const kem_context = concat(enc, pkRm)
|
|
2849
|
-
const shared_secret = await
|
|
2889
|
+
const shared_secret = await ExtractAndExpand(this, dh, kem_context)
|
|
2850
2890
|
return shared_secret
|
|
2851
2891
|
},
|
|
2852
2892
|
}
|
|
@@ -3070,7 +3110,7 @@ async function DeriveKeyPairNist(
|
|
|
3070
3110
|
if (counter > 255) {
|
|
3071
3111
|
throw new DeriveKeyPairError('Key derivation exceeded maximum iterations')
|
|
3072
3112
|
}
|
|
3073
|
-
candidate = await
|
|
3113
|
+
candidate = await DeriveKeyPairBytes(this, ikm, L_candidate, I2OSP(counter, 1))
|
|
3074
3114
|
candidate[0] = candidate[0]! & this.bitmask
|
|
3075
3115
|
sk = OS2IP(candidate)
|
|
3076
3116
|
counter = counter + 1
|
|
@@ -3107,8 +3147,7 @@ async function GetKeyPairNist(
|
|
|
3107
3147
|
|
|
3108
3148
|
/** @see [DeriveKeyPair](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-03.html#section-7.1.3) */
|
|
3109
3149
|
async function DeriveKeyPairX(this: DHKEM, ikm: Uint8Array, extractable: boolean) {
|
|
3110
|
-
const
|
|
3111
|
-
const sk = await LabeledExpand(this.kdf, this.suite_id, dkp_prk, L_sk, new Uint8Array(), this.Nsk)
|
|
3150
|
+
const sk = await DeriveKeyPairBytes(this, ikm, L_sk, new Uint8Array())
|
|
3112
3151
|
return await createKeyPairFromPrivateKey(this, sk, extractable)
|
|
3113
3152
|
}
|
|
3114
3153
|
|
|
@@ -3607,11 +3646,7 @@ interface WebCryptoAEAD extends AEAD {
|
|
|
3607
3646
|
|
|
3608
3647
|
type AEAD_BASE = Pick<AEAD, 'Seal' | 'Open'>
|
|
3609
3648
|
|
|
3610
|
-
function AEAD_SHARED(): AEAD_BASE {
|
|
3611
|
-
// Note: The per-invocation plaintext limits (P_MAX, e.g. 2^36 - 31 bytes for
|
|
3612
|
-
// AES-GCM and 2^38 - 64 bytes for ChaCha20-Poly1305) are not explicitly
|
|
3613
|
-
// enforced here as they exceed the maximum ArrayBuffer/Uint8Array sizes
|
|
3614
|
-
// attainable in JavaScript runtimes.
|
|
3649
|
+
function AEAD_SHARED(P_MAX: number): AEAD_BASE {
|
|
3615
3650
|
// Cache the WebCrypto CryptoKey derived from a given key-bytes Uint8Array.
|
|
3616
3651
|
// Across the lifetime of a SenderContext/RecipientContext, `this.#key` is a
|
|
3617
3652
|
// stable Uint8Array, so crypto.subtle.importKey() would otherwise be called
|
|
@@ -3630,6 +3665,9 @@ function AEAD_SHARED(): AEAD_BASE {
|
|
|
3630
3665
|
}
|
|
3631
3666
|
return {
|
|
3632
3667
|
async Seal(this: WebCryptoAEAD, key, nonce, aad, pt) {
|
|
3668
|
+
if (pt.byteLength > P_MAX) {
|
|
3669
|
+
throw new RangeError('"pt" exceeds P_MAX')
|
|
3670
|
+
}
|
|
3633
3671
|
const cryptoKey =
|
|
3634
3672
|
cache.get(key) ?? (await cacheValue(cache, key, () => importKey.call(this, key)))
|
|
3635
3673
|
return new Uint8Array(
|
|
@@ -3702,7 +3740,7 @@ export const AEAD_AES_128_GCM: AEADFactory = function (): WebCryptoAEAD {
|
|
|
3702
3740
|
Nt: 16,
|
|
3703
3741
|
algorithm: 'AES-GCM',
|
|
3704
3742
|
keyFormat: 'raw',
|
|
3705
|
-
...AEAD_SHARED(),
|
|
3743
|
+
...AEAD_SHARED(AES_GCM_P_MAX),
|
|
3706
3744
|
}
|
|
3707
3745
|
}
|
|
3708
3746
|
|
|
@@ -3734,7 +3772,7 @@ export const AEAD_AES_256_GCM: AEADFactory = function (): WebCryptoAEAD {
|
|
|
3734
3772
|
Nt: 16,
|
|
3735
3773
|
algorithm: 'AES-GCM',
|
|
3736
3774
|
keyFormat: 'raw',
|
|
3737
|
-
...AEAD_SHARED(),
|
|
3775
|
+
...AEAD_SHARED(AES_GCM_P_MAX),
|
|
3738
3776
|
}
|
|
3739
3777
|
}
|
|
3740
3778
|
|
|
@@ -3767,7 +3805,7 @@ export const AEAD_ChaCha20Poly1305: AEADFactory = function AEAD_ChaCha20Poly1305
|
|
|
3767
3805
|
algorithm: 'ChaCha20-Poly1305',
|
|
3768
3806
|
// @ts-expect-error
|
|
3769
3807
|
keyFormat: 'raw-secret',
|
|
3770
|
-
...AEAD_SHARED(),
|
|
3808
|
+
...AEAD_SHARED(CHACHA20_POLY1305_P_MAX),
|
|
3771
3809
|
}
|
|
3772
3810
|
}
|
|
3773
3811
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hpke",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Hybrid Public Key Encryption (HPKE) for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -56,18 +56,18 @@
|
|
|
56
56
|
"@noble/curves": "^2.2.0",
|
|
57
57
|
"@noble/hashes": "^2.2.0",
|
|
58
58
|
"@noble/post-quantum": "^0.6.1",
|
|
59
|
-
"@types/node": "^24.
|
|
60
|
-
"amaro": "^1.1.
|
|
61
|
-
"esbuild": "^0.28.
|
|
62
|
-
"playwright": "^1.
|
|
63
|
-
"prettier": "^3.8.
|
|
64
|
-
"prettier-plugin-jsdoc": "^1.8.
|
|
59
|
+
"@types/node": "^24.13.2",
|
|
60
|
+
"amaro": "^1.1.10",
|
|
61
|
+
"esbuild": "^0.28.1",
|
|
62
|
+
"playwright": "^1.61.0",
|
|
63
|
+
"prettier": "^3.8.4",
|
|
64
|
+
"prettier-plugin-jsdoc": "^1.8.1",
|
|
65
65
|
"remark-behead": "^3.1.0",
|
|
66
|
-
"remark-insert-headings": "^
|
|
66
|
+
"remark-insert-headings": "^1.0.0",
|
|
67
67
|
"remark-toc": "^9.0.0",
|
|
68
68
|
"serve": "^14.2.6",
|
|
69
69
|
"typedoc": "^0.28.19",
|
|
70
|
-
"typedoc-plugin-markdown": "^4.
|
|
70
|
+
"typedoc-plugin-markdown": "^4.12.0",
|
|
71
71
|
"typedoc-plugin-remark": "^2.0.1",
|
|
72
72
|
"typescript": "^6.0.3"
|
|
73
73
|
},
|