Skip to content

Commit c80b6bd

Browse files
committed
crypto: expose crypto.constants.OPENSSL_IS_BORINGSSL
1 parent 4edb139 commit c80b6bd

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

lib/internal/bootstrap/node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ObjectDefineProperty(process, 'allowedNodeEnvironmentFlags', {
266266

267267
// TODO(joyeecheung): this property has not been well-maintained, should we
268268
// deprecate it in favor of a better API?
269-
const { isDebugBuild, hasOpenSSL, hasInspector } = config;
269+
const { isDebugBuild, hasOpenSSL, openSSLIsBoringSSL, hasInspector } = config;
270270
const features = {
271271
inspector: hasInspector,
272272
debug: isDebugBuild,
@@ -276,6 +276,7 @@ const features = {
276276
tls_sni: hasOpenSSL,
277277
tls_ocsp: hasOpenSSL,
278278
tls: hasOpenSSL,
279+
openssl_is_boringssl: openSSLIsBoringSSL,
279280
// This needs to be dynamic because --no-node-snapshot disables the
280281
// code cache even if the binary is built with embedded code cache.
281282
get cached_builtins() {

src/node_config.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ static void InitConfig(Local<Object> target,
4848
READONLY_FALSE_PROPERTY(target, "isDebugBuild");
4949
#endif // defined(DEBUG) && DEBUG
5050

51+
#ifdef OPENSSL_IS_BORINGSSL
52+
READONLY_TRUE_PROPERTY(target, "openSSLIsBoringSSL");
53+
#else
54+
READONLY_FALSE_PROPERTY(target, "openSSLIsBoringSSL");
55+
#endif // OPENSSL_IS_BORINGSSL
56+
5157
#if HAVE_OPENSSL
5258
READONLY_TRUE_PROPERTY(target, "hasOpenSSL");
5359
#else

test/parallel/test-crypto-getcipherinfo.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ assert(getCipherInfo('aes-128-cbc', { ivLength: 16 }));
6262

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

6870
assert(!getCipherInfo('aes-128-ocb', { ivLength: 16 }));
69-
for (let n = 1; n < 16; n++)
70-
assert(getCipherInfo('aes-128-ocb', { ivLength: n }));
71+
if (!process.features.openssl_is_boringssl) {
72+
for (let n = 1; n < 16; n++)
73+
assert(getCipherInfo('aes-128-ocb', { ivLength: n }));
74+
}

test/parallel/test-crypto-hkdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const algorithms = [
125125
['sha256', '', 'salt', '', 10],
126126
['sha512', 'secret', 'salt', '', 15],
127127
];
128-
if (!hasOpenSSL3)
128+
if (!hasOpenSSL3 && !process.features.openssl_is_boringssl)
129129
algorithms.push(['whirlpool', 'secret', '', 'info', 20]);
130130

131131
algorithms.forEach(([ hash, secret, salt, info, length ]) => {

test/parallel/test-tls-getprotocol.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ const clientConfigs = [
2929

3030
const serverConfig = {
3131
secureProtocol: 'TLS_method',
32-
ciphers: 'RSA@SECLEVEL=0',
3332
key: fixtures.readKey('agent2-key.pem'),
3433
cert: fixtures.readKey('agent2-cert.pem')
3534
};
3635

36+
if (!process.features.openssl_is_boringssl) {
37+
serverConfig.ciphers = 'RSA@SECLEVEL=0';
38+
}
39+
3740
const server = tls.createServer(serverConfig, common.mustCall(clientConfigs.length))
3841
.listen(0, common.localhostIPv4, function() {
3942
let connected = 0;

test/parallel/test-tls-write-error.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ const server_cert = fixtures.readKey('agent1-cert.pem');
1717
const opts = {
1818
key: server_key,
1919
cert: server_cert,
20-
ciphers: 'ALL@SECLEVEL=0'
2120
};
2221

22+
if (!process.features.openssl_is_boringssl) {
23+
opts.ciphers = 'ALL@SECLEVEL=0';
24+
}
25+
2326
const server = https.createServer(opts, (req, res) => {
2427
res.write('hello');
2528
}).listen(0, common.mustCall(() => {

0 commit comments

Comments
 (0)