Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6eea524

Browse filesBrowse files
panvaaduh95
authored andcommitted
crypto: reject duplicate ML-KEM JWK key_ops
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #62905 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
1 parent 80d4836 commit 6eea524
Copy full SHA for 6eea524

2 files changed

+17Lines changed: 17 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/util.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,10 @@ const kKeyOps = {
801801
unwrapKey: 6,
802802
deriveKey: 7,
803803
deriveBits: 8,
804+
encapsulateKey: 9,
805+
encapsulateBits: 10,
806+
decapsulateKey: 11,
807+
decapsulateBits: 12,
804808
};
805809

806810
function validateKeyOps(keyOps, usagesSet) {
Collapse file

‎test/parallel/test-webcrypto-export-import-ml-kem.js‎

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 numberDiff line numberDiff line change
@@ -321,3 +321,16 @@ async function testImportRawSeed({ name, privateUsages }, extractable) {
321321
});
322322
}
323323
})().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());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.