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 <mdawson@devrus.com> PR-URL: #46532 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 11 additions & 7 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy