GeezerVison is showing github.com — crypto: reject duplicate ML-KEM JWK key_ops · nodejs/node@6eea524
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/util.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -801,6 +801,10 @@ const kKeyOps = { | 801 | 801 | unwrapKey: 6, | 802 | 802 | deriveKey: 7, | 803 | 803 | deriveBits: 8, | | 804 | + encapsulateKey: 9, | | 805 | + encapsulateBits: 10, | | 806 | + decapsulateKey: 11, | | 807 | + decapsulateBits: 12, | 804 | 808 | }; | 805 | 809 |
| 806 | 810 | function validateKeyOps(keyOps, usagesSet) { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-export-import-ml-kem.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -321,3 +321,16 @@ async function testImportRawSeed({ name, privateUsages }, extractable) { | 321 | 321 | }); | 322 | 322 | } | 323 | 323 | })().then(common.mustCall()); | | 324 | + | | 325 | +// Regression test: JWK `key_ops` validation must recognize ML-KEM operations | | 326 | +// (encapsulateKey, encapsulateBits, decapsulateKey, decapsulateBits) so that | | 327 | +// duplicate entries are rejected | | 328 | +(async function() { | | 329 | + for (const op of ['encapsulateKey', 'encapsulateBits', | | 330 | + 'decapsulateKey', 'decapsulateBits']) { | | 331 | + const jwk = { ...keyData['ML-KEM-768'].jwk, key_ops: [op, op] }; | | 332 | + await assert.rejects( | | 333 | + subtle.importKey('jwk', jwk, { name: 'ML-KEM-768' }, true, [op]), | | 334 | + { name: 'DataError', message: /Duplicate key operation/ }); | | 335 | + } | | 336 | +})().then(common.mustCall()); |
|