Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: unify crypto constant setup #27077

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions src/node_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ void DefinePriorityConstants(Local<Object> target) {
#endif
}

void DefineOpenSSLConstants(Local<Object> target) {
void DefineCryptoConstants(Local<Object> target) {
#ifdef OPENSSL_VERSION_NUMBER
NODE_DEFINE_CONSTANT(target, OPENSSL_VERSION_NUMBER);
#endif
Expand Down Expand Up @@ -1041,13 +1041,44 @@ void DefineOpenSSLConstants(Local<Object> target) {
NODE_DEFINE_CONSTANT(target, RSA_PSS_SALTLEN_AUTO);
#endif

#ifdef DEFAULT_CIPHER_LIST_CORE
NODE_DEFINE_STRING_CONSTANT(target,
"defaultCoreCipherList",
DEFAULT_CIPHER_LIST_CORE);
#endif

#ifdef TLS1_VERSION
NODE_DEFINE_CONSTANT(target, TLS1_VERSION);
#endif

#ifdef TLS1_1_VERSION
NODE_DEFINE_CONSTANT(target, TLS1_1_VERSION);
#endif

#ifdef TLS1_2_VERSION
NODE_DEFINE_CONSTANT(target, TLS1_2_VERSION);
#endif

#ifdef TLS1_3_VERSION
NODE_DEFINE_CONSTANT(target, TLS1_3_VERSION);
#endif

// Unused by node, but removing it is semver-major.
NODE_DEFINE_CONSTANT(target, INT_MAX);

#if HAVE_OPENSSL
// NOTE: These are not defines
NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_COMPRESSED);

NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_UNCOMPRESSED);

NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_HYBRID);

NODE_DEFINE_STRING_CONSTANT(
target,
"defaultCipherList",
per_process::cli_options->tls_cipher_list.c_str());

#endif
}

Expand Down Expand Up @@ -1232,24 +1263,6 @@ void DefineSystemConstants(Local<Object> target) {
#endif
}

void DefineCryptoConstants(Local<Object> target) {
#if HAVE_OPENSSL
NODE_DEFINE_STRING_CONSTANT(target,
"defaultCoreCipherList",
DEFAULT_CIPHER_LIST_CORE);
NODE_DEFINE_STRING_CONSTANT(
target,
"defaultCipherList",
per_process::cli_options->tls_cipher_list.c_str());

NODE_DEFINE_CONSTANT(target, TLS1_VERSION);
NODE_DEFINE_CONSTANT(target, TLS1_1_VERSION);
NODE_DEFINE_CONSTANT(target, TLS1_2_VERSION);
NODE_DEFINE_CONSTANT(target, TLS1_3_VERSION);
#endif
NODE_DEFINE_CONSTANT(target, INT_MAX);
}

void DefineDLOpenConstants(Local<Object> target) {
#ifdef RTLD_LAZY
NODE_DEFINE_CONSTANT(target, RTLD_LAZY);
Expand Down Expand Up @@ -1347,7 +1360,6 @@ void DefineConstants(v8::Isolate* isolate, Local<Object> target) {
DefineSignalConstants(sig_constants);
DefinePriorityConstants(priority_constants);
DefineSystemConstants(fs_constants);
DefineOpenSSLConstants(crypto_constants);
DefineCryptoConstants(crypto_constants);
DefineZlibConstants(zlib_constants);
DefineDLOpenConstants(dlopen_constants);
Expand Down