Skip to content

Commit

Permalink
src: unify crypto constant setup
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sam-github committed Apr 8, 2019
1 parent 0911e88 commit a3f30a4
Showing 1 changed file with 32 additions and 20 deletions.
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

0 comments on commit a3f30a4

Please sign in to comment.