Skip to content

Commit 6ede6ce

Browse files
committed
feat: add HPKE JWE Algorithms
1 parent d0505bf commit 6ede6ce

26 files changed

Lines changed: 1292 additions & 141 deletions

cookbook/jwe.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,4 +668,44 @@ export default [
668668
},
669669
},
670670
},
671+
{
672+
title:
673+
'https://datatracker.ietf.org/doc/draft-ietf-jose-hpke-encrypt/ - HPKE Integrated Encryption',
674+
deterministic: false,
675+
input: {
676+
plaintext:
677+
'You can trust us to stick with you through thick and thin–to the bitter end. And you can trust us to keep any secret of yours–closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo.',
678+
key: {
679+
kty: 'EC',
680+
use: 'enc',
681+
alg: 'HPKE-0',
682+
kid: 'yCnfbmYMZcWrKDt_DjNebRCB1vxVoqv4umJ4WK8RYjk',
683+
crv: 'P-256',
684+
x: 'gixQJ0qg4Ag-6HSMaIEDL_zbDhoXavMyKlmdn__AQVE',
685+
y: 'ZxTgRLWaKONCL_GbZKLNPsW9EW6nBsN4AwQGEFAFFbM',
686+
d: 'g2DXtKapi2oN2zL_RCWX8D4bWURHCKN2-ZNGC05ZaR8',
687+
},
688+
alg: 'HPKE-0',
689+
aad: 'The Fellowship of the Ring',
690+
},
691+
encrypting_content: {
692+
protected: {
693+
alg: 'HPKE-0',
694+
kid: 'yCnfbmYMZcWrKDt_DjNebRCB1vxVoqv4umJ4WK8RYjk',
695+
},
696+
},
697+
output: {
698+
compact:
699+
'eyJhbGciOiJIUEtFLTAiLCJraWQiOiJ5Q25mYm1ZTVpjV3JLRHRfRGpOZWJSQ0IxdnhWb3F2NHVtSjRXSzhSWWprIn0.BLAJX8adrFsDKaoJAc3iy2dq-6jEH3Uv-bSgqIoDeREqpWglMoTS67XsXere1ZYxiQKEFU6MbWe8O7vmdlSmcUk..NcN9ew5aijn8W7piLVRU8r2cOP0JKqxOF4RllVsJM4qsAfVXW5Ka6so9zdUmXXNOXyCEk0wV_s8ICAnD4LbRa5TkhTeuhijIfAt9bQ2fMLOeyed3WyArs8yaMraa9Zbh4i6SaHunM7jU_xoz_N2WbykSOSySmCO49H4mP3jLW9L_TYQfeVfYsrB8clqokZ8h-3eQGNwmOPtkjWdpAfaHUsp4-HC9nRd6yrTU6mV65Nn2iYynu3Xkgy2Lm-kQKDavIEW3PBpEeiw6mtPJE9o8sT-0lZ9kpWtqog2XbNGEfjSOjujvNe1b0g4-FdNFMFO_fo0rxe902W1pGT7znv4Q-xBkIydK4ZwjiFN6dAXutnococ37A0Hr5esPLwHRTTrBFw.',
700+
json_flat: {
701+
ciphertext:
702+
'LabI8_KIPDbymUSbyVctj8AfISXQ07sMt1xQ1lrS-0heU2jjejpQIK75K1KXcvwn15E6Kil_tJ6LBcYCu02O1H8_aooJGuoLw1vEzQn16h498YX9e2SA2IcVrJTkcCjL7YpF9fsAF3JEzGfsmmrpZPPVdxCn7g8dkGRcyulnHrNvBu4BFtub-URtf-nYCFIJHZ4k-ul9fDddquicFzCxQonx66-ZX5nbj6azHG65tAZntd6VFkRgihdxTvIpvTS4gfulQeKyShbiw-OCJNbzFdEnOKEMnsyqRjwG7iVrFEilFAMsvLJ14-lcuR5btIkUntIwlnsfUa2Ytk33znCfAFN0wYukdDvJe-V0nnNUFlOeLyYV0eEGisgC9dQQ1kFu3g',
703+
encrypted_key:
704+
'BAOlZ-VnbhQu4NOlTlDAVYwUJB-Q6YcWwnRNWK6YLSiHHlW4rN0qUzBJ3Rc2_y8nkasn8nUVGBzdq7OhdKKiLq4',
705+
aad: 'VGhlIEZlbGxvd3NoaXAgb2YgdGhlIFJpbmc',
706+
protected:
707+
'eyJhbGciOiJIUEtFLTAiLCJraWQiOiJ5Q25mYm1ZTVpjV3JLRHRfRGpOZWJSQ0IxdnhWb3F2NHVtSjRXSzhSWWprIn0',
708+
},
709+
},
710+
},
671711
]

docs/jwt/decrypt/interfaces/JWTDecryptOptions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ This option makes the JWT "iat" (Issued At) Claim presence required.
133133

134134
***
135135

136+
### psk?
137+
138+
`optional` **psk**: [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
139+
140+
HPKE Pre-Shared Key (PSK) for use in PSK mode.
141+
142+
***
143+
136144
### requiredClaims?
137145

138146
`optional` **requiredClaims**: `string`[]

docs/types/interfaces/CompactJWEHeaderParameters.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@ JWE "alg" (Algorithm) Header Parameter
2626

2727
***
2828

29-
### enc
30-
31-
**enc**: `string`
32-
33-
JWE "enc" (Encryption Algorithm) Header Parameter
34-
35-
#### See
36-
37-
[Algorithm Key Requirements](https://github.com/panva/jose/issues/210#jwe-alg)
38-
39-
***
40-
4129
### crit?
4230

4331
`optional` **crit**: `string`[]
@@ -54,6 +42,18 @@ JWE "crit" (Critical) Header Parameter
5442

5543
***
5644

45+
### enc?
46+
47+
`optional` **enc**: `string`
48+
49+
JWE "enc" (Encryption Algorithm) Header Parameter
50+
51+
#### See
52+
53+
[Algorithm Key Requirements](https://github.com/panva/jose/issues/210#jwe-alg)
54+
55+
***
56+
5757
### jku?
5858

5959
`optional` **jku**: `string`
@@ -78,6 +78,14 @@ JWE "crit" (Critical) Header Parameter
7878

7979
***
8080

81+
### psk\_id?
82+
83+
`optional` **psk\_id**: `string`
84+
85+
HPKE Pre-Shared Key Identifier (PSK ID) for use in PSK mode.
86+
87+
***
88+
8189
### typ?
8290

8391
`optional` **typ**: `string`

docs/types/interfaces/DecryptOptions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,11 @@ Set to `Infinity` to disable the decompressed size limit.
7575
(PBES2 Key Management Algorithms only) Maximum allowed "p2c" (PBES2 Count) Header Parameter
7676
value. The PBKDF2 iteration count defines the algorithm's computational expense. By default
7777
this value is set to 10000.
78+
79+
***
80+
81+
### psk?
82+
83+
`optional` **psk**: [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
84+
85+
HPKE Pre-Shared Key (PSK) for use in PSK mode.

docs/types/interfaces/JWEHeaderParameters.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ JWE "enc" (Encryption Algorithm) Header Parameter
7878

7979
***
8080

81+
### psk\_id?
82+
83+
`optional` **psk\_id**: `string`
84+
85+
HPKE Pre-Shared Key Identifier (PSK ID) for use in PSK mode.
86+
87+
***
88+
8189
### typ?
8290

8391
`optional` **typ**: `string`

docs/types/interfaces/JWEKeyManagementHeaderParameters.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,19 @@ You should not use this parameter. It is only intended for testing and vector
6767

6868
You should not use this parameter. It is only intended for testing and vector
6969
validation purposes.
70+
71+
***
72+
73+
### psk?
74+
75+
`optional` **psk**: [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
76+
77+
HPKE Pre-Shared Key (PSK) for use in PSK mode.
78+
79+
***
80+
81+
### psk\_id?
82+
83+
`optional` **psk\_id**: [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
84+
85+
HPKE Pre-Shared Key Identifier (PSK ID) for use in PSK mode.

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
"ava": "^7.0.0",
237237
"esbuild": "^0.27.3",
238238
"glob": "^13.0.6",
239+
"hpke": "^1.0.6",
239240
"npm-run-all2": "^8.0.4",
240241
"patch-package": "^8.0.1",
241242
"prettier": "^3.8.1",

0 commit comments

Comments
 (0)