Skip to content

Commit a5ab59d

Browse files
committed
src: move more crypto impl detail to ncrypto dep
nodejs/node#56421
1 parent c708f67 commit a5ab59d

File tree

1 file changed

+8
-74
lines changed

1 file changed

+8
-74
lines changed

patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ index 245a43920c7baf000ba63192a84a4c3fd219be7d..56a554175b805c1703f13d62041f8c80
147147
# The location of simdutf - use the one from node's deps by default.
148148
node_simdutf_path = "$node_path/deps/simdutf"
149149
diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc
150-
index c7588583530cf291946d01cec807390d987706cf..495fb92355a7eadc2f7ec885a3b529988bb3bd02 100644
150+
index 1754d1f71b8adbcb584bfe4606e2a341836fb671..ac0f529e75c30add0708dc20470846f2f56e4b86 100644
151151
--- a/src/crypto/crypto_cipher.cc
152152
+++ b/src/crypto/crypto_cipher.cc
153-
@@ -1080,7 +1080,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
153+
@@ -1033,7 +1033,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
154154
if (EVP_PKEY_decrypt_init(ctx.get()) <= 0) {
155155
return ThrowCryptoError(env, ERR_get_error());
156156
}
@@ -159,7 +159,7 @@ index c7588583530cf291946d01cec807390d987706cf..495fb92355a7eadc2f7ec885a3b52998
159159
int rsa_pkcs1_implicit_rejection =
160160
EVP_PKEY_CTX_ctrl_str(ctx.get(), "rsa_pkcs1_implicit_rejection", "1");
161161
// From the doc -2 means that the option is not supported.
162-
@@ -1095,6 +1095,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
162+
@@ -1048,6 +1048,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
163163
env,
164164
"RSA_PKCS1_PADDING is no longer supported for private decryption");
165165
}
@@ -168,45 +168,10 @@ index c7588583530cf291946d01cec807390d987706cf..495fb92355a7eadc2f7ec885a3b52998
168168

169169
const EVP_MD* digest = nullptr;
170170
diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc
171-
index 43a126f863779d3f364f92bd237039474b489845..77a3caee93049f65faef37e93b871c467ebca7e5 100644
171+
index d94f6e1c82c4a62547b3b395f375c86ce4deb5de..b81b9005365272217c77e2b9289bd9f877c0e77c 100644
172172
--- a/src/crypto/crypto_common.cc
173173
+++ b/src/crypto/crypto_common.cc
174-
@@ -134,7 +134,7 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) {
175-
const unsigned char* buf;
176-
size_t len;
177-
size_t rem;
178-
-
179-
+#ifndef OPENSSL_IS_BORINGSSL
180-
if (!SSL_client_hello_get0_ext(
181-
ssl.get(),
182-
TLSEXT_TYPE_application_layer_protocol_negotiation,
183-
@@ -147,13 +147,15 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) {
184-
len = (buf[0] << 8) | buf[1];
185-
if (len + 2 != rem) return nullptr;
186-
return reinterpret_cast<const char*>(buf + 3);
187-
+#endif
188-
+ return nullptr;
189-
}
190-
191-
const char* GetClientHelloServerName(const SSLPointer& ssl) {
192-
const unsigned char* buf;
193-
size_t len;
194-
size_t rem;
195-
-
196-
+#ifndef OPENSSL_IS_BORINGSSL
197-
if (!SSL_client_hello_get0_ext(
198-
ssl.get(),
199-
TLSEXT_TYPE_server_name,
200-
@@ -175,6 +177,8 @@ const char* GetClientHelloServerName(const SSLPointer& ssl) {
201-
if (len + 2 > rem)
202-
return nullptr;
203-
return reinterpret_cast<const char*>(buf + 5);
204-
+#endif
205-
+ return nullptr;
206-
}
207-
208-
const char* GetServerName(SSL* ssl) {
209-
@@ -282,7 +286,7 @@ StackOfX509 CloneSSLCerts(X509Pointer&& cert,
174+
@@ -124,7 +124,7 @@ StackOfX509 CloneSSLCerts(X509Pointer&& cert,
210175
if (!peer_certs) return StackOfX509();
211176
if (cert && !sk_X509_push(peer_certs.get(), cert.release()))
212177
return StackOfX509();
@@ -215,47 +180,16 @@ index 43a126f863779d3f364f92bd237039474b489845..77a3caee93049f65faef37e93b871c46
215180
X509Pointer cert(X509_dup(sk_X509_value(ssl_certs, i)));
216181
if (!cert || !sk_X509_push(peer_certs.get(), cert.get()))
217182
return StackOfX509();
218-
@@ -298,7 +302,7 @@ MaybeLocal<Object> AddIssuerChainToObject(X509Pointer* cert,
183+
@@ -140,7 +140,7 @@ MaybeLocal<Object> AddIssuerChainToObject(X509Pointer* cert,
219184
Environment* const env) {
220185
cert->reset(sk_X509_delete(peer_certs.get(), 0));
221186
for (;;) {
222187
- int i;
223188
+ size_t i;
224189
for (i = 0; i < sk_X509_num(peer_certs.get()); i++) {
225-
ncrypto::X509View ca(sk_X509_value(peer_certs.get(), i));
190+
X509View ca(sk_X509_value(peer_certs.get(), i));
226191
if (!cert->view().isIssuedBy(ca)) continue;
227-
@@ -384,14 +388,14 @@ MaybeLocal<Array> GetClientHelloCiphers(
228-
Environment* env,
229-
const SSLPointer& ssl) {
230-
EscapableHandleScope scope(env->isolate());
231-
- const unsigned char* buf;
232-
- size_t len = SSL_client_hello_get0_ciphers(ssl.get(), &buf);
233-
+ // const unsigned char* buf = nullptr;
234-
+ size_t len = 0; // SSL_client_hello_get0_ciphers(ssl.get(), &buf);
235-
size_t count = len / 2;
236-
MaybeStackBuffer<Local<Value>, 16> ciphers(count);
237-
int j = 0;
238-
for (size_t n = 0; n < len; n += 2) {
239-
- const SSL_CIPHER* cipher = SSL_CIPHER_find(ssl.get(), buf);
240-
- buf += 2;
241-
+ const SSL_CIPHER* cipher = nullptr; // SSL_CIPHER_find(ssl.get(), buf);
242-
+ // buf += 2;
243-
Local<Object> obj = Object::New(env->isolate());
244-
if (!Set(env->context(),
245-
obj,
246-
@@ -444,8 +448,11 @@ MaybeLocal<Object> GetEphemeralKey(Environment* env, const SSLPointer& ssl) {
247-
248-
EscapableHandleScope scope(env->isolate());
249-
Local<Object> info = Object::New(env->isolate());
250-
+#ifndef OPENSSL_IS_BORINGSSL
251-
if (!SSL_get_peer_tmp_key(ssl.get(), &raw_key)) return scope.Escape(info);
252-
-
253-
+#else
254-
+ if (!SSL_get_server_tmp_key(ssl.get(), &raw_key)) return scope.Escape(info);
255-
+#endif
256-
Local<Context> context = env->context();
257-
crypto::EVPKeyPointer key(raw_key);
258-
192+
259193
diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
260194
index aa5fc61f19e435b4833f3f49df10fa1edf2142c7..0a338b018a4ec20cb5bce250faf60d3f3bf192d4 100644
261195
--- a/src/crypto/crypto_context.cc

0 commit comments

Comments
 (0)