Skip to content

Commit a2f1d52

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

5 files changed

+26
-7
lines changed

src/node_constants.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ void DefineCryptoConstants(Local<Object> target) {
817817
NODE_DEFINE_CONSTANT(target, OPENSSL_VERSION_NUMBER);
818818
#endif
819819

820+
#ifdef OPENSSL_IS_BORINGSSL
821+
#undef OPENSSL_IS_BORINGSSL
822+
#define OPENSSL_IS_BORINGSSL 1
823+
NODE_DEFINE_CONSTANT(target, OPENSSL_IS_BORINGSSL);
824+
#undef OPENSSL_IS_BORINGSSL
825+
#endif
826+
820827
#ifdef SSL_OP_ALL
821828
NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
822829
#endif

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 (!crypto.constants.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 (!crypto.constants.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 && !crypto.constants.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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const { hasOpenSSL } = require('../common/crypto');
1111
const assert = require('assert');
1212
const tls = require('tls');
1313
const fixtures = require('../common/fixtures');
14+
const { constants } = require('crypto');
1415

1516
const clientConfigs = [
1617
{
@@ -29,11 +30,14 @@ const clientConfigs = [
2930

3031
const serverConfig = {
3132
secureProtocol: 'TLS_method',
32-
ciphers: 'RSA@SECLEVEL=0',
3333
key: fixtures.readKey('agent2-key.pem'),
3434
cert: fixtures.readKey('agent2-cert.pem')
3535
};
3636

37+
if (!constants.OPENSSL_IS_BORINGSSL) {
38+
serverConfig.ciphers = 'RSA@SECLEVEL=0';
39+
}
40+
3741
const server = tls.createServer(serverConfig, common.mustCall(clientConfigs.length))
3842
.listen(0, common.localhostIPv4, function() {
3943
let connected = 0;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (!common.hasCrypto)
66
const { TestTLSSocket, ccs } = require('../common/tls');
77
const fixtures = require('../common/fixtures');
88
const https = require('https');
9+
const { constants } = require('node:crypto');
910

1011
// Regression test for an use-after-free bug in the TLS implementation that
1112
// would occur when `SSL_write()` failed.
@@ -17,9 +18,12 @@ const server_cert = fixtures.readKey('agent1-cert.pem');
1718
const opts = {
1819
key: server_key,
1920
cert: server_cert,
20-
ciphers: 'ALL@SECLEVEL=0'
2121
};
2222

23+
if (!constants.OPENSSL_IS_BORINGSSL) {
24+
opts.ciphers = 'ALL@SECLEVEL=0';
25+
}
26+
2327
const server = https.createServer(opts, (req, res) => {
2428
res.write('hello');
2529
}).listen(0, common.mustCall(() => {

0 commit comments

Comments
 (0)