Skip to content

crypto: expose crypto.constants.OPENSSL_IS_BORINGSSL #58387

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ ObjectDefineProperty(process, 'allowedNodeEnvironmentFlags', {

// TODO(joyeecheung): this property has not been well-maintained, should we
// deprecate it in favor of a better API?
const { isDebugBuild, hasOpenSSL, hasInspector } = config;
const { isDebugBuild, hasOpenSSL, openSSLIsBoringSSL, hasInspector } = config;
const features = {
inspector: hasInspector,
debug: isDebugBuild,
Expand All @@ -276,6 +276,7 @@ const features = {
tls_sni: hasOpenSSL,
tls_ocsp: hasOpenSSL,
tls: hasOpenSSL,
openssl_is_boringssl: openSSLIsBoringSSL,
// This needs to be dynamic because --no-node-snapshot disables the
// code cache even if the binary is built with embedded code cache.
get cached_builtins() {
Expand Down
6 changes: 6 additions & 0 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static void InitConfig(Local<Object> target,
READONLY_FALSE_PROPERTY(target, "isDebugBuild");
#endif // defined(DEBUG) && DEBUG

#ifdef OPENSSL_IS_BORINGSSL
READONLY_TRUE_PROPERTY(target, "openSSLIsBoringSSL");
#else
READONLY_FALSE_PROPERTY(target, "openSSLIsBoringSSL");
#endif // OPENSSL_IS_BORINGSSL

#if HAVE_OPENSSL
READONLY_TRUE_PROPERTY(target, "hasOpenSSL");
#else
Expand Down
12 changes: 8 additions & 4 deletions test/parallel/test-crypto-getcipherinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ assert(getCipherInfo('aes-128-cbc', { ivLength: 16 }));

assert(!getCipherInfo('aes-128-ccm', { ivLength: 1 }));
assert(!getCipherInfo('aes-128-ccm', { ivLength: 14 }));
for (let n = 7; n <= 13; n++)
assert(getCipherInfo('aes-128-ccm', { ivLength: n }));
if (!process.features.openssl_is_boringssl) {
for (let n = 7; n <= 13; n++)
assert(getCipherInfo('aes-128-ccm', { ivLength: n }));
}

assert(!getCipherInfo('aes-128-ocb', { ivLength: 16 }));
for (let n = 1; n < 16; n++)
assert(getCipherInfo('aes-128-ocb', { ivLength: n }));
if (!process.features.openssl_is_boringssl) {
for (let n = 1; n < 16; n++)
assert(getCipherInfo('aes-128-ocb', { ivLength: n }));
}
2 changes: 1 addition & 1 deletion test/parallel/test-crypto-hkdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const algorithms = [
['sha256', '', 'salt', '', 10],
['sha512', 'secret', 'salt', '', 15],
];
if (!hasOpenSSL3)
if (!hasOpenSSL3 && !process.features.openssl_is_boringssl)
algorithms.push(['whirlpool', 'secret', '', 'info', 20]);

algorithms.forEach(([ hash, secret, salt, info, length ]) => {
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-tls-getprotocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ const clientConfigs = [

const serverConfig = {
secureProtocol: 'TLS_method',
ciphers: 'RSA@SECLEVEL=0',
key: fixtures.readKey('agent2-key.pem'),
cert: fixtures.readKey('agent2-cert.pem')
};

if (!process.features.openssl_is_boringssl) {
serverConfig.ciphers = 'RSA@SECLEVEL=0';
}

const server = tls.createServer(serverConfig, common.mustCall(clientConfigs.length))
.listen(0, common.localhostIPv4, function() {
let connected = 0;
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-tls-write-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ const server_cert = fixtures.readKey('agent1-cert.pem');
const opts = {
key: server_key,
cert: server_cert,
ciphers: 'ALL@SECLEVEL=0'
};

if (!process.features.openssl_is_boringssl) {
opts.ciphers = 'ALL@SECLEVEL=0';
}

const server = https.createServer(opts, (req, res) => {
res.write('hello');
}).listen(0, common.mustCall(() => {
Expand Down
Loading