Skip to content

Commit 066f084

Browse files
committed
[TEMP] Temporary for debugging in CI with openssl 1.1.1
1 parent defdb2f commit 066f084

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

deps/ncrypto/ncrypto.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ bool setFipsEnabled(bool enable, CryptoErrorList* errors) {
235235
if (isFipsEnabled() == enable) return true;
236236
ClearErrorOnReturn clearErrorOnReturn(errors);
237237
#if OPENSSL_VERSION_MAJOR >= 3
238-
return EVP_default_properties_enable_fips(nullptr, enable ? 1 : 0) == 1;
238+
return EVP_default_properties_enable_fips(nullptr, enable ? 1 : 0) == 1 &&
239+
EVP_default_properties_is_fips_enabled(nullptr);
239240
#else
240-
return FIPS_mode_set(enable ? 1 : 0) == 1;
241+
return FIPS_mode() == 0 ? FIPS_mode_set(enable ? 1 : 0) == 1 : true;
241242
#endif
242243
}
243244

@@ -248,18 +249,17 @@ bool testFipsEnabled() {
248249
if (OSSL_PROVIDER_available(nullptr, "fips")) {
249250
fips_provider = OSSL_PROVIDER_load(nullptr, "fips");
250251
}
251-
const auto enabled = fips_provider == nullptr ? 0
252-
: OSSL_PROVIDER_self_test(fips_provider) ? 1
253-
: 0;
252+
if (fips_provider == nullptr) return false;
253+
int result = OSSL_PROVIDER_self_test(fips_provider);
254+
OSSL_PROVIDER_unload(fips_provider);
255+
return result;
254256
#else
255257
#ifdef OPENSSL_FIPS
256-
const auto enabled = FIPS_selftest() ? 1 : 0;
258+
return FIPS_selftest();
257259
#else // OPENSSL_FIPS
258-
const auto enabled = 0;
260+
return false;
259261
#endif // OPENSSL_FIPS
260262
#endif
261-
262-
return enabled;
263263
}
264264

265265
// ============================================================================

src/crypto/crypto_util.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "openssl/provider.h"
2323
#endif
2424

25-
#include <openssl/rand.h>
26-
2725
namespace node {
2826

2927
using ncrypto::BignumPointer;
@@ -85,8 +83,12 @@ bool ProcessFipsOptions() {
8583
/* Override FIPS settings in configuration file, if needed. */
8684
if (per_process::cli_options->enable_fips_crypto ||
8785
per_process::cli_options->force_fips_crypto) {
86+
#if OPENSSL_VERSION_MAJOR >= 3
8887
if (!ncrypto::testFipsEnabled()) return false;
89-
return ncrypto::setFipsEnabled(true, nullptr) && ncrypto::isFipsEnabled();
88+
return ncrypto::setFipsEnabled(true, nullptr);
89+
#else
90+
if (FIPS_mode() == 0) return FIPS_mode_set(1);
91+
#endif
9092
}
9193
return true;
9294
}

0 commit comments

Comments
 (0)