Skip to content

Commit ecc7511

Browse files
committed
crypto: implement randomuuid
nodejs/node#36729
1 parent d9d12f7 commit ecc7511

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

patches/node/fix_comment_out_incompatible_crypto_modules.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ with what's exposed through BoringSSL. I plan to upstream parts of this or
99
otherwise introduce shims to reduce friction.
1010

1111
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
12-
index c0baf86802a67f00830c81d325f448bcea7d4e40..c2fd0f94eeb1aeaecdb18e80268ef1fb84c5c8c2 100644
12+
index c119b2314f18d1710bb3cbf1910c86ff994ec951..58554799b50097972405e40f593d089236bca961 100644
1313
--- a/src/node_crypto.cc
1414
+++ b/src/node_crypto.cc
1515
@@ -5207,11 +5207,11 @@ bool DiffieHellman::Init(int primeLength, int g) {

patches/node/fix_use_crypto_impls_for_compat.patch

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ From: Shelley Vohr <[email protected]>
33
Date: Wed, 12 Feb 2020 15:08:04 -0800
44
Subject: fix: use crypto impls for compat
55

6-
BoringSSL does not export DSA_get0_q. This patch works around that problem
7-
by using the implementations of those functions as found in the OpenSSL repo.
8-
I plan to try and upstream a version of this.
6+
BoringSSL does not export DSA_get0_q, OPENSSL_secure_malloc, or
7+
OPENSSL_secure_clear_free.
8+
9+
This patch works around the DSA_get0_q problem by using the
10+
implementations of that function as found in the OpenSSL repo.
11+
12+
Node.js added the malloc/free incompatibilities in https://github.com/nodejs/node/pull/36729
13+
though they don't use secure heap at the moment. This makes it equivalent
14+
to swap these out with OPENSSL_malloc and OPENSSL_clear_free at present.
15+
We can revisit this once that happens and determine a more mutually
16+
compatible path forward either by upstreaming a shim to BoringSSL or
17+
adapting Node.js.
918

1019
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
11-
index 79e781fb3e6ec63334c2c5d4b24d2a6049be79fc..c0baf86802a67f00830c81d325f448bcea7d4e40 100644
20+
index 79e781fb3e6ec63334c2c5d4b24d2a6049be79fc..c119b2314f18d1710bb3cbf1910c86ff994ec951 100644
1221
--- a/src/node_crypto.cc
1322
+++ b/src/node_crypto.cc
1423
@@ -4574,7 +4574,7 @@ static unsigned int GetBytesOfRS(const ManagedEVPPKey& pkey) {
@@ -20,3 +29,21 @@ index 79e781fb3e6ec63334c2c5d4b24d2a6049be79fc..c0baf86802a67f00830c81d325f448bc
2029
} else if (base_id == EVP_PKEY_EC) {
2130
EC_KEY* ec_key = EVP_PKEY_get0_EC_KEY(pkey.get());
2231
const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key);
32+
@@ -6949,7 +6949,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
33+
CHECK(args[0]->IsUint32());
34+
Environment* env = Environment::GetCurrent(args);
35+
uint32_t len = args[0].As<Uint32>()->Value();
36+
- char* data = static_cast<char*>(OPENSSL_secure_malloc(len));
37+
+ char* data = static_cast<char*>(OPENSSL_malloc(len));
38+
if (data == nullptr) {
39+
// There's no memory available for the allocation.
40+
// Return nothing.
41+
@@ -6961,7 +6961,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
42+
data,
43+
len,
44+
[](void* data, size_t len, void* deleter_data) {
45+
- OPENSSL_secure_clear_free(data, len);
46+
+ OPENSSL_clear_free(data, len);
47+
},
48+
data);
49+
Local<ArrayBuffer> buffer = ArrayBuffer::New(env->isolate(), store);

0 commit comments

Comments
 (0)