]> git.kaiwu.me - njs.git/commitdiff
WebCrypto: reject unsupported generateKey() algorithms in njs
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 17 Nov 2026 02:31:16 +0000 (18:31 -0800)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 17 Nov 2026 22:09:33 +0000 (14:09 -0800)
Previously, generateKey() with an algorithm that has no key
generation, such as HKDF, threw InternalError synchronously instead
of returning a rejected Promise, unlike every other generateKey()
error.

Route the error through the common result path, as required by Web
Cryptography API section 14.3.6.

The issue was introduced in 50e7c9b2 (0.7.10).

external/njs_webcrypto_module.c

index 8d3fc5ee703bc6f9a9abf9302f55e68e53c01c06..8f3e1c133a7be430b095eaeab9526c73ccce16e7 100644 (file)
@@ -3218,7 +3218,7 @@ njs_ext_generate_key(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     default:
         njs_vm_internal_error(vm, "not implemented generateKey"
                               "algorithm: \"%V\"", njs_algorithm_string(alg));
-        return NJS_ERROR;
+        goto fail;
     }
 
     return njs_webcrypto_result(vm, &value, NJS_OK, retval);