Files
electron/patches/node/fix_use_crypto_impls_for_compat.patch
Electron Bot ccf70326c0 chore: bump chromium to 1ba9678489174a6123358a7683f37 (master) (#22719)
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Andy Locascio <andy@slack-corp.com>
2020-04-06 13:09:52 -07:00

34 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 12 Feb 2020 15:08:04 -0800
Subject: fix: use crypto impls for compat
BoringSSL does not export DSA_get0_q, ECDSA_SIG_get0_r, or ECDSA_SIG_get0_s. This
patch works around that problem by using the implementations of those functions as
found in the OpenSSL repo. I plan to upstream a version of this.
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 3c2393a1c674250f7bd262ee5dbc30330c9f2a58..ac1b57efaebbef7da1bb38b587146edad81289db 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5021,7 +5021,7 @@ static unsigned int GetBytesOfRS(const ManagedEVPPKey& pkey) {
if (base_id == EVP_PKEY_DSA) {
DSA* dsa_key = EVP_PKEY_get0_DSA(pkey.get());
// Both r and s are computed mod q, so their width is limited by that of q.
- bits = BN_num_bits(DSA_get0_q(dsa_key));
+ bits = BN_num_bits(dsa_key->q);
} else if (base_id == EVP_PKEY_EC) {
EC_KEY* ec_key = EVP_PKEY_get0_EC_KEY(pkey.get());
const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key);
@@ -5050,8 +5050,8 @@ static AllocatedBuffer ConvertSignatureToP1363(Environment* env,
AllocatedBuffer buf = env->AllocateManaged(2 * n);
unsigned char* data = reinterpret_cast<unsigned char*>(buf.data());
- const BIGNUM* r = ECDSA_SIG_get0_r(asn1_sig.get());
- const BIGNUM* s = ECDSA_SIG_get0_s(asn1_sig.get());
+ const BIGNUM* r = asn1_sig.get()->r;
+ const BIGNUM* s = asn1_sig.get()->s;
CHECK_EQ(n, static_cast<unsigned int>(BN_bn2binpad(r, data, n)));
CHECK_EQ(n, static_cast<unsigned int>(BN_bn2binpad(s, data + n, n)));