@@ -53,7 +53,7 @@ index fe35a8e0f6bbb7ab515a0343a7ed046c44e86474..43a7abbf237d8d809953e302b83755a3
53
53
54
54
const EVP_MD* digest = nullptr;
55
55
diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc
56
- index 6a967702b22df0eb8aa10e853fd232794955860d..b5631ed9d55339705a9b52dad66ac4a884df5f31 100644
56
+ index 6a967702b22df0eb8aa10e853fd232794955860d..31058cccc6ffeed6b09aaecda320ee2f15849ec8 100644
57
57
--- a/src/crypto/crypto_common.cc
58
58
+++ b/src/crypto/crypto_common.cc
59
59
@@ -134,7 +134,7 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) {
@@ -91,6 +91,24 @@ index 6a967702b22df0eb8aa10e853fd232794955860d..b5631ed9d55339705a9b52dad66ac4a8
91
91
}
92
92
93
93
const char* GetServerName(SSL* ssl) {
94
+ @@ -282,7 +286,7 @@ StackOfX509 CloneSSLCerts(X509Pointer&& cert,
95
+ if (!peer_certs) return StackOfX509();
96
+ if (cert && !sk_X509_push(peer_certs.get(), cert.release()))
97
+ return StackOfX509();
98
+ - for (int i = 0; i < sk_X509_num(ssl_certs); i++) {
99
+ + for (size_t i = 0; i < sk_X509_num(ssl_certs); i++) {
100
+ X509Pointer cert(X509_dup(sk_X509_value(ssl_certs, i)));
101
+ if (!cert || !sk_X509_push(peer_certs.get(), cert.get()))
102
+ return StackOfX509();
103
+ @@ -298,7 +302,7 @@ MaybeLocal<Object> AddIssuerChainToObject(X509Pointer* cert,
104
+ Environment* const env) {
105
+ cert->reset(sk_X509_delete(peer_certs.get(), 0));
106
+ for (;;) {
107
+ - int i;
108
+ + size_t i;
109
+ for (i = 0; i < sk_X509_num(peer_certs.get()); i++) {
110
+ ncrypto::X509View ca(sk_X509_value(peer_certs.get(), i));
111
+ if (!cert->view().isIssuedBy(ca)) continue;
94
112
@@ -384,14 +388,14 @@ MaybeLocal<Array> GetClientHelloCiphers(
95
113
Environment* env,
96
114
const SSLPointer& ssl) {
@@ -124,7 +142,7 @@ index 6a967702b22df0eb8aa10e853fd232794955860d..b5631ed9d55339705a9b52dad66ac4a8
124
142
crypto::EVPKeyPointer key(raw_key);
125
143
126
144
diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
127
- index c924a54639e8c22d765dc240dffacfffb200ca0c..661e8a13c9245f76441414982dc4a996f4896a81 100644
145
+ index c924a54639e8c22d765dc240dffacfffb200ca0c..94fd301b9dc81aa86f41151417f67e7dbe2f3e4f 100644
128
146
--- a/src/crypto/crypto_context.cc
129
147
+++ b/src/crypto/crypto_context.cc
130
148
@@ -64,7 +64,7 @@ X509_STORE* GetOrCreateRootCertStore() {
@@ -136,6 +154,15 @@ index c924a54639e8c22d765dc240dffacfffb200ca0c..661e8a13c9245f76441414982dc4a996
136
154
if (!bio) return {};
137
155
ByteSource bsrc = ByteSource::FromStringOrBuffer(env, v);
138
156
if (bsrc.size() > INT_MAX) return {};
157
+ @@ -94,7 +94,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
158
+ // the CA certificates.
159
+ SSL_CTX_clear_extra_chain_certs(ctx);
160
+
161
+ - for (int i = 0; i < sk_X509_num(extra_certs); i++) {
162
+ + for (size_t i = 0; i < sk_X509_num(extra_certs); i++) {
163
+ X509* ca = sk_X509_value(extra_certs, i);
164
+
165
+ // NOTE: Increments reference count on `ca`
139
166
@@ -920,11 +920,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
140
167
// If the user specified "auto" for dhparams, the JavaScript layer will pass
141
168
// true to this function instead of the original string. Any other string
@@ -150,11 +177,30 @@ index c924a54639e8c22d765dc240dffacfffb200ca0c..661e8a13c9245f76441414982dc4a996
150
177
DHPointer dh;
151
178
{
152
179
BIOPointer bio(LoadBIO(env, args[0]));
180
+ @@ -1150,7 +1151,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
181
+ }
182
+
183
+ // Add CA certs too
184
+ - for (int i = 0; i < sk_X509_num(extra_certs.get()); i++) {
185
+ + for (size_t i = 0; i < sk_X509_num(extra_certs.get()); i++) {
186
+ X509* ca = sk_X509_value(extra_certs.get(), i);
187
+
188
+ X509_STORE_add_cert(sc->GetCertStoreOwnedByThisSecureContext(), ca);
153
189
diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc
154
- index e5664dfa2bc7e11922fa965f28acdf21470d1147..d8df6b46013ed8177270648e89b5f9ce6bf548f2 100644
190
+ index e5664dfa2bc7e11922fa965f28acdf21470d1147..c9e32ee754cec137f3e7673956e6af1360cb767f 100644
155
191
--- a/src/crypto/crypto_dh.cc
156
192
+++ b/src/crypto/crypto_dh.cc
157
- @@ -86,11 +86,7 @@ void New(const FunctionCallbackInfo<Value>& args) {
193
+ @@ -7,7 +7,9 @@
194
+ #include "memory_tracker-inl.h"
195
+ #include "ncrypto.h"
196
+ #include "node_errors.h"
197
+ + #ifndef OPENSSL_IS_BORINGSSL
198
+ #include "openssl/bnerr.h"
199
+ + #endif
200
+ #include "openssl/dh.h"
201
+ #include "threadpoolwork-inl.h"
202
+ #include "v8.h"
203
+ @@ -86,11 +88,7 @@ void New(const FunctionCallbackInfo<Value>& args) {
158
204
if (args[0]->IsInt32()) {
159
205
int32_t bits = args[0].As<Int32>()->Value();
160
206
if (bits < 2) {
@@ -167,7 +213,7 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..d8df6b46013ed8177270648e89b5f9ce
167
213
return ThrowCryptoError(env, ERR_get_error(), "Invalid prime length");
168
214
}
169
215
170
- @@ -103,7 +99 ,7 @@ void New(const FunctionCallbackInfo<Value>& args) {
216
+ @@ -103,7 +101 ,7 @@ void New(const FunctionCallbackInfo<Value>& args) {
171
217
}
172
218
int32_t generator = args[1].As<Int32>()->Value();
173
219
if (generator < 2) {
@@ -176,7 +222,7 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..d8df6b46013ed8177270648e89b5f9ce
176
222
return ThrowCryptoError(env, ERR_get_error(), "Invalid generator");
177
223
}
178
224
179
- @@ -132,12 +128 ,12 @@ void New(const FunctionCallbackInfo<Value>& args) {
225
+ @@ -132,12 +130 ,12 @@ void New(const FunctionCallbackInfo<Value>& args) {
180
226
if (args[1]->IsInt32()) {
181
227
int32_t generator = args[1].As<Int32>()->Value();
182
228
if (generator < 2) {
@@ -191,7 +237,7 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..d8df6b46013ed8177270648e89b5f9ce
191
237
return ThrowCryptoError(env, ERR_get_error(), "Invalid generator");
192
238
}
193
239
} else {
194
- @@ -146,11 +142 ,11 @@ void New(const FunctionCallbackInfo<Value>& args) {
240
+ @@ -146,11 +144 ,11 @@ void New(const FunctionCallbackInfo<Value>& args) {
195
241
return THROW_ERR_OUT_OF_RANGE(env, "generator is too big");
196
242
bn_g = BignumPointer(reinterpret_cast<uint8_t*>(arg1.data()), arg1.size());
197
243
if (!bn_g) {
@@ -205,7 +251,25 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..d8df6b46013ed8177270648e89b5f9ce
205
251
return ThrowCryptoError(env, ERR_get_error(), "Invalid generator");
206
252
}
207
253
}
208
- @@ -398,9 +394,11 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
254
+ @@ -258,15 +256,15 @@ void ComputeSecret(const FunctionCallbackInfo<Value>& args) {
255
+ BignumPointer key(key_buf.data(), key_buf.size());
256
+
257
+ switch (dh.checkPublicKey(key)) {
258
+ - case DHPointer::CheckPublicKeyResult::INVALID:
259
+ - // Fall-through
260
+ case DHPointer::CheckPublicKeyResult::CHECK_FAILED:
261
+ return THROW_ERR_CRYPTO_INVALID_KEYTYPE(env,
262
+ "Unspecified validation error");
263
+ + #ifndef OPENSSL_IS_BORINGSSL
264
+ case DHPointer::CheckPublicKeyResult::TOO_SMALL:
265
+ return THROW_ERR_CRYPTO_INVALID_KEYLEN(env, "Supplied key is too small");
266
+ case DHPointer::CheckPublicKeyResult::TOO_LARGE:
267
+ return THROW_ERR_CRYPTO_INVALID_KEYLEN(env, "Supplied key is too large");
268
+ + #endif
269
+ case DHPointer::CheckPublicKeyResult::NONE:
270
+ break;
271
+ }
272
+ @@ -398,9 +396,11 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
209
273
key_params = EVPKeyPointer(EVP_PKEY_new());
210
274
CHECK(key_params);
211
275
CHECK_EQ(EVP_PKEY_assign_DH(key_params.get(), dh.release()), 1);
@@ -218,7 +282,7 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..d8df6b46013ed8177270648e89b5f9ce
218
282
if (!param_ctx ||
219
283
EVP_PKEY_paramgen_init(param_ctx.get()) <= 0 ||
220
284
EVP_PKEY_CTX_set_dh_paramgen_prime_len(
221
- @@ -414,6 +412 ,9 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
285
+ @@ -414,6 +414 ,9 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
222
286
}
223
287
224
288
key_params = EVPKeyPointer(raw_params);
0 commit comments