Skip to content

Commit 9fccb06

Browse files
codebyteretargos
authored andcommitted
crypto: expose crypto.constants.OPENSSL_IS_BORINGSSL
PR-URL: #58387 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 3499285 commit 9fccb06

7 files changed

Lines changed: 26 additions & 8 deletions

File tree

‎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
constfeatures={
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
getcached_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(letn=7;n<=13;n++)
66-
assert(getCipherInfo('aes-128-ccm',{ivLength: n}));
65+
if(!process.features.openssl_is_boringssl){
66+
for(letn=7;n<=13;n++)
67+
assert(getCipherInfo('aes-128-ccm',{ivLength: n}));
68+
}
6769

6870
assert(!getCipherInfo('aes-128-ocb',{ivLength: 16}));
69-
for(letn=1;n<16;n++)
70-
assert(getCipherInfo('aes-128-ocb',{ivLength: n}));
71+
if(!process.features.openssl_is_boringssl){
72+
for(letn=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-process-features.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const expectedKeys = new Map([
99
['debug',['boolean']],
1010
['uv',['boolean']],
1111
['ipv6',['boolean']],
12+
['openssl_is_boringssl',['boolean']],
1213
['tls_alpn',['boolean']],
1314
['tls_sni',['boolean']],
1415
['tls_ocsp',['boolean']],

‎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
constserverConfig={
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
constserver=tls.createServer(serverConfig,common.mustCall(clientConfigs.length))
3841
.listen(0,common.localhostIPv4,function(){
3942
letconnected=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
constopts={
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
constserver=https.createServer(opts,(req,res)=>{
2427
res.write('hello');
2528
}).listen(0,common.mustCall(()=>{

0 commit comments

Comments
 (0)