Skip to content

Commit effdca8

Browse files
mhdawsondanielleadams
authored andcommitted
crypto: don't assume FIPS is disabled by default
For binaries that use --shared-openssl FIPs may be enabled by default by the system. Allow --force-fips and --enable-fips to be specified in these cases. Signed-off-by: Michael Dawson <[email protected]> PR-URL: #46532 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent f8d0291 commit effdca8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/crypto/crypto_util.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ bool ProcessFipsOptions() {
120120
return EVP_default_properties_enable_fips(nullptr, 1) &&
121121
EVP_default_properties_is_fips_enabled(nullptr);
122122
#else
123-
return FIPS_mode() == 0 && FIPS_mode_set(1);
123+
if (FIPS_mode() == 0) return FIPS_mode_set(1);
124+
124125
#endif
125126
}
126127
return true;

test/parallel/test-crypto-fips.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ testHelper(
7777
'process.versions',
7878
process.env);
7979

80-
// By default FIPS should be off in both FIPS and non-FIPS builds.
81-
testHelper(
82-
'stdout',
83-
[],
84-
FIPS_DISABLED,
85-
'require("crypto").getFips()',
86-
{ ...process.env, 'OPENSSL_CONF': ' ' });
80+
// By default FIPS should be off in both FIPS and non-FIPS builds
81+
// unless Node.js was configured using --shared-openssl in
82+
// which case it may be enabled by the system.
83+
if (!sharedOpenSSL()) {
84+
testHelper(
85+
'stdout',
86+
[],
87+
FIPS_DISABLED,
88+
'require("crypto").getFips()',
89+
{ ...process.env, 'OPENSSL_CONF': ' ' });
90+
}
8791

8892
// This should succeed for both FIPS and non-FIPS builds in combination with
8993
// OpenSSL 1.1.1 or OpenSSL 3.0

0 commit comments

Comments
 (0)