Skip to content

Commit

Permalink
fix: add missing openssl/rand.h include
Browse files Browse the repository at this point in the history
Before nodejs/node#35093 this include was
explicitly there but it was remove in the refactor.

Upstreamed at nodejs/node#38864.
  • Loading branch information
codebytere committed May 31, 2021
1 parent 74f495f commit a3236a5
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions patches/node/fix_comment_out_incompatible_crypto_modules.patch
Expand Up @@ -232,55 +232,35 @@ index 5fa91cce1a6ad2bc1167e20a4dadcfdfc2343440..d6db572ffac83b82eb3356a4d3258ae8

size_t out_len = 0;
diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
index fbe4c0f06c10df7c8a492711594381c27c6f81f7..1684a4242d160f5536c30ffef2a3acffa258cc4f 100644
index fbe4c0f06c10df7c8a492711594381c27c6f81f7..76c8c037ffd3c8b67179d7d881ad6ea530b00686 100644
--- a/src/crypto/crypto_util.cc
+++ b/src/crypto/crypto_util.cc
@@ -61,6 +61,7 @@ int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) {
}

void CheckEntropy() {
+#ifndef OPENSSL_IS_BORINGSSL
for (;;) {
int status = RAND_status();
CHECK_GE(status, 0); // Cannot fail.
@@ -71,15 +72,20 @@ void CheckEntropy() {
if (RAND_poll() == 0)
break;
}
+#endif
}
@@ -20,6 +20,8 @@
#endif
#endif

bool EntropySource(unsigned char* buffer, size_t length) {
+#ifndef OPENSSL_IS_BORINGSSL
// Ensure that OpenSSL's PRNG is properly seeded.
CheckEntropy();
// RAND_bytes() can return 0 to indicate that the entropy data is not truly
// random. That's okay, it's still better than V8's stock source of entropy,
// which is /dev/urandom on UNIX platforms and the current time on Windows.
return RAND_bytes(buffer, length) != -1;
+#else
+ return false;
+#endif
}
+#include <openssl/rand.h>
+
namespace node {

int PasswordCallback(char* buf, int size, int rwflag, void* u) {
@@ -118,7 +124,6 @@ void InitCryptoOnce() {
using v8::ArrayBuffer;
@@ -118,7 +120,6 @@ void InitCryptoOnce() {
OPENSSL_init_ssl(0, settings);
OPENSSL_INIT_free(settings);
settings = nullptr;
-#endif

#ifndef _WIN32
if (per_process::cli_options->secure_heap != 0) {
@@ -137,6 +142,7 @@ void InitCryptoOnce() {
@@ -137,6 +138,7 @@ void InitCryptoOnce() {
break;
}
}
+#endif
#endif

/* Override FIPS settings in cnf file, if needed. */
@@ -675,10 +681,12 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
@@ -675,10 +677,12 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
}

void SecureHeapUsed(const FunctionCallbackInfo<Value>& args) {
Expand Down

0 comments on commit a3236a5

Please sign in to comment.