]> git.kaiwu.me - njs.git/commitdiff
Webcrypto: fix QuickJS build with OpenSSL < 1.1.0
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 12 Aug 2026 00:13:13 +0000 (17:13 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Wed, 12 Aug 2026 03:36:54 +0000 (20:36 -0700)
The issue was introduced in 75ca26f83471 (0.8.10).

The QuickJS WebCrypto implementation called BN_bn2binpad() and
ECDSA_SIG_set0() directly, although compatibility wrappers were already
used by the njs implementation.  It also referenced an njs-only
string_info variable when HKDF was unavailable.

Use the shared OpenSSL compatibility wrappers and remove the stale
reference.

external/qjs_webcrypto_module.c

index 3da69e19b6434f72f461b4259163e16c54183877..29f1931cbf435febc9764223c24d8296f2f3539f 100644 (file)
@@ -2401,7 +2401,6 @@ free:
 #else
         (void) pctx;
         (void) olen;
-        (void) &string_info;
         (void) &info;
 #endif
 
@@ -4484,11 +4483,11 @@ qjs_convert_der_to_p1363(JSContext *cx, EVP_PKEY *pkey, const u_char *der,
     s = ec_sig->s;
 #endif
 
-    if (BN_bn2binpad(r, data, n) <= 0) {
+    if (njs_bn_bn2binpad(r, data, n) <= 0) {
         goto fail;
     }
 
-    if (BN_bn2binpad(s, &data[n], n) <= 0) {
+    if (njs_bn_bn2binpad(s, &data[n], n) <= 0) {
         goto fail;
     }
 
@@ -4548,7 +4547,7 @@ qjs_convert_p1363_to_der(JSContext *cx, EVP_PKEY *pkey, u_char *p1363,
         goto fail;
     }
 
-    if (ECDSA_SIG_set0(ec_sig, r, s) != 1) {
+    if (njs_ecdsa_sig_set0(ec_sig, r, s) != 1) {
         BN_free(r);
         BN_free(s);
         JS_ThrowOutOfMemory(cx);