From: Dmitry Volyntsev Date: Thu, 19 Nov 2026 01:05:40 +0000 (-0800) Subject: WebCrypto: remove empty hash from HKDF and PBKDF2 keys in njs X-Git-Url: https://git.kaiwu.me/http/%7B@url%7D?a=commitdiff_plain;h=fc3735196d28b014da9d1ca7c0e8fb1c4826518c;p=njs.git WebCrypto: remove empty hash from HKDF and PBKDF2 keys in njs Previously, HKDF and PBKDF2 keys went through the HMAC branch and key.algorithm exposed an empty hash member. These keys have no hash; their KeyAlgorithm contains only the name. The issue was introduced in 722e2763 (0.8.0). --- diff --git a/external/njs_webcrypto_module.c b/external/njs_webcrypto_module.c index 1df19647..6f0859bc 100644 --- a/external/njs_webcrypto_module.c +++ b/external/njs_webcrypto_module.c @@ -5519,6 +5519,8 @@ njs_key_ext_algorithm(njs_vm_t *vm, njs_object_prop_t *prop, uint32_t unused, case NJS_ALGORITHM_ED25519: case NJS_ALGORITHM_X25519: + case NJS_ALGORITHM_PBKDF2: + case NJS_ALGORITHM_HKDF: break; case NJS_ALGORITHM_HMAC: diff --git a/test/webcrypto/key_algorithm.t.mjs b/test/webcrypto/key_algorithm.t.mjs index 0285e714..3c501c84 100644 --- a/test/webcrypto/key_algorithm.t.mjs +++ b/test/webcrypto/key_algorithm.t.mjs @@ -9,7 +9,9 @@ async function test(params) { ['deriveBits']); let algorithm = key.algorithm; - if (algorithm.name !== params.name) { + if (Object.keys(algorithm).join() !== 'name' + || algorithm.name !== params.name) + { throw Error(`unexpected algorithm: ${JSON.stringify(algorithm)}`); }