@@ -147,7 +147,7 @@ index 6e5bbe07d0c337b36f3157c2e6404fdc91849fd1..7ec682833213de9054a8c30751436d12
147147 DHPointer dh;
148148 {
149149diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc
150- index b4447102a8478639a5aa774e583834d79808603f..d3dad0ae8a9810e8481529776f4ed4686a8d9c53 100644
150+ index b4447102a8478639a5aa774e583834d79808603f..678be07feb394530b944c1b356265416f2d50742 100644
151151--- a/src/crypto/crypto_dh.cc
152152+++ b/src/crypto/crypto_dh.cc
153153@@ -154,13 +154,11 @@ bool DiffieHellman::Init(BignumPointer&& bn_p, int g) {
@@ -166,7 +166,7 @@ index b4447102a8478639a5aa774e583834d79808603f..d3dad0ae8a9810e8481529776f4ed468
166166 return false;
167167 }
168168 BignumPointer bn_p(
169- @@ -176,18 +174,17 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
169+ @@ -176,20 +174,17 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
170170 bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) {
171171 dh_.reset(DH_new());
172172 if (p_len <= 0) {
@@ -184,11 +184,13 @@ index b4447102a8478639a5aa774e583834d79808603f..d3dad0ae8a9810e8481529776f4ed468
184184 BignumPointer bn_g(
185185 BN_bin2bn(reinterpret_cast<const unsigned char*>(g), g_len, nullptr));
186186 if (BN_is_zero(bn_g.get()) || BN_is_one(bn_g.get())) {
187+ - ERR_put_error(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS,
188+ - DH_R_BAD_GENERATOR, __FILE__, __LINE__);
187189+ OPENSSL_PUT_ERROR(DH, DH_R_BAD_GENERATOR);
188- ERR_put_error(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS,
189- DH_R_BAD_GENERATOR, __FILE__, __LINE__);
190190 return false;
191- @@ -219,8 +216,10 @@ typedef BignumPointer (*StandardizedGroupInstantiator)();
191+ }
192+ BignumPointer bn_p(
193+ @@ -219,8 +214,10 @@ typedef BignumPointer (*StandardizedGroupInstantiator)();
192194 inline StandardizedGroupInstantiator FindDiffieHellmanGroup(const char* name) {
193195 #define V(n, p) \
194196 if (StringEqualNoCase(name, n)) return InstantiateStandardizedGroup<p>
@@ -199,7 +201,7 @@ index b4447102a8478639a5aa774e583834d79808603f..d3dad0ae8a9810e8481529776f4ed468
199201 V("modp5", BN_get_rfc3526_prime_1536);
200202 V("modp14", BN_get_rfc3526_prime_2048);
201203 V("modp15", BN_get_rfc3526_prime_3072);
202- @@ -559,15 +558 ,20 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
204+ @@ -559,15 +556 ,20 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
203205 return EVPKeyCtxPointer();
204206 }
205207
@@ -220,7 +222,7 @@ index b4447102a8478639a5aa774e583834d79808603f..d3dad0ae8a9810e8481529776f4ed468
220222 if (!param_ctx ||
221223 EVP_PKEY_paramgen_init(param_ctx.get()) <= 0 ||
222224 EVP_PKEY_CTX_set_dh_paramgen_prime_len(
223- @@ -581,6 +585 ,9 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
225+ @@ -581,6 +583 ,9 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
224226 }
225227
226228 key_params = EVPKeyPointer(raw_params);
@@ -370,6 +372,28 @@ index 5734d8fdc5505e1586f571c19b840bd56e9c9f1f..3034b114e081e2b32dd5b71653927a41
370372 }
371373 } // namespace
372374
375+ diff --git a/src/env.h b/src/env.h
376+ index 994b9573822fd3eb0588e87edaa0e505aa5102fb..bb84f5ab43cb5be42019921e5dc2fc010d7b9018 100644
377+ --- a/src/env.h
378+ +++ b/src/env.h
379+ @@ -49,7 +49,7 @@
380+ #include "uv.h"
381+ #include "v8.h"
382+
383+ - #if HAVE_OPENSSL
384+ + #if HAVE_OPENSSL && OPENSSL_VERSION_MAJOR >= 3
385+ #include <openssl/evp.h>
386+ #endif
387+
388+ @@ -1032,7 +1032,7 @@ class Environment : public MemoryRetainer {
389+ kExitInfoFieldCount
390+ };
391+
392+ - #if HAVE_OPENSSL
393+ + #if HAVE_OPENSSL// && !defined(OPENSSL_IS_BORINGSSL)
394+ #if OPENSSL_VERSION_MAJOR >= 3
395+ // We declare another alias here to avoid having to include crypto_util.h
396+ using EVPMDPointer = DeleteFnPtr<EVP_MD, EVP_MD_free>;
373397diff --git a/src/node.cc b/src/node.cc
374398index 10e04ed8a28bd010e4887ad5b9af3886f7b32a53..012dd487e8db232d068bce358ad44b14e78d0fe9 100644
375399--- a/src/node.cc
0 commit comments