Skip to content

Commit a3f30a4

Browse files
committed
src: unify crypto constant setup
DefineCryptoConstants() sets constants from OpenSSL into `crypto.constants`, for crypto and tls. DefineOpenSSLConstants() did exactly the same. Unify them. PR-URL: #27077 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0911e88 commit a3f30a4

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

src/node_constants.cc

+32-20
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ void DefinePriorityConstants(Local<Object> target) {
795795
#endif
796796
}
797797

798-
void DefineOpenSSLConstants(Local<Object> target) {
798+
void DefineCryptoConstants(Local<Object> target) {
799799
#ifdef OPENSSL_VERSION_NUMBER
800800
NODE_DEFINE_CONSTANT(target, OPENSSL_VERSION_NUMBER);
801801
#endif
@@ -1041,13 +1041,44 @@ void DefineOpenSSLConstants(Local<Object> target) {
10411041
NODE_DEFINE_CONSTANT(target, RSA_PSS_SALTLEN_AUTO);
10421042
#endif
10431043

1044+
#ifdef DEFAULT_CIPHER_LIST_CORE
1045+
NODE_DEFINE_STRING_CONSTANT(target,
1046+
"defaultCoreCipherList",
1047+
DEFAULT_CIPHER_LIST_CORE);
1048+
#endif
1049+
1050+
#ifdef TLS1_VERSION
1051+
NODE_DEFINE_CONSTANT(target, TLS1_VERSION);
1052+
#endif
1053+
1054+
#ifdef TLS1_1_VERSION
1055+
NODE_DEFINE_CONSTANT(target, TLS1_1_VERSION);
1056+
#endif
1057+
1058+
#ifdef TLS1_2_VERSION
1059+
NODE_DEFINE_CONSTANT(target, TLS1_2_VERSION);
1060+
#endif
1061+
1062+
#ifdef TLS1_3_VERSION
1063+
NODE_DEFINE_CONSTANT(target, TLS1_3_VERSION);
1064+
#endif
1065+
1066+
// Unused by node, but removing it is semver-major.
1067+
NODE_DEFINE_CONSTANT(target, INT_MAX);
1068+
10441069
#if HAVE_OPENSSL
10451070
// NOTE: These are not defines
10461071
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_COMPRESSED);
10471072

10481073
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_UNCOMPRESSED);
10491074

10501075
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_HYBRID);
1076+
1077+
NODE_DEFINE_STRING_CONSTANT(
1078+
target,
1079+
"defaultCipherList",
1080+
per_process::cli_options->tls_cipher_list.c_str());
1081+
10511082
#endif
10521083
}
10531084

@@ -1232,24 +1263,6 @@ void DefineSystemConstants(Local<Object> target) {
12321263
#endif
12331264
}
12341265

1235-
void DefineCryptoConstants(Local<Object> target) {
1236-
#if HAVE_OPENSSL
1237-
NODE_DEFINE_STRING_CONSTANT(target,
1238-
"defaultCoreCipherList",
1239-
DEFAULT_CIPHER_LIST_CORE);
1240-
NODE_DEFINE_STRING_CONSTANT(
1241-
target,
1242-
"defaultCipherList",
1243-
per_process::cli_options->tls_cipher_list.c_str());
1244-
1245-
NODE_DEFINE_CONSTANT(target, TLS1_VERSION);
1246-
NODE_DEFINE_CONSTANT(target, TLS1_1_VERSION);
1247-
NODE_DEFINE_CONSTANT(target, TLS1_2_VERSION);
1248-
NODE_DEFINE_CONSTANT(target, TLS1_3_VERSION);
1249-
#endif
1250-
NODE_DEFINE_CONSTANT(target, INT_MAX);
1251-
}
1252-
12531266
void DefineDLOpenConstants(Local<Object> target) {
12541267
#ifdef RTLD_LAZY
12551268
NODE_DEFINE_CONSTANT(target, RTLD_LAZY);
@@ -1347,7 +1360,6 @@ void DefineConstants(v8::Isolate* isolate, Local<Object> target) {
13471360
DefineSignalConstants(sig_constants);
13481361
DefinePriorityConstants(priority_constants);
13491362
DefineSystemConstants(fs_constants);
1350-
DefineOpenSSLConstants(crypto_constants);
13511363
DefineCryptoConstants(crypto_constants);
13521364
DefineZlibConstants(zlib_constants);
13531365
DefineDLOpenConstants(dlopen_constants);

0 commit comments

Comments
 (0)