mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
crypto: reject duplicate ML-KEM JWK key_ops
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62905 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
This commit is contained in:
1 parent
80d4836616
commit
6eea52426f
2 files changed
+17
No files matched your search
@@ -801,6 +801,10 @@ const kKeyOps = {
|
||||
unwrapKey: 6,
|
||||
deriveKey: 7,
|
||||
deriveBits: 8,
|
||||
encapsulateKey: 9,
|
||||
encapsulateBits: 10,
|
||||
decapsulateKey: 11,
|
||||
decapsulateBits: 12,
|
||||
};
|
||||
|
||||
function validateKeyOps(keyOps, usagesSet) {
|
||||
|
||||
@@ -321,3 +321,16 @@ async function testImportRawSeed({ name, privateUsages }, extractable) {
|
||||
});
|
||||
}
|
||||
})().then(common.mustCall());
|
||||
|
||||
// Regression test: JWK `key_ops` validation must recognize ML-KEM operations
|
||||
// (encapsulateKey, encapsulateBits, decapsulateKey, decapsulateBits) so that
|
||||
// duplicate entries are rejected
|
||||
(async function() {
|
||||
for (const op of ['encapsulateKey', 'encapsulateBits',
|
||||
'decapsulateKey', 'decapsulateBits']) {
|
||||
const jwk = { ...keyData['ML-KEM-768'].jwk, key_ops: [op, op] };
|
||||
await assert.rejects(
|
||||
subtle.importKey('jwk', jwk, { name: 'ML-KEM-768' }, true, [op]),
|
||||
{ name: 'DataError', message: /Duplicate key operation/ });
|
||||
}
|
||||
})().then(common.mustCall());
|
||||
Reference in new issue
Block a user