Skip to content

Commit d0a7d3c

Browse files
committed
crypto: include openssl/rand.h explicitly
nodejs/node#55425
1 parent 4290aea commit d0a7d3c

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@ Upstreams:
1717
- https://github.com/nodejs/node/pull/39136
1818

1919
diff --git a/deps/ncrypto/ncrypto.cc b/deps/ncrypto/ncrypto.cc
20-
index 457bd2f6c5b18956d06c716fbfae429496fb352d..e954cb2e53f3d8c297d21ef9f698d824ca574106 100644
20+
index ac2d771555126a4f43b8c3a3fd299d40019e6622..769fe636ef2b5d02ecc9ff753e64d93ea5075700 100644
2121
--- a/deps/ncrypto/ncrypto.cc
2222
+++ b/deps/ncrypto/ncrypto.cc
23-
@@ -6,13 +6,11 @@
24-
#include <openssl/evp.h>
25-
#include <openssl/hmac.h>
26-
#include <openssl/pkcs12.h>
27-
+#include <openssl/rand.h>
28-
#include <openssl/x509v3.h>
23+
@@ -11,9 +11,6 @@
2924
#if OPENSSL_VERSION_MAJOR >= 3
3025
#include <openssl/provider.h>
3126
#endif
@@ -35,30 +30,31 @@ index 457bd2f6c5b18956d06c716fbfae429496fb352d..e954cb2e53f3d8c297d21ef9f698d824
3530

3631
namespace ncrypto {
3732
namespace {
38-
@@ -694,7 +692,7 @@ bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) {
33+
@@ -708,7 +705,7 @@ bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) {
3934

4035
bool ok = true;
4136

4237
- for (int i = 0; i < sk_GENERAL_NAME_num(names); i++) {
4338
+ for (size_t i = 0; i < sk_GENERAL_NAME_num(names); i++) {
4439
GENERAL_NAME* gen = sk_GENERAL_NAME_value(names, i);
4540

46-
if (i != 0)
47-
@@ -720,7 +718,7 @@ bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext) {
41+
if (i != 0) BIO_write(out.get(), ", ", 2);
42+
@@ -732,7 +729,7 @@ bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext) {
4843

4944
bool ok = true;
5045

5146
- for (int i = 0; i < sk_ACCESS_DESCRIPTION_num(descs); i++) {
5247
+ for (size_t i = 0; i < sk_ACCESS_DESCRIPTION_num(descs); i++) {
5348
ACCESS_DESCRIPTION* desc = sk_ACCESS_DESCRIPTION_value(descs, i);
5449

55-
if (i != 0)
56-
@@ -857,13 +855,17 @@ BIOPointer X509View::getValidTo() const {
50+
if (i != 0) BIO_write(out.get(), "\n", 1);
51+
@@ -874,13 +871,17 @@ BIOPointer X509View::getValidTo() const {
5752

5853
int64_t X509View::getValidToTime() const {
5954
struct tm tp;
55+
- ASN1_TIME_to_tm(X509_get0_notAfter(cert_), &tp);
6056
+#ifndef OPENSSL_IS_BORINGSSL
61-
ASN1_TIME_to_tm(X509_get0_notAfter(cert_), &tp);
57+
+ ASN1_TIME_to_tm(X509_get0_notAfter(cert_), &tp);
6258
+#endif
6359
return PortableTimeGM(&tp);
6460
}
@@ -71,21 +67,22 @@ index 457bd2f6c5b18956d06c716fbfae429496fb352d..e954cb2e53f3d8c297d21ef9f698d824
7167
return PortableTimeGM(&tp);
7268
}
7369

74-
@@ -1043,7 +1045,11 @@ BIOPointer BIOPointer::NewMem() {
70+
@@ -1085,7 +1086,11 @@ BIOPointer BIOPointer::NewMem() {
7571
}
7672

7773
BIOPointer BIOPointer::NewSecMem() {
74+
- return BIOPointer(BIO_new(BIO_s_secmem()));
7875
+#ifdef OPENSSL_IS_BORINGSSL
7976
+ return BIOPointer(BIO_new(BIO_s_mem()));
8077
+#else
81-
return BIOPointer(BIO_new(BIO_s_secmem()));
78+
+ return BIOPointer(BIO_new(BIO_s_secmem()));
8279
+#endif
8380
}
8481

8582
BIOPointer BIOPointer::New(const BIO_METHOD* method) {
86-
@@ -1098,8 +1104,10 @@ BignumPointer DHPointer::FindGroup(const std::string_view name,
87-
FindGroupOption option) {
88-
#define V(n, p) if (EqualNoCase(name, n)) return BignumPointer(p(nullptr));
83+
@@ -1149,8 +1154,10 @@ BignumPointer DHPointer::FindGroup(const std::string_view name,
84+
#define V(n, p) \
85+
if (EqualNoCase(name, n)) return BignumPointer(p(nullptr));
8986
if (option != FindGroupOption::NO_SMALL_PRIMES) {
9087
+#ifndef OPENSSL_IS_BORINGSSL
9188
V("modp1", BN_get_rfc2409_prime_768);
@@ -94,7 +91,7 @@ index 457bd2f6c5b18956d06c716fbfae429496fb352d..e954cb2e53f3d8c297d21ef9f698d824
9491
V("modp5", BN_get_rfc3526_prime_1536);
9592
}
9693
V("modp14", BN_get_rfc3526_prime_2048);
97-
@@ -1171,11 +1179,13 @@ DHPointer::CheckPublicKeyResult DHPointer::checkPublicKey(const BignumPointer& p
94+
@@ -1223,11 +1230,13 @@ DHPointer::CheckPublicKeyResult DHPointer::checkPublicKey(
9895
int codes = 0;
9996
if (DH_check_pub_key(dh_.get(), pub_key.get(), &codes) != 1)
10097
return DHPointer::CheckPublicKeyResult::CHECK_FAILED;

0 commit comments

Comments
 (0)