]> git.kaiwu.me - njs.git/commit
WebCrypto: return false for wrong-length ECDSA signatures
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 15 Oct 2026 06:06:08 +0000 (23:06 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 15 Oct 2026 14:42:10 +0000 (07:42 -0700)
commitf7495e221b88b9dd89eaf45cea46550023199635
treefb86c7d690c2cdc9d45d30194fa918b4e535076c
parent7c00df7f49c9d8f32f509ea8ef8bcc1e729fea2a
WebCrypto: return false for wrong-length ECDSA signatures

ECDSA signatures of an invalid length cause verify() to throw instead
of returning false.  njs passes an empty DER signature to
EVP_PKEY_verify(), while QuickJS rejects the length during conversion.

The njs behavior dates back to 86c202c7 (0.7.7); QuickJS rejects these
signatures since 75ca26f8 (0.8.10).

Treat a length mismatch as an invalid signature, as required by
WebCrypto ECDSA Verify, while preserving diagnostics for conversion
failures.  Test all three supported curves with invalid lengths and
a valid signature.
external/njs_webcrypto_module.c
external/qjs_webcrypto_module.c
test/webcrypto/sign.t.mjs