diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml
index ae6a6619f47d..15046de071fd 100644
--- a/.github/workflows/test-shared.yml
+++ b/.github/workflows/test-shared.yml
@@ -259,8 +259,8 @@ jobs:
# the matrix-selected nixpkgs attribute (e.g. `openssl_3_6`). All
# other shared libs (brotli, cares, libuv, …) keep their defaults.
# `permittedInsecurePackages` whitelists just the matrix-selected
- # release (e.g. `openssl-1.1.1w`) so EOL-with-extended-support
- # cycles evaluate without relaxing nixpkgs' meta check globally.
+ # release so EOL-with-extended-support cycles evaluate without relaxing
+ # nixpkgs' meta check globally.
extra-nix-flags: |
--arg useSeparateDerivationForV8 ${{ needs.build-aarch64-linux-v8.outputs.local-cache && '"$(nix-store --import < libv8-aarch64-linux.nar)"' || 'true' }} \
--arg sharedLibDeps "(import $TAR_DIR/tools/nix/sharedLibDeps.nix {}) // {
diff --git a/BUILDING.md b/BUILDING.md
index c32d1889c96f..db384d7abeb7 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -206,7 +206,7 @@ on your Linux distribution.
#### OpenSSL asm support
-OpenSSL-1.1.1 requires the following assembler version for use of asm
+OpenSSL requires the following assembler version for use of asm
support on x86\_64 and ia32.
For use of AVX-512,
@@ -214,8 +214,6 @@ For use of AVX-512,
* gas (GNU assembler) version 2.26 or higher
* nasm version 2.11.8 or higher in Windows
-AVX-512 is disabled for Skylake-X by OpenSSL-1.1.1.
-
For use of AVX2,
* gas (GNU assembler) version 2.23 or higher
@@ -223,7 +221,7 @@ For use of AVX2,
* llvm version 3.3 or higher
* nasm version 2.10 or higher in Windows
-Please refer to for details.
+Please refer to for details.
If compiling without one of the above, use `configure` with the
`--openssl-no-asm` flag. Otherwise, `configure` will fail.
@@ -1029,14 +1027,20 @@ using the following configure option:
## Building Node.js with FIPS-compliant OpenSSL
-Node.js supports FIPS when statically or dynamically linked with OpenSSL 3 via
-[OpenSSL's provider model](https://docs.openssl.org/3.0/man7/crypto/#OPENSSL-PROVIDERS).
-It is not necessary to rebuild Node.js to enable support for FIPS.
+Node.js can use an OpenSSL FIPS provider via
+[OpenSSL's provider model](https://docs.openssl.org/master/man7/crypto/#openssl-providers),
+whether OpenSSL is linked statically or dynamically. It is not necessary to
+rebuild Node.js to do so; the provider and the OpenSSL configuration that
+activates it are supplied at runtime.
+
+Node.js does not build a FIPS provider. OpenSSL requires that a FIPS provider
+be built from a release that carries a FIPS certificate, so a provider built
+as part of the Node.js build would have no validation status.
-When using OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL.
+`./configure --openssl-is-fips` only records that the OpenSSL being linked is
+FIPS capable, and requires `--shared-openssl`.
-See [FIPS mode](doc/api/crypto.md#fips-mode) for more information on how to
-enable FIPS support in Node.js.
+See [FIPS mode](doc/api/crypto.md#fips-mode) for how to configure it.
## Building Node.js with Temporal support
@@ -1120,6 +1124,10 @@ A number of `configure` options are provided to support this use case.
provide the ability to set the path to an external JavaScript file
for the dependency to be used at runtime.
+When building with `--shared-openssl`, Node.js requires OpenSSL 3.0 or later.
+Support for building against OpenSSL 1.x was removed in Node.js 27.0.0, and
+`configure` fails if an older version is detected.
+
It is the responsibility of any distribution
shipping with these options to:
diff --git a/benchmark/crypto/kem.js b/benchmark/crypto/kem.js
index 34374dfc8494..05e640e1f5b2 100644
--- a/benchmark/crypto/kem.js
+++ b/benchmark/crypto/kem.js
@@ -35,12 +35,12 @@ if (hasOpenSSL(3, 2)) {
keyFixtures.x25519 = readKeyPair('x25519_public', 'x25519_private');
keyFixtures.x448 = readKeyPair('x448_public', 'x448_private');
}
-if (hasOpenSSL(3, 0)) {
+if (!isBoringSSL) {
keyFixtures.rsa = readKeyPair('rsa_public_2048', 'rsa_private_2048');
}
if (Object.keys(keyFixtures).length === 0) {
- console.log('no supported key types available for this OpenSSL version');
+ console.log('no supported key types available for this crypto implementation');
process.exit(0);
}
diff --git a/benchmark/crypto/mac.js b/benchmark/crypto/mac.js
index ea9d3a56e59f..a6ff89f22ea8 100644
--- a/benchmark/crypto/mac.js
+++ b/benchmark/crypto/mac.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common.js');
-const { hasOpenSSL, isBoringSSL } = require('../../test/common/crypto.js');
+const { isBoringSSL } = require('../../test/common/crypto.js');
const assert = require('node:assert');
const {
createHmac,
@@ -9,11 +9,10 @@ const {
getMacs,
} = require('node:crypto');
-if (!hasOpenSSL(3) ||
- isBoringSSL ||
+if (isBoringSSL ||
typeof createMac !== 'function' ||
typeof getMacs !== 'function') {
- console.log('Skipping: generic MAC API requires OpenSSL >= 3');
+ console.log('Skipping: generic MAC API requires OpenSSL EVP_MAC support');
process.exit(0);
}
diff --git a/configure.py b/configure.py
index 8b3332a461f4..d329fc8b0c68 100755
--- a/configure.py
+++ b/configure.py
@@ -268,7 +268,8 @@
action='store_true',
dest='openssl_is_fips',
default=None,
- help='specifies that the OpenSSL library is FIPS compatible')
+ help='specifies that the shared OpenSSL library is FIPS capable '
+ '(requires --shared-openssl)')
parser.add_argument('--openssl-use-def-ca-store',
action='store_true',
@@ -1422,8 +1423,9 @@ def try_check_compiler(cc, lang):
#
# The version of asm compiler is needed for building openssl asm files.
# See deps/openssl/openssl.gypi for detail.
-# Commands and regular expressions to obtain its version number are taken from
-# https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha512-x86_64.pl#L112-L129
+# Commands and regular expressions to obtain its version number mirror the
+# bundled OpenSSL assembler scripts, including
+# deps/openssl/openssl/crypto/sha/asm/sha512-x86_64.pl.
#
def get_version_helper(cc, regexp):
try:
@@ -2315,7 +2317,6 @@ def configure_openssl(o):
variables['node_shared_ngtcp2'] = b(options.shared_ngtcp2)
variables['node_shared_nghttp3'] = b(options.shared_nghttp3)
variables['openssl_is_fips'] = b(options.openssl_is_fips)
- variables['node_fipsinstall'] = b(False)
if options.openssl_no_asm:
variables['openssl_no_asm'] = 1
@@ -2349,15 +2350,15 @@ def without_ssl_error(option):
if not options.shared_openssl and not options.openssl_no_asm:
is_x86 = 'x64' in variables['target_arch'] or 'ia32' in variables['target_arch']
- # supported asm compiler for AVX2. See https://github.com/openssl/openssl/
- # blob/OpenSSL_1_1_0-stable/crypto/modes/asm/aesni-gcm-x86_64.pl#L52-L69
- openssl110_asm_supported = \
+ # Check for an assembler that supports the instructions used by OpenSSL.
+ # See deps/openssl/openssl/INSTALL.md for its toolchain requirements.
+ openssl_asm_supported = \
('gas_version' in variables and Version(variables['gas_version']) >= Version('2.23')) or \
('xcode_version' in variables and Version(variables['xcode_version']) >= Version('5.0')) or \
('llvm_version' in variables and Version(variables['llvm_version']) >= Version('3.3')) or \
('nasm_version' in variables and Version(variables['nasm_version']) >= Version('2.10'))
- if is_x86 and not openssl110_asm_supported:
+ if is_x86 and not openssl_asm_supported:
error('''Did not find a new enough assembler, install one or build with
--openssl-no-asm.
Please refer to BUILDING.md''')
@@ -2370,17 +2371,25 @@ def without_ssl_error(option):
if options.openssl_no_asm and options.shared_openssl:
error('--openssl-no-asm is incompatible with --shared-openssl')
+ if options.openssl_is_fips and not options.shared_openssl:
+ error('--openssl-is-fips is only available with --shared-openssl')
+
if options.openssl_is_fips:
o['defines'] += ['OPENSSL_FIPS']
- if options.openssl_is_fips and not options.shared_openssl:
- variables['node_fipsinstall'] = b(True)
-
configure_library('openssl', o)
o['variables']['openssl_version'] = get_openssl_version(o)
o['variables']['openssl_is_boringssl'] = get_openssl_is_boringssl(o)
+ # BoringSSL identifies itself as OpenSSL 1.1.1 and is exempt from this check.
+ # A version of 0 means detection failed, which is already warned about in
+ # get_openssl_version() and is caught at compile time by ncrypto.h.
+ openssl_version = o['variables']['openssl_version']
+ if o['variables']['openssl_is_boringssl'] == 'false' and \
+ 0 < openssl_version < 0x30000000:
+ error('OpenSSL 1.x is no longer supported, v3.0.0 or later is required.')
+
def configure_lief(o):
if options.without_lief:
if options.shared_lief:
diff --git a/deps/ncrypto/engine.cc b/deps/ncrypto/engine.cc
deleted file mode 100644
index a8e64e250491..000000000000
--- a/deps/ncrypto/engine.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "ncrypto.h"
-
-#if !defined(OPENSSL_NO_ENGINE) && \
- ((defined(NCRYPTO_ENGINE_COMPAT) && NCRYPTO_ENGINE_COMPAT) || \
- NCRYPTO_USE_LEGACY_OPENSSL)
-#include
-#endif
-
-namespace ncrypto {
-
-// ============================================================================
-// Engine
-
-#ifndef OPENSSL_NO_ENGINE
-EnginePointer::EnginePointer(void* engine_, bool finish_on_exit_)
- : engine(engine_), finish_on_exit(finish_on_exit_) {}
-
-EnginePointer::EnginePointer(EnginePointer&& other) noexcept
- : engine(other.engine), finish_on_exit(other.finish_on_exit) {
- other.release();
-}
-
-EnginePointer::~EnginePointer() {
- reset();
-}
-
-EnginePointer& EnginePointer::operator=(EnginePointer&& other) noexcept {
- if (this == &other) return *this;
- this->~EnginePointer();
- return *new (this) EnginePointer(std::move(other));
-}
-
-void EnginePointer::reset(void* engine_, bool finish_on_exit_) {
- if (engine != nullptr) {
- ENGINE* current = static_cast(engine);
- if (finish_on_exit) {
- // This also does the equivalent of ENGINE_free.
- ENGINE_finish(current);
- } else {
- ENGINE_free(current);
- }
- }
- engine = engine_;
- finish_on_exit = finish_on_exit_;
-}
-
-void* EnginePointer::release() {
- void* ret = engine;
- engine = nullptr;
- finish_on_exit = false;
- return ret;
-}
-
-EnginePointer EnginePointer::getEngineByName(const char* name,
- CryptoErrorList* errors) {
- MarkPopErrorOnReturn mark_pop_error_on_return(errors);
- EnginePointer engine(ENGINE_by_id(name));
- if (!engine) {
- // Engine not found, try loading dynamically.
- engine = EnginePointer(ENGINE_by_id("dynamic"));
- if (engine) {
- ENGINE* current = static_cast(engine.engine);
- if (!ENGINE_ctrl_cmd_string(current, "SO_PATH", name, 0) ||
- !ENGINE_ctrl_cmd_string(current, "LOAD", nullptr, 0)) {
- engine.reset();
- }
- }
- }
- return engine;
-}
-
-bool EnginePointer::setAsDefault(uint32_t flags, CryptoErrorList* errors) {
- if (engine == nullptr) return false;
- ClearErrorOnReturn clear_error_on_return(errors);
- return ENGINE_set_default(static_cast(engine), flags) != 0;
-}
-
-bool EnginePointer::init(bool finish_on_exit) {
- if (engine == nullptr) return false;
- if (finish_on_exit) setFinishOnExit();
- return ENGINE_init(static_cast(engine)) == 1;
-}
-
-EVPKeyPointer EnginePointer::loadPrivateKey(const char* key_name) {
- if (engine == nullptr) return EVPKeyPointer();
- return EVPKeyPointer(ENGINE_load_private_key(
- static_cast(engine), key_name, nullptr, nullptr));
-}
-
-bool EnginePointer::setClientCertEngine(SSL_CTX* ctx) {
- if (engine == nullptr || ctx == nullptr) return false;
- return SSL_CTX_set_client_cert_engine(ctx, static_cast(engine)) == 1;
-}
-
-void EnginePointer::initEnginesOnce() {
- static bool initialized = false;
- if (!initialized) {
- ENGINE_load_builtin_engines();
- ENGINE_register_all_complete();
- initialized = true;
- }
-}
-
-#endif // OPENSSL_NO_ENGINE
-
-} // namespace ncrypto
diff --git a/deps/ncrypto/ncrypto.cc b/deps/ncrypto/ncrypto.cc
index 6c817b742412..a5bf5b6aebd7 100644
--- a/deps/ncrypto/ncrypto.cc
+++ b/deps/ncrypto/ncrypto.cc
@@ -19,7 +19,7 @@
#include
#include
#include
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
#include
#include
#include
@@ -29,16 +29,6 @@
#include
#endif
#endif
-// EVP_PKEY_CTX_set_dsa_paramgen_q_bits was added in OpenSSL 1.1.1e.
-#if OPENSSL_VERSION_NUMBER < 0x1010105fL
-#define EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits) \
- EVP_PKEY_CTX_ctrl((ctx), \
- EVP_PKEY_DSA, \
- EVP_PKEY_OP_PARAMGEN, \
- EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, \
- (qbits), \
- nullptr)
-#endif
namespace ncrypto {
namespace {
@@ -46,7 +36,7 @@ using BignumCtxPointer = DeleteFnPtr;
using BignumGenCallbackPointer = DeleteFnPtr;
using NetscapeSPKIPointer = DeleteFnPtr;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
using X509PubKeyPointer = DeleteFnPtr;
// OSSL_STORE_close() returns int, so it needs a void-returning adapter to be
// usable as a DeleteFnPtr deleter.
@@ -58,7 +48,7 @@ using UIMethodPointer = DeleteFnPtr;
#endif
const EVP_CIPHER* GetCipherCtxCipher(const EVP_CIPHER_CTX* ctx) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVP_CIPHER_CTX_get0_cipher(ctx);
#else
return EVP_CIPHER_CTX_cipher(ctx);
@@ -66,14 +56,10 @@ const EVP_CIPHER* GetCipherCtxCipher(const EVP_CIPHER_CTX* ctx) {
}
const EVP_MD* GetDigestCtxMd(const EVP_MD_CTX* ctx) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER || NCRYPTO_USE_BORINGSSL
return EVP_MD_CTX_get0_md(ctx);
-#else
- return EVP_MD_CTX_md(ctx);
-#endif
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
using ASN1StringPointer = DeleteFnPtr;
using OSSLParamBldPointer = DeleteFnPtr;
using RsaPssParamsPointer = DeleteFnPtr;
@@ -127,7 +113,7 @@ constexpr std::array kRsaOtherPrimeParamNames = {{
static constexpr int kX509NameFlagsRFC2253WithinUtf8JSON =
XN_FLAG_RFC2253 & ~ASN1_STRFLGS_ESC_MSB & ~ASN1_STRFLGS_ESC_CTRL;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
template
bool GetPKeyBnParam(const EVP_PKEY* pkey, const char* name, Pointer* out) {
BIGNUM* bn = nullptr;
@@ -508,7 +494,7 @@ namespace {
std::atomic fips_state_generation{0};
bool isFipsEnabledRaw() {
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
return EVP_default_properties_is_fips_enabled(nullptr) == 1;
#else
return FIPS_mode() == 1;
@@ -525,7 +511,7 @@ bool setFipsEnabled(bool enable, CryptoErrorList* errors) {
const bool was_enabled = isFipsEnabled();
if (was_enabled == enable) return true;
ClearErrorOnReturn clearErrorOnReturn(errors);
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
const bool success =
EVP_default_properties_enable_fips(nullptr, enable ? 1 : 0) == 1;
#else
@@ -543,7 +529,7 @@ uint64_t getFipsStateGeneration() {
bool testFipsEnabled() {
ClearErrorOnReturn clear_error_on_return;
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
OSSL_PROVIDER* fips_provider = nullptr;
if (OSSL_PROVIDER_available(nullptr, "fips")) {
fips_provider = OSSL_PROVIDER_load(nullptr, "fips");
@@ -725,17 +711,15 @@ int BignumPointer::isPrime(int nchecks,
},
&innerCb);
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return BN_check_prime(get(), ctx.get(), cb.get());
-#elif NCRYPTO_USE_BORINGSSL
+#else
int is_probably_prime = 0;
if (BN_primality_test(
&is_probably_prime, get(), nchecks, ctx.get(), 0, cb.get()) != 1) {
return -1;
}
return is_probably_prime;
-#else
- return BN_is_prime_ex(get(), nchecks, ctx.get(), cb.get());
#endif
}
@@ -805,7 +789,7 @@ bool CSPRNG(void* buffer, size_t length) {
auto buf = reinterpret_cast(buffer);
do {
if (1 == RAND_status()) {
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
if (1 == RAND_bytes_ex(nullptr, buf, length, 0)) {
return true;
}
@@ -818,9 +802,9 @@ bool CSPRNG(void* buffer, size_t length) {
return true;
#endif
}
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
const auto code = ERR_peek_last_error();
- // A misconfigured OpenSSL 3 installation may report 1 from RAND_poll()
+ // A misconfigured OpenSSL installation may report 1 from RAND_poll()
// and RAND_status() but fail in RAND_bytes() if it cannot look up
// a matching algorithm for the CSPRNG.
if (ERR_GET_LIB(code) == ERR_LIB_RAND) {
@@ -855,7 +839,7 @@ int PasswordCallback(char* buf, int size, int rwflag, void* u) {
return -1;
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
namespace {
struct StorePassphraseData {
Buffer passphrase{.data = nullptr, .len = 0};
@@ -1141,7 +1125,7 @@ bool PrintGeneralName(const BIOPointer& out, const GENERAL_NAME* gen) {
BIO_printf(out.get(), (j == 0) ? "%X" : ":%X", pair);
}
} else {
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
BIO_printf(out.get(), "", ip_len);
#else
BIO_printf(out.get(), "");
@@ -1155,14 +1139,14 @@ bool PrintGeneralName(const BIOPointer& out, const GENERAL_NAME* gen) {
BIO_printf(out.get(), "Registered ID:%s", oline);
} else if (gen->type == GEN_OTHERNAME) {
// The format that is used here is based on OpenSSL's implementation of
- // GENERAL_NAME_print (as of OpenSSL 3.0.1). Earlier versions of Node.js
+ // GENERAL_NAME_print. Earlier versions of Node.js
// instead produced the same format as i2v_GENERAL_NAME, which was somewhat
// awkward, especially when passed to translatePeerCertificate.
bool unicode = true;
const char* prefix = nullptr;
- // OpenSSL 1.1.1 does not support othername in GENERAL_NAME_print and may
+ // BoringSSL does not support othername in GENERAL_NAME_print and may
// not define these NIDs.
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
int nid = OBJ_obj2nid(gen->d.otherName->type_id);
switch (nid) {
case NID_id_on_SmtpUTF8Mailbox:
@@ -1182,7 +1166,7 @@ bool PrintGeneralName(const BIOPointer& out, const GENERAL_NAME* gen) {
prefix = "NAIRealm";
break;
}
-#endif // OPENSSL_VERSION_MAJOR >= 3
+#endif // !OPENSSL_IS_BORINGSSL
int val_type = gen->d.otherName->value->type;
if (prefix == nullptr || (unicode && val_type != V_ASN1_UTF8STRING) ||
(!unicode && val_type != V_ASN1_IA5STRING)) {
@@ -1273,7 +1257,7 @@ bool SafeX509InfoAccessPrint(const BIOPointer& out, const X509_EXTENSION* ext) {
}
sk_ACCESS_DESCRIPTION_pop_free(descs, ACCESS_DESCRIPTION_free);
-#if OPENSSL_VERSION_MAJOR < 3
+#ifdef OPENSSL_IS_BORINGSSL
BIO_write(out.get(), "\n", 1);
#endif
@@ -1650,7 +1634,7 @@ bool X509View::ifRsa(KeyCallback callback) const {
if (cert_ == nullptr) return true;
OSSL3_CONST EVP_PKEY* pkey = X509_get0_pubkey(cert_);
if (EVPKeyPointer::isRsaVariant(pkey)) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
Rsa rsa(pkey);
#else
Rsa rsa(EVP_PKEY_get0_RSA(pkey));
@@ -1666,7 +1650,7 @@ bool X509View::ifEc(KeyCallback callback) const {
if (cert_ == nullptr) return true;
OSSL3_CONST EVP_PKEY* pkey = X509_get0_pubkey(cert_);
if (EVPKeyPointer::isA(pkey, KeyAlgorithm::EC)) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
Ec ec(pkey);
#else
Ec ec(EVP_PKEY_get0_EC_KEY(pkey));
@@ -1698,7 +1682,7 @@ X509Pointer X509Pointer::IssuerFrom(const SSL_CTX* ctx, const X509View& cert) {
}
X509Pointer X509Pointer::PeerFrom(const SSLPointer& ssl) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return X509Pointer(SSL_get1_peer_certificate(ssl.get()));
#else
return X509Pointer(SSL_get_peer_certificate(ssl.get()));
@@ -1826,7 +1810,7 @@ int BIOPointer::Write(BIOPointer* bio, std::string_view message) {
// DHPointer
namespace {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const char* GetOpenSSLDhGroupName(const std::string_view name,
DHPointer::FindGroupOption option) {
if (option != DHPointer::FindGroupOption::NO_SMALL_PRIMES &&
@@ -1903,7 +1887,7 @@ std::optional CheckDhParams(const BIGNUM* p,
const BIGNUM* g,
const BIGNUM* q,
const BIGNUM* j) {
- // TODO(panva): In a semver-major, consider tightening OpenSSL 3 validation
+ // TODO(panva): In a semver-major, consider tightening OpenSSL validation
// to report generator and q failures as strictly as legacy DH_check().
if (p == nullptr || g == nullptr) return std::nullopt;
@@ -1991,7 +1975,7 @@ std::optional CheckDhParams(const BIGNUM* p,
#endif
} // namespace
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DHPointer::DHPointer(EVPKeyPointer&& key, const char* group_name)
: dh_(key.release()), group_name_(group_name) {}
@@ -2004,7 +1988,7 @@ DHPointer::DHPointer(DH* dh) : dh_(dh) {}
#endif
DHPointer::DHPointer(DHPointer&& other) noexcept
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
: dh_(other.dh_.release()),
p_(std::move(other.p_)),
g_(std::move(other.g_)),
@@ -2029,14 +2013,14 @@ DHPointer::~DHPointer() {
}
void DHPointer::reset(
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_PKEY* dh
#else
DH* dh
#endif
) {
dh_.reset(dh);
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
p_.reset();
g_.reset();
pub_key_.reset();
@@ -2045,7 +2029,7 @@ void DHPointer::reset(
#endif
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_PKEY* DHPointer::release() {
if (!dh_ && p_ && g_) {
auto pkey =
@@ -2104,7 +2088,7 @@ DHPointer DHPointer::FromGroup(const std::string_view name,
auto generator = GetStandardGenerator();
if (!generator) return {}; // Unable to create the generator.
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const char* group_name = GetOpenSSLDhGroupName(name, option);
return DHPointer(std::move(group), std::move(generator), group_name);
#else
@@ -2115,7 +2099,7 @@ DHPointer DHPointer::FromGroup(const std::string_view name,
DHPointer DHPointer::New(BignumPointer&& p, BignumPointer&& g) {
if (!p || !g) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
auto pkey = NewDhPKey(p.get(), g.get());
if (!pkey) return {};
return DHPointer(std::move(pkey));
@@ -2138,7 +2122,7 @@ DHPointer DHPointer::New(BignumPointer&& p, BignumPointer&& g) {
}
DHPointer DHPointer::New(size_t bits, unsigned int generator) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
auto param_ctx = EVPKeyCtxPointer::NewFromAlgorithm(KeyAlgorithm::DH);
if (!param_ctx.initForParamgen() ||
!param_ctx.setDhParameters(bits, generator)) {
@@ -2163,7 +2147,7 @@ DHPointer DHPointer::New(size_t bits, unsigned int generator) {
DHPointer::CheckResult DHPointer::check() {
ClearErrorOnReturn clearErrorOnReturn;
if (!*this) return DHPointer::CheckResult::NONE;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
// TODO(panva): In a semver-major, consider validating named DH groups
// through the provider instead of preserving the historical verifyError.
if (group_name_ != nullptr) return CheckResult::NONE;
@@ -2205,7 +2189,7 @@ DHPointer::CheckPublicKeyResult DHPointer::checkPublicKey(
if (!pub_key || !*this) {
return DHPointer::CheckPublicKeyResult::CHECK_FAILED;
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DeleteFnPtr p;
DeleteFnPtr g;
const BIGNUM* p_bn = p_.get();
@@ -2272,7 +2256,7 @@ DHPointer::CheckPublicKeyResult DHPointer::checkPublicKey(
DataPointer DHPointer::getPrime() const {
if (!*this) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_) return p_.encode();
DeleteFnPtr p;
@@ -2288,7 +2272,7 @@ DataPointer DHPointer::getPrime() const {
size_t DHPointer::getPrimeBits() const {
if (!*this) return 0;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_) return BignumPointer::GetBitCount(p_.get());
DeleteFnPtr p;
@@ -2304,7 +2288,7 @@ size_t DHPointer::getPrimeBits() const {
DataPointer DHPointer::getGenerator() const {
if (!*this) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (g_) return g_.encode();
DeleteFnPtr p;
@@ -2320,7 +2304,7 @@ DataPointer DHPointer::getGenerator() const {
DataPointer DHPointer::getPublicKey() const {
if (!*this) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (pub_key_) return pub_key_.encode();
if (!dh_) return {};
@@ -2336,7 +2320,7 @@ DataPointer DHPointer::getPublicKey() const {
DataPointer DHPointer::getPrivateKey() const {
if (!*this) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (pvt_key_) return pvt_key_.encode();
if (!dh_) return {};
@@ -2352,7 +2336,7 @@ DataPointer DHPointer::getPrivateKey() const {
bool DHPointer::hasPrivateKey() const {
if (!*this) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (pvt_key_) return true;
if (!dh_) return false;
@@ -2370,7 +2354,7 @@ DataPointer DHPointer::generateKeys() {
ClearErrorOnReturn clearErrorOnReturn;
if (!*this) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_ && g_) {
if (!pvt_key_ && !GenerateDhPrivateKey(&pvt_key_, p_.get(), group_name_)) {
return {};
@@ -2437,7 +2421,7 @@ DataPointer DHPointer::generateKeys() {
size_t DHPointer::size() const {
if (!*this) return 0;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_) return BignumPointer::GetByteCount(p_.get());
const int bits = EVP_PKEY_get_bits(dh_.get());
@@ -2454,7 +2438,7 @@ DataPointer DHPointer::computeSecret(const BignumPointer& peer) const {
ClearErrorOnReturn clearErrorOnReturn;
if (!*this || !peer) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_ && pvt_key_) {
auto secret = BignumPointer::NewSecure();
BignumCtxPointer ctx(BN_CTX_new());
@@ -2522,7 +2506,7 @@ DataPointer DHPointer::computeSecret(const BignumPointer& peer) const {
bool DHPointer::setPublicKey(BignumPointer&& key) {
if (!*this) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_ && g_) {
pub_key_ = std::move(key);
return true;
@@ -2559,7 +2543,7 @@ bool DHPointer::setPublicKey(BignumPointer&& key) {
bool DHPointer::setPrivateKey(BignumPointer&& key) {
if (!*this) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (p_ && g_) {
pvt_key_ = std::move(key);
return true;
@@ -2603,7 +2587,7 @@ DataPointer DHPointer::stateless(const EVPKeyPointer& ourKey,
if (!ctx || EVP_PKEY_derive_init(ctx.get()) <= 0) {
return {};
}
- // TODO(panva): In a semver-major, consider padding OpenSSL 3 DH derivation
+ // TODO(panva): In a semver-major, consider padding OpenSSL DH derivation
// results here to match DiffieHellman::computeSecret().
if (EVP_PKEY_derive_set_peer(ctx.get(), theirKey.get()) <= 0 ||
EVP_PKEY_derive(ctx.get(), nullptr, &out_size) <= 0) {
@@ -2632,11 +2616,6 @@ DataPointer DHPointer::stateless(const EVPKeyPointer& ourKey,
// KDF
const EVP_MD* getDigestByName(const char* name) {
- // Historically, "dss1" and "DSS1" were DSA aliases for SHA-1
- // exposed through the public API.
- if (strcmp(name, "dss1") == 0 || strcmp(name, "DSS1") == 0) [[unlikely]] {
- return EVP_sha1();
- }
return EVP_get_digestbyname(name);
}
@@ -2665,11 +2644,8 @@ DataPointer hkdf(const Digest& md,
}
auto ctx = EVPKeyCtxPointer::NewFromName("HKDF");
- // OpenSSL < 3.0.0 accepted only a void* as the argument of
- // EVP_PKEY_CTX_set_hkdf_md.
- const EVP_MD* md_ptr = md;
if (!ctx || !EVP_PKEY_derive_init(ctx.get()) ||
- !EVP_PKEY_CTX_set_hkdf_md(ctx.get(), md_ptr) ||
+ !EVP_PKEY_CTX_set_hkdf_md(ctx.get(), md) ||
!EVP_PKEY_CTX_add1_hkdf_info(ctx.get(), info.data, info.len)) {
return {};
}
@@ -2682,12 +2658,9 @@ DataPointer hkdf(const Digest& md,
actual_salt = {default_salt, static_cast(md.size())};
}
- // We do not use EVP_PKEY_HKDF_MODE_EXTRACT_AND_EXPAND because and instead
- // implement the extraction step ourselves because EVP_PKEY_derive does not
- // handle zero-length keys, which are required for Web Crypto.
- // TODO(jasnell): Once OpenSSL 1.1.1 support is dropped completely, and once
- // BoringSSL is confirmed to support it, wen can hopefully drop this and use
- // EVP_KDF directly which does support zero length keys.
+ // Implement the extraction step here because EVP_PKEY_derive does not handle
+ // zero-length keys, which are required for Web Crypto. EVP_KDF handles them
+ // but is not available in BoringSSL.
unsigned char pseudorandom_key[EVP_MAX_MD_SIZE];
unsigned pseudorandom_key_len = sizeof(pseudorandom_key);
@@ -2937,7 +2910,7 @@ const KeyAlgorithm KeyAlgorithm::SLH_DSA_SHAKE_256S("SLH-DSA-SHAKE-256s", Family
// clang-format on
namespace {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
constexpr char kSignatureContextString[] = "context-string";
constexpr char kSignatureInstance[] = "instance";
#endif
@@ -3020,75 +2993,61 @@ size_t KeyAlgorithm::seedSize() const {
}
namespace {
-#if !NCRYPTO_USE_OPENSSL3_PROVIDER
-struct LegacyKeyAlgorithm {
+#if NCRYPTO_USE_BORINGSSL
+struct BoringSSLKeyAlgorithm {
const char* name;
int id;
-#if NCRYPTO_USE_BORINGSSL
const EVP_PKEY_ALG* (*raw_key_algorithm)() = nullptr;
-#endif
};
-// These backends require native key IDs. BoringSSL also uses EVP_PKEY_ALG
-// descriptors for raw keys; keep both adapters in the same table.
+// BoringSSL requires native key IDs and EVP_PKEY_ALG descriptors for raw keys;
+// keep both adapters in the same table.
// clang-format off
// NOLINTBEGIN(whitespace/line_length)
-const LegacyKeyAlgorithm kLegacyKeyAlgorithms[] = {
+const BoringSSLKeyAlgorithm kBoringSSLKeyAlgorithms[] = {
{KeyAlgorithm::RSA.name(), EVP_PKEY_RSA},
{KeyAlgorithm::RSA_PSS.name(), EVP_PKEY_RSA_PSS},
{KeyAlgorithm::DSA.name(), EVP_PKEY_DSA},
{KeyAlgorithm::DH.name(), EVP_PKEY_DH},
{KeyAlgorithm::EC.name(), EVP_PKEY_EC},
-#if NCRYPTO_USE_BORINGSSL
{KeyAlgorithm::ED25519.name(), EVP_PKEY_ED25519, EVP_pkey_ed25519},
{KeyAlgorithm::X25519.name(), EVP_PKEY_X25519, EVP_pkey_x25519},
-#else
- {KeyAlgorithm::ED25519.name(), EVP_PKEY_ED25519},
- {KeyAlgorithm::X25519.name(), EVP_PKEY_X25519},
-#endif
{"HKDF", EVP_PKEY_HKDF},
{KeyAlgorithm::ED448.name(), EVP_PKEY_ED448},
{KeyAlgorithm::X448.name(), EVP_PKEY_X448},
-#ifndef OPENSSL_NO_SM2
- {KeyAlgorithm::SM2.name(), EVP_PKEY_SM2},
-#endif
-#if NCRYPTO_USE_BORINGSSL
{KeyAlgorithm::ML_DSA_44.name(), EVP_PKEY_ML_DSA_44, EVP_pkey_ml_dsa_44},
{KeyAlgorithm::ML_DSA_65.name(), EVP_PKEY_ML_DSA_65, EVP_pkey_ml_dsa_65},
{KeyAlgorithm::ML_DSA_87.name(), EVP_PKEY_ML_DSA_87, EVP_pkey_ml_dsa_87},
{KeyAlgorithm::ML_KEM_768.name(), EVP_PKEY_ML_KEM_768, EVP_pkey_ml_kem_768},
{KeyAlgorithm::ML_KEM_1024.name(), EVP_PKEY_ML_KEM_1024, EVP_pkey_ml_kem_1024},
-#endif
};
// NOLINTEND(whitespace/line_length)
// clang-format on
-const LegacyKeyAlgorithm* FindLegacyKeyAlgorithm(const char* name) {
+const BoringSSLKeyAlgorithm* FindBoringSSLKeyAlgorithm(const char* name) {
if (name == nullptr) return nullptr;
- for (const auto& algorithm : kLegacyKeyAlgorithms) {
+ for (const auto& algorithm : kBoringSSLKeyAlgorithms) {
if (CaseInsensitiveNameEqual()(name, algorithm.name)) return &algorithm;
}
return nullptr;
}
-int GetLegacyKeyId(const char* name) {
- const auto* algorithm = FindLegacyKeyAlgorithm(name);
+int GetBoringSSLKeyId(const char* name) {
+ const auto* algorithm = FindBoringSSLKeyAlgorithm(name);
return algorithm == nullptr ? NID_undef : algorithm->id;
}
-#if NCRYPTO_USE_BORINGSSL
const EVP_PKEY_ALG* GetBoringSSLKeyAlgorithm(const KeyAlgorithm& algorithm) {
- const auto* entry = FindLegacyKeyAlgorithm(algorithm.name());
+ const auto* entry = FindBoringSSLKeyAlgorithm(algorithm.name());
return entry != nullptr && entry->raw_key_algorithm != nullptr
? entry->raw_key_algorithm()
: nullptr;
}
#endif
-#endif
} // namespace
void ConfigurePqcEncoding() {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER && OPENSSL_VERSION_PREREQ(3, 5)
+#if NCRYPTO_USE_OPENSSL_PROVIDER && OPENSSL_VERSION_PREREQ(3, 5)
// Configure all loaded providers to prefer seed-only format for ML-KEM and
// ML-DSA private keys in PKCS#8 export, falling back to priv-only when a
// seed is not available. The provider encoder reads these parameters at
@@ -3117,35 +3076,25 @@ EVPKeyPointer EVPKeyPointer::New() {
EVPKeyPointer EVPKeyPointer::NewRawPublic(
const KeyAlgorithm& algorithm, const Buffer& data) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVPKeyPointer(EVP_PKEY_new_raw_public_key_ex(
nullptr, algorithm.name(), nullptr, data.data, data.len));
-#elif NCRYPTO_USE_BORINGSSL
+#else
const auto* alg = GetBoringSSLKeyAlgorithm(algorithm);
if (alg == nullptr) return {};
return EVPKeyPointer(EVP_PKEY_from_raw_public_key(alg, data.data, data.len));
-#else
- const int id = GetLegacyKeyId(algorithm.name());
- if (id == NID_undef) return {};
- return EVPKeyPointer(
- EVP_PKEY_new_raw_public_key(id, nullptr, data.data, data.len));
#endif
}
EVPKeyPointer EVPKeyPointer::NewRawPrivate(
const KeyAlgorithm& algorithm, const Buffer& data) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVPKeyPointer(EVP_PKEY_new_raw_private_key_ex(
nullptr, algorithm.name(), nullptr, data.data, data.len));
-#elif NCRYPTO_USE_BORINGSSL
+#else
const auto* alg = GetBoringSSLKeyAlgorithm(algorithm);
if (alg == nullptr) return {};
return EVPKeyPointer(EVP_PKEY_from_raw_private_key(alg, data.data, data.len));
-#else
- const int id = GetLegacyKeyId(algorithm.name());
- if (id == NID_undef) return {};
- return EVPKeyPointer(
- EVP_PKEY_new_raw_private_key(id, nullptr, data.data, data.len));
#endif
}
@@ -3157,7 +3106,7 @@ EVPKeyPointer EVPKeyPointer::NewRawSeed(
if (seed_alg == nullptr) return {};
return EVPKeyPointer(
EVP_PKEY_from_private_seed(seed_alg, data.data, data.len));
-#elif NCRYPTO_USE_OPENSSL3_PROVIDER
+#else
// ML-DSA and ML-KEM both use the provider parameter "seed".
OSSL_PARAM params[] = {
OSSL_PARAM_construct_octet_string(
@@ -3171,14 +3120,12 @@ EVPKeyPointer EVPKeyPointer::NewRawSeed(
return {};
}
return EVPKeyPointer(pkey);
-#else
- return {};
#endif
}
EVPKeyPointer EVPKeyPointer::NewDH(DHPointer&& dh) {
if (!dh) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVPKeyPointer(dh.release());
#else
auto key = New();
@@ -3190,7 +3137,7 @@ EVPKeyPointer EVPKeyPointer::NewDH(DHPointer&& dh) {
#endif
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVPKeyPointer EVPKeyPointer::NewRSA(const Rsa& rsa) {
const auto public_key = rsa.getPublicKey();
if (public_key.n == nullptr || public_key.e == nullptr) return {};
@@ -3254,7 +3201,7 @@ EVPKeyPointer EVPKeyPointer::NewRSA(RSAPointer&& rsa) {
}
return key;
}
-#endif // NCRYPTO_USE_OPENSSL3_PROVIDER
+#endif // NCRYPTO_USE_OPENSSL_PROVIDER
EVPKeyPointer::EVPKeyPointer(EVP_PKEY* pkey) : pkey_(pkey) {}
@@ -3281,12 +3228,12 @@ EVP_PKEY* EVPKeyPointer::release() {
bool EVPKeyPointer::isA(const EVP_PKEY* key, const char* name) {
if (key == nullptr || name == nullptr) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
// EVP_PKEY_is_a() can match an untyped key to an unknown legacy name.
return EVP_PKEY_get0_type_name(key) != nullptr &&
EVP_PKEY_is_a(key, name) == 1;
#else
- const int id = GetLegacyKeyId(name);
+ const int id = GetBoringSSLKeyId(name);
return id != NID_undef && EVP_PKEY_id(key) == id;
#endif
}
@@ -3294,13 +3241,12 @@ bool EVPKeyPointer::isA(const EVP_PKEY* key, const char* name) {
// Returns true unless the key is known not to be SM2, so that a key whose curve
// cannot be determined opts out of the prehashed fallback rather than into it.
bool EVPKeyPointer::mayBeSM2() const {
-#ifdef OPENSSL_NO_SM2
+#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_NO_SM2)
return false;
#else
if (isA(KeyAlgorithm::SM2)) return true;
if (!isA(KeyAlgorithm::EC)) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
// An ECKeyPointer would also need the public point, which a provider-backed
// key need not expose.
char group_name[64];
@@ -3314,14 +3260,6 @@ bool EVPKeyPointer::mayBeSM2() const {
}
return OBJ_sn2nid(group_name) == NID_sm2 ||
EC_curve_nist2nid(group_name) == NID_sm2;
-#else
- ECKeyPointer ec(*this);
- if (!ec) return true;
-
- const EC_GROUP* group = ec.getGroup();
- if (group == nullptr) return true;
- return EC_GROUP_get_curve_name(group) == NID_sm2;
-#endif
#endif
}
@@ -3339,7 +3277,7 @@ bool EVPKeyPointer::isA(const KeyAlgorithm& algorithm) const {
const KeyAlgorithm* EVPKeyPointer::getAlgorithm() const {
if (!pkey_) return nullptr;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
// Provider primary names identify algorithms. Legacy ASN.1 methods can
// share names (for example, SM2 uses EC), so resolve those through isA().
// The fallback also handles providers with a noncanonical primary alias.
@@ -3354,7 +3292,7 @@ const KeyAlgorithm* EVPKeyPointer::getAlgorithm() const {
}
#else
const int id = EVP_PKEY_id(get());
- for (const auto& algorithm : kLegacyKeyAlgorithms) {
+ for (const auto& algorithm : kBoringSSLKeyAlgorithms) {
if (id == algorithm.id) return KeyAlgorithm::FromName(algorithm.name);
}
#endif
@@ -3379,7 +3317,7 @@ bool EVPKeyPointer::supportsRawPrivate() const {
bool EVPKeyPointer::supportsContextString() const {
const auto* algorithm = getAlgorithm();
if (algorithm == nullptr || !algorithm->isOneShot()) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
MarkPopErrorOnReturn mark_pop_error_on_return;
DeleteFnPtr signature(
EVP_SIGNATURE_fetch(nullptr, EVP_PKEY_get0_type_name(get()), nullptr));
@@ -3389,10 +3327,8 @@ bool EVPKeyPointer::supportsContextString() const {
OSSL_PARAM_locate_const(params, kSignatureContextString) != nullptr &&
(algorithm != &KeyAlgorithm::ED25519 ||
OSSL_PARAM_locate_const(params, kSignatureInstance) != nullptr);
-#elif NCRYPTO_USE_BORINGSSL
- return algorithm->isPqc();
#else
- return false;
+ return algorithm->isPqc();
#endif
}
@@ -3571,21 +3507,17 @@ DataPointer EVPKeyPointer::rawPublicKey() const {
}
namespace {
-DataPointer GetRawSeed([[maybe_unused]] EVP_PKEY* key, size_t seed_len) {
+DataPointer GetRawSeed(EVP_PKEY* key, size_t seed_len) {
auto data = DataPointer::Alloc(seed_len);
if (!data) return {};
-#if NCRYPTO_USE_BORINGSSL || NCRYPTO_USE_OPENSSL3_PROVIDER
const Buffer buf = data;
size_t len = data.size();
-#endif
#if NCRYPTO_USE_BORINGSSL
if (EVP_PKEY_get_private_seed(key, buf.data, &len) != 1) return {};
-#elif NCRYPTO_USE_OPENSSL3_PROVIDER
+#else
if (EVP_PKEY_get_octet_string_param(key, "seed", buf.data, buf.len, &len) !=
1)
return {};
-#else
- return {};
#endif
return data;
}
@@ -3663,7 +3595,7 @@ BIOPointer EVPKeyPointer::derPublicKey() const {
bool EVPKeyPointer::assign(const ECKeyPointer& eckey) {
if (!pkey_ || !eckey) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return set(eckey);
#else
return EVP_PKEY_assign_EC_KEY(pkey_.get(), eckey.get());
@@ -3672,7 +3604,7 @@ bool EVPKeyPointer::assign(const ECKeyPointer& eckey) {
bool EVPKeyPointer::set(const ECKeyPointer& eckey) {
if (!pkey_ || !eckey) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const int nid = EC_GROUP_get_curve_name(eckey.group_.get());
const char* group_name = OBJ_nid2sn(nid);
if (group_name == nullptr) return false;
@@ -3940,7 +3872,7 @@ Buffer GetPassphrase(
return pass;
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
using OSSLEncoderCtxPointer =
DeleteFnPtr;
@@ -4106,7 +4038,7 @@ EVPKeyPointer::ParseKeyResult EVPKeyPointer::TryParsePrivateKey(
EVPKeyPointer::ParseKeyResult EVPKeyPointer::TryLoadPrivateKeyFromStore(
const StorePrivateKeyConfig& config) {
-#if !NCRYPTO_USE_OPENSSL3_PROVIDER
+#if !NCRYPTO_USE_OPENSSL_PROVIDER
return ParseKeyResult(PKParseError::FAILED);
#else
// The error queue is left populated on failure so the caller can surface a
@@ -4217,7 +4149,7 @@ Result EVPKeyPointer::writePrivateKey(
// PKCS1 is only permitted for RSA keys.
if (!isA(KeyAlgorithm::RSA)) return Result(false);
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const EVP_CIPHER* cipher =
config.format == PKFormatType::PEM ? config.cipher : nullptr;
if (cipher != nullptr && passphrase.len == 0) {
@@ -4232,12 +4164,8 @@ Result EVPKeyPointer::writePrivateKey(
cipher,
passphrase);
}
-#else
-#if OPENSSL_VERSION_MAJOR >= 3
- const RSA* rsa = EVP_PKEY_get0_RSA(get());
#else
RSA* rsa = EVP_PKEY_get0_RSA(get());
-#endif
if (rsa == nullptr) return Result(false);
switch (config.format) {
@@ -4299,7 +4227,7 @@ Result EVPKeyPointer::writePrivateKey(
// SEC1 is only permitted for EC keys
if (!isA(KeyAlgorithm::EC)) return Result(false);
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const EVP_CIPHER* cipher =
config.format == PKFormatType::PEM ? config.cipher : nullptr;
err = !WriteEncodedPKey(bio.get(),
@@ -4309,12 +4237,8 @@ Result EVPKeyPointer::writePrivateKey(
"type-specific",
cipher,
passphrase);
-#else
-#if OPENSSL_VERSION_MAJOR >= 3
- const EC_KEY* ec = EVP_PKEY_get0_EC_KEY(get());
#else
EC_KEY* ec = EVP_PKEY_get0_EC_KEY(get());
-#endif
if (ec == nullptr) return Result(false);
switch (config.format) {
@@ -4366,7 +4290,7 @@ Result EVPKeyPointer::writePublicKey(
if (config.type == ncrypto::EVPKeyPointer::PKEncodingType::PKCS1) {
// PKCS#1 is only valid for RSA keys.
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!isA(KeyAlgorithm::RSA)) return Result(false);
if (!WriteEncodedPKey(bio.get(),
get(),
@@ -4377,12 +4301,8 @@ Result EVPKeyPointer::writePublicKey(
mark_pop_error_on_return.peekError());
}
return bio;
-#else
-#if OPENSSL_VERSION_MAJOR >= 3
- const RSA* rsa = EVP_PKEY_get0_RSA(get());
#else
RSA* rsa = EVP_PKEY_get0_RSA(get());
-#endif
if (rsa == nullptr) return Result(false);
if (config.format == ncrypto::EVPKeyPointer::PKFormatType::PEM) {
@@ -4403,7 +4323,7 @@ Result EVPKeyPointer::writePublicKey(
#endif
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (ECKeyHasMissingOid(*this)) {
ERR_raise(ERR_LIB_EC, EC_R_MISSING_OID);
return Result(false,
@@ -4413,7 +4333,7 @@ Result EVPKeyPointer::writePublicKey(
if (config.format == ncrypto::EVPKeyPointer::PKFormatType::PEM) {
// Encode SPKI as PEM.
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
// Build the SubjectPublicKeyInfo wrapper explicitly before PEM encoding.
// Provider-backed keys can fail the direct PEM_write_bio_PUBKEY() path even
// when OpenSSL can materialize the public wrapper with X509_PUBKEY_set().
@@ -4429,7 +4349,7 @@ Result EVPKeyPointer::writePublicKey(
mark_pop_error_on_return.peekError());
}
#else
- // Non-OpenSSL >= 3 builds do not all declare PEM_write_bio_X509_PUBKEY().
+ // BoringSSL does not declare PEM_write_bio_X509_PUBKEY().
if (PEM_write_bio_PUBKEY(bio.get(), get()) != 1) {
return Result(false,
mark_pop_error_on_return.peekError());
@@ -4447,9 +4367,6 @@ Result EVPKeyPointer::writePublicKey(
}
bool EVPKeyPointer::isRsaVariant(const EVP_PKEY* key) {
-#if !NCRYPTO_USE_OPENSSL3_PROVIDER && !NCRYPTO_USE_BORINGSSL
- if (key != nullptr && EVP_PKEY_id(key) == EVP_PKEY_RSA2) return true;
-#endif
return isA(key, KeyAlgorithm::RSA) || isA(key, KeyAlgorithm::RSA_PSS);
}
@@ -4470,7 +4387,7 @@ std::optional EVPKeyPointer::getBytesOfRS() const {
int bits;
if (isA(KeyAlgorithm::DSA)) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DeleteFnPtr q;
if (!GetPKeyBnParam(get(), OSSL_PKEY_PARAM_FFC_Q, &q)) return std::nullopt;
bits = BignumPointer::GetBitCount(q.get());
@@ -4488,7 +4405,7 @@ std::optional EVPKeyPointer::getBytesOfRS() const {
if (!has_bits) return std::nullopt;
#endif
} else if (isA(KeyAlgorithm::EC)) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
bits = EVP_PKEY_bits(get());
#else
const EC_KEY* ec_key = EVP_PKEY_get0_EC_KEY(get());
@@ -4509,17 +4426,10 @@ std::optional EVPKeyPointer::getBytesOfRS() const {
EVPKeyPointer::operator Rsa() const {
if (!isA(KeyAlgorithm::RSA) && !isA(KeyAlgorithm::RSA_PSS)) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return Rsa(get());
#else
- // TODO(tniessen): Remove the "else" branch once we drop support for OpenSSL
- // versions older than 1.1.1e via FIPS / dynamic linking.
- OSSL3_CONST RSA* rsa;
- if (OPENSSL_VERSION_NUMBER >= 0x1010105fL) {
- rsa = EVP_PKEY_get0_RSA(get());
- } else {
- rsa = static_cast(EVP_PKEY_get0(get()));
- }
+ OSSL3_CONST RSA* rsa = EVP_PKEY_get0_RSA(get());
if (rsa == nullptr) return {};
return Rsa(rsa);
#endif
@@ -4528,7 +4438,7 @@ EVPKeyPointer::operator Rsa() const {
EVPKeyPointer::operator Dsa() const {
if (!isA(KeyAlgorithm::DSA)) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return Dsa(get());
#else
OSSL3_CONST DSA* dsa = EVP_PKEY_get0_DSA(get());
@@ -4539,14 +4449,14 @@ EVPKeyPointer::operator Dsa() const {
bool EVPKeyPointer::validateDsaParameters() const {
if (!pkey_) return false;
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
if (EVP_default_properties_is_fips_enabled(nullptr) &&
isA(KeyAlgorithm::DSA)) {
#else
if (FIPS_mode() && isA(KeyAlgorithm::DSA)) {
#endif
// Validate DSA2 parameters from FIPS 186-4.
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DeleteFnPtr p;
DeleteFnPtr q;
if (!GetPKeyBnParam(pkey_.get(), OSSL_PKEY_PARAM_FFC_P, &p) ||
@@ -4825,7 +4735,7 @@ constexpr char AsciiToLower(char c) {
return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
constexpr auto kUnsupportedCipherFlags =
EVP_CIPH_FLAG_CIPHER_WITH_MAC | EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK;
@@ -4867,7 +4777,7 @@ void PushAlgorithmAlias(const char* name, void* arg) {
#endif
} // namespace
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
Cipher::Cipher(DeleteFnPtr cipher)
: cipher_(cipher.get()), fetched_cipher_(std::move(cipher)) {}
#endif
@@ -4890,7 +4800,7 @@ bool CaseInsensitiveNameEqual::operator()(std::string_view lhs,
DigestCache::Result DigestCache::lookup(const char* name,
uint64_t generation) const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (generation_ != generation) return {};
const auto it = aliases_.find(name);
if (it == aliases_.end()) return {};
@@ -4905,7 +4815,7 @@ DigestCache::Result DigestCache::lookup(const char* name,
DigestCache::Result DigestCache::insert(const char* name,
const EVP_MD* digest,
uint64_t generation) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (generation_ != generation || name == nullptr || digest == nullptr) {
return {};
}
@@ -4950,7 +4860,7 @@ DigestCache::Result DigestCache::insert(const char* name,
}
void DigestCache::reset(uint64_t generation) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (generation_ == generation) return;
aliases_.clear();
digests_.clear();
@@ -4960,7 +4870,7 @@ void DigestCache::reset(uint64_t generation) {
}
const DigestCache::AliasMap& DigestCache::aliases() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return aliases_;
#else
static const AliasMap empty;
@@ -4969,7 +4879,7 @@ const DigestCache::AliasMap& DigestCache::aliases() const {
}
const EVP_CIPHER* CipherCache::lookup(const char* name, uint64_t generation) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (generation_ != generation) {
aliases_.clear();
ciphers_.clear();
@@ -4987,7 +4897,7 @@ const EVP_CIPHER* CipherCache::lookup(const char* name, uint64_t generation) {
#endif
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const EVP_CIPHER* CipherCache::insert(
const char* name,
DeleteFnPtr&& cipher,
@@ -5024,7 +4934,7 @@ const EVP_CIPHER* CipherCache::insert(
#endif
Cipher::Cipher(const Cipher& other) : cipher_(other.cipher_) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (other.fetched_cipher_ != nullptr) {
if (EVP_CIPHER_up_ref(other.fetched_cipher_.get()) == 1) {
fetched_cipher_.reset(other.fetched_cipher_.get());
@@ -5037,7 +4947,7 @@ Cipher::Cipher(const Cipher& other) : cipher_(other.cipher_) {
Cipher& Cipher::operator=(const Cipher& other) {
if (this == &other) return *this;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (other.fetched_cipher_ != nullptr) {
if (EVP_CIPHER_up_ref(other.fetched_cipher_.get()) == 1) {
fetched_cipher_.reset(other.fetched_cipher_.get());
@@ -5057,13 +4967,13 @@ Cipher& Cipher::operator=(const Cipher& other) {
const Cipher Cipher::FromName(const char* name, CipherCache* cache) {
const EVP_CIPHER* cipher = EVP_get_cipherbyname(name);
if (cipher != nullptr) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!IsSupportedLegacyCipher(cipher)) return Cipher();
#endif
return Cipher(cipher);
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
// A resolution that overlaps a FIPS transition may use either property
// state. The cache retains the generation observed here, so the first
// resolution begun after the transition clears any stale entries.
@@ -5096,13 +5006,13 @@ const Cipher Cipher::FromName(const char* name, CipherCache* cache) {
const Cipher Cipher::FromNid(int nid, CipherCache* cache) {
const EVP_CIPHER* cipher = EVP_get_cipherbynid(nid);
if (cipher != nullptr) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!IsSupportedLegacyCipher(cipher)) return Cipher();
#endif
return Cipher(cipher);
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const char* name = OBJ_nid2sn(nid);
if (name != nullptr) return FromName(name, cache);
#else
@@ -5212,7 +5122,7 @@ bool Cipher::isCcmMode() const {
bool Cipher::isCtsMode() const {
if (!cipher_) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return (EVP_CIPHER_get_flags(cipher_) & EVP_CIPH_FLAG_CTS) != 0;
#else
return false;
@@ -5323,7 +5233,7 @@ const char* Cipher::getName() const {
const char* name = OBJ_nid2sn(nid);
if (name != nullptr) return name;
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVP_CIPHER_get0_name(cipher_);
#else
return {};
@@ -5420,10 +5330,10 @@ bool CipherCtxPointer::setAeadTagLength(size_t length) {
ctx_.get(), EVP_CTRL_AEAD_SET_TAG, length, nullptr);
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
namespace {
// OSSL_CIPHER_PARAM_XTS_STANDARD is not defined by OpenSSL 3.0. Use its
-// parameter name directly so custom 3.0 providers can advertise it too.
+// parameter name directly so custom providers can advertise it too.
constexpr char kCipherParamXtsStandard[] = "xts_standard";
bool SetCipherCtxStringParam(EVP_CIPHER_CTX* ctx,
@@ -5449,7 +5359,7 @@ bool SetCipherCtxStringParam(EVP_CIPHER_CTX* ctx,
#endif
bool CipherCtxPointer::setCtsMode(const char* mode) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return SetCipherCtxStringParam(ctx_.get(), OSSL_CIPHER_PARAM_CTS_MODE, mode);
#else
static_cast(mode);
@@ -5463,7 +5373,7 @@ bool CipherCtxPointer::setPadding(bool padding) {
}
bool CipherCtxPointer::setXtsStandard(const char* standard) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return SetCipherCtxStringParam(ctx_.get(), kCipherParamXtsStandard, standard);
#else
static_cast(standard);
@@ -6164,15 +6074,13 @@ EVPKeyCtxPointer EVPKeyCtxPointer::New(const EVPKeyPointer& key) {
EVPKeyCtxPointer EVPKeyCtxPointer::NewFromName(const char* name) {
if (name == nullptr) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVPKeyCtxPointer(EVP_PKEY_CTX_new_from_name(nullptr, name, nullptr));
#else
- const int id = GetLegacyKeyId(name);
+ const int id = GetBoringSSLKeyId(name);
if (id == NID_undef) return {};
-#ifdef OPENSSL_IS_BORINGSSL
// DSA keys are not supported with BoringSSL.
if (id == EVP_PKEY_DSA) return {};
-#endif
return EVPKeyCtxPointer(EVP_PKEY_CTX_new_id(id, nullptr));
#endif
}
@@ -6235,7 +6143,7 @@ bool EVPKeyCtxPointer::setDsaParameters(uint32_t bits,
bool EVPKeyCtxPointer::setEcParameters(int curve, int encoding) {
if (!ctx_) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const char* group_name = OBJ_nid2sn(curve);
if (group_name == nullptr) return false;
@@ -6300,7 +6208,7 @@ bool EVPKeyCtxPointer::setRsaKeygenBits(int bits) {
bool EVPKeyCtxPointer::setRsaKeygenPubExp(BignumPointer&& e) {
if (!ctx_) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return EVP_PKEY_CTX_set1_rsa_keygen_pubexp(ctx_.get(), e.get()) == 1;
#else
if (EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx_.get(), e.get()) == 1) {
@@ -6314,15 +6222,12 @@ bool EVPKeyCtxPointer::setRsaKeygenPubExp(BignumPointer&& e) {
bool EVPKeyCtxPointer::setRsaPssKeygenMd(const Digest& md) {
if (!md || !ctx_) return false;
- // OpenSSL < 3 accepts a void* for the md parameter.
- const EVP_MD* md_ptr = md;
- return EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx_.get(), md_ptr) > 0;
+ return EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx_.get(), md) > 0;
}
bool EVPKeyCtxPointer::setRsaPssKeygenMgf1Md(const Digest& md) {
if (!md || !ctx_) return false;
- const EVP_MD* md_ptr = md;
- return EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx_.get(), md_ptr) > 0;
+ return EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx_.get(), md) > 0;
}
bool EVPKeyCtxPointer::setRsaPssSaltlen(int salt_len) {
@@ -6400,11 +6305,7 @@ EVPKeyPointer EVPKeyCtxPointer::paramgen() const {
bool EVPKeyCtxPointer::publicCheck() const {
if (!ctx_) return false;
#ifndef OPENSSL_IS_BORINGSSL
-#if OPENSSL_VERSION_MAJOR >= 3
return EVP_PKEY_public_check_quick(ctx_.get()) == 1;
-#else
- return EVP_PKEY_public_check(ctx_.get()) == 1;
-#endif
#else // OPENSSL_IS_BORINGSSL
// Boringssl appears not to support this operation.
// TODO(jasnell): Is there an alternative approach that Boringssl does
@@ -6562,7 +6463,7 @@ Rsa::OtherPrimeInfoPointer::OtherPrimeInfoPointer(BignumPointer&& r,
BignumPointer&& t)
: r(r.release()), d(d.release()), t(t.release()) {}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
namespace {
int DigestAlgorithmIdentifierToNid(const unsigned char* data, size_t size) {
size_t sequence_header;
@@ -6816,7 +6717,7 @@ Rsa::Rsa(OSSL3_CONST RSA* ptr) : rsa_(ptr) {}
#endif
const Rsa::PublicKey Rsa::getPublicKey() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!rsa_) return {};
return PublicKey{n_.get(), e_.get(), d_.get()};
#else
@@ -6828,7 +6729,7 @@ const Rsa::PublicKey Rsa::getPublicKey() const {
}
const Rsa::PrivateKey Rsa::getPrivateKey() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!rsa_) return {};
return PrivateKey{p_.get(), q_.get(), dp_.get(), dq_.get(), qi_.get()};
#else
@@ -6842,29 +6743,11 @@ const Rsa::PrivateKey Rsa::getPrivateKey() const {
const Rsa::OtherPrimeInfos Rsa::getOtherPrimeInfos() const {
OtherPrimeInfos infos;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
infos.reserve(other_prime_infos_.size());
for (const auto& info : other_prime_infos_) {
infos.push_back({info.r.get(), info.d.get(), info.t.get()});
}
-#elif NCRYPTO_USE_LEGACY_OPENSSL
- if (rsa_ == nullptr) return infos;
- const int count = RSA_get_multi_prime_extra_count(rsa_);
- if (count <= 0) return infos;
-
- std::vector factors(count);
- std::vector exponents(count);
- std::vector coefficients(count);
- if (RSA_get0_multi_prime_factors(rsa_, factors.data()) != 1 ||
- RSA_get0_multi_prime_crt_params(
- rsa_, exponents.data(), coefficients.data()) != 1) {
- return {};
- }
-
- infos.reserve(count);
- for (int i = 0; i < count; i++) {
- infos.push_back({factors[i], exponents[i], coefficients[i]});
- }
#endif
return infos;
}
@@ -6890,7 +6773,7 @@ bool Rsa::checkPrimeProduct() const {
}
const std::optional Rsa::getPssParams() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return pss_params_;
#else
if (rsa_ == nullptr) return std::nullopt;
@@ -6931,7 +6814,7 @@ const std::optional Rsa::getPssParams() const {
BIOPointer Rsa::derPublicKey() const {
auto bio = BIOPointer::NewMem();
if (!bio) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
auto pkey = EVPKeyPointer::NewRSA(*this);
if (!pkey) return {};
if (!rsa_pss_) {
@@ -6970,7 +6853,7 @@ BIOPointer Rsa::derPublicKey() const {
bool Rsa::setPublicKey(BignumPointer&& n, BignumPointer&& e) {
if (!n || !e) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
n_.reset(n.release());
e_.reset(e.release());
rsa_ = true;
@@ -6992,7 +6875,7 @@ bool Rsa::setPrivateKey(BignumPointer&& d,
BignumPointer&& dq,
BignumPointer&& qi,
OtherPrimeInfoPointers&& other_prime_infos) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!d || !q || !p || !dp || !dq || !qi) return false;
for (const auto& info : other_prime_infos) {
if (!info.r || !info.d || !info.t) return false;
@@ -7026,36 +6909,7 @@ bool Rsa::setPrivateKey(BignumPointer&& d,
dq.release();
qi.release();
-#if NCRYPTO_USE_LEGACY_OPENSSL
- if (!other_prime_infos.empty()) {
- std::vector factors;
- std::vector exponents;
- std::vector coefficients;
- factors.reserve(other_prime_infos.size());
- exponents.reserve(other_prime_infos.size());
- coefficients.reserve(other_prime_infos.size());
- for (const auto& info : other_prime_infos) {
- if (!info.r || !info.d || !info.t) return false;
- factors.push_back(info.r.get());
- exponents.push_back(info.d.get());
- coefficients.push_back(info.t.get());
- }
- if (RSA_set0_multi_prime_params(const_cast(rsa_),
- factors.data(),
- exponents.data(),
- coefficients.data(),
- static_cast(factors.size())) != 1) {
- return false;
- }
- for (auto& info : other_prime_infos) {
- info.r.release();
- info.d.release();
- info.t.release();
- }
- }
-#else
if (!other_prime_infos.empty()) return false;
-#endif
return true;
#endif
}
@@ -7109,7 +6963,7 @@ struct CipherCallbackContext {
void operator()(const char* name) { cb(name); }
};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
template ,
#endif
&context);
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_CIPHER_do_all_provided(nullptr, array_push_back_provider, &context);
#endif
#endif
@@ -7219,7 +7073,7 @@ void Cipher::ForEach(Cipher::CipherNameCallback callback) {
// ============================================================================
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
Ec::Ec() : ec_(nullptr), pub_(nullptr) {}
Ec::Ec(const EVP_PKEY* pkey) : Ec() {
@@ -7291,7 +7145,7 @@ Ec::Ec(OSSL3_CONST EC_KEY* key) : ec_(key) {}
#endif
const EC_GROUP* Ec::getGroup() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return ec_.get();
#else
return ECKeyPointer::GetGroup(ec_);
@@ -7299,7 +7153,7 @@ const EC_GROUP* Ec::getGroup() const {
}
const EC_POINT* Ec::getPublicKey() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return pub_.get();
#else
return ECKeyPointer::GetPublicKey(ec_);
@@ -7307,7 +7161,7 @@ const EC_POINT* Ec::getPublicKey() const {
}
point_conversion_form_t Ec::getPointConversionForm() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
return form_;
#else
return EC_KEY_get_conv_form(ec_);
@@ -7321,7 +7175,7 @@ int Ec::getCurve() const {
DataPointer Ec::TryExportPublic(const EVPKeyPointer& key,
point_conversion_form_t form) {
if (!key || form != POINT_CONVERSION_UNCOMPRESSED) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
{
MarkPopErrorOnReturn pop_errors;
size_t length = 0;
@@ -7345,7 +7199,7 @@ DataPointer Ec::TryExportPublic(const EVPKeyPointer& key,
DataPointer Ec::ExportPrivate(const EVPKeyPointer& key) {
if (!key) return {};
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
{
MarkPopErrorOnReturn pop_errors;
BignumPointer priv;
@@ -7370,7 +7224,7 @@ bool Ec::GetKeyComponents(const EVPKeyPointer& key,
BignumPointer* priv,
int* degree) {
if (!key) return false;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const int nid = GetCurveId(key);
switch (nid) {
case NID_X9_62_prime256v1:
@@ -7426,7 +7280,7 @@ bool Ec::GetKeyComponents(const EVPKeyPointer& key,
int Ec::GetCurveId(const EVPKeyPointer& key) {
if (!key) return NID_undef;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
char name[80];
size_t length = 0;
if (EVP_PKEY_get_utf8_string_param(
@@ -7602,7 +7456,7 @@ std::optional EVPMDCtxPointer::signInitWithContext(
return std::nullopt;
}
return ctx;
-#elif NCRYPTO_USE_OPENSSL3_PROVIDER
+#else
EVP_PKEY_CTX* ctx = nullptr;
// Ed25519 requires the INSTANCE param to switch into Ed25519ctx mode.
@@ -7636,8 +7490,6 @@ std::optional EVPMDCtxPointer::signInitWithContext(
return std::nullopt;
}
return ctx;
-#else
- return std::nullopt;
#endif
}
@@ -7655,7 +7507,7 @@ std::optional EVPMDCtxPointer::verifyInitWithContext(
return std::nullopt;
}
return ctx;
-#elif NCRYPTO_USE_OPENSSL3_PROVIDER
+#else
EVP_PKEY_CTX* ctx = nullptr;
// Ed25519 requires the INSTANCE param to switch into Ed25519ctx mode.
@@ -7689,8 +7541,6 @@ std::optional EVPMDCtxPointer::verifyInitWithContext(
return std::nullopt;
}
return ctx;
-#else
- return std::nullopt;
#endif
}
@@ -8199,7 +8049,7 @@ std::pair X509Name::Iterator::operator*() const {
// ============================================================================
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
Dsa::Dsa() : dsa_(false) {}
Dsa::Dsa(const EVP_PKEY* pkey) : Dsa() {
@@ -8216,7 +8066,7 @@ Dsa::Dsa(OSSL3_CONST DSA* dsa) : dsa_(dsa) {}
#endif
const BIGNUM* Dsa::getP() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!dsa_) return nullptr;
return p_.get();
#else
@@ -8228,7 +8078,7 @@ const BIGNUM* Dsa::getP() const {
}
const BIGNUM* Dsa::getQ() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!dsa_) return nullptr;
return q_.get();
#else
@@ -8240,7 +8090,7 @@ const BIGNUM* Dsa::getQ() const {
}
size_t Dsa::getModulusLength() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!dsa_) return 0;
#else
if (dsa_ == nullptr) return 0;
@@ -8249,7 +8099,7 @@ size_t Dsa::getModulusLength() const {
}
size_t Dsa::getDivisorLength() const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!dsa_) return 0;
#else
if (dsa_ == nullptr) return 0;
@@ -8264,13 +8114,13 @@ size_t Digest::size() const {
return EVP_MD_size(md_);
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
Digest::Digest(DeleteFnPtr md)
: md_(md.get()), fetched_md_(std::move(md)) {}
#endif
Digest::Digest(const Digest& other) : md_(other.md_) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (other.fetched_md_ != nullptr) {
if (EVP_MD_up_ref(other.fetched_md_.get()) == 1) {
fetched_md_.reset(other.fetched_md_.get());
@@ -8283,7 +8133,7 @@ Digest::Digest(const Digest& other) : md_(other.md_) {
Digest& Digest::operator=(const Digest& other) {
if (this == &other) return *this;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (other.fetched_md_ != nullptr) {
if (EVP_MD_up_ref(other.fetched_md_.get()) == 1) {
fetched_md_.reset(other.fetched_md_.get());
@@ -8306,7 +8156,7 @@ const Digest Digest::SHA256 = Digest(EVP_sha256());
const Digest Digest::SHA384 = Digest(EVP_sha384());
const Digest Digest::SHA512 = Digest(EVP_sha512());
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
namespace {
bool IsSupportedDigest(const EVP_MD* md) {
if (md == nullptr || EVP_MD_is_a(md, "NULL")) return false;
@@ -8324,7 +8174,7 @@ bool IsSupportedDigest(const EVP_MD* md) {
const Digest Digest::FromName(const char* name) {
const EVP_MD* md = ncrypto::getDigestByName(name);
if (md != nullptr) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (md == EVP_md_null()) return Digest();
#endif
return Digest(md);
@@ -8334,7 +8184,7 @@ const Digest Digest::FromName(const char* name) {
}
const Digest Digest::Fetch(const char* name) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
MarkPopErrorOnReturn mark_pop_error_on_return;
DeleteFnPtr fetched(
EVP_MD_fetch(nullptr, name, nullptr));
@@ -8349,7 +8199,7 @@ const Digest Digest::Fetch(const char* name) {
// ============================================================================
// KEM Implementation
#if OPENSSL_WITH_KEM
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
bool KEM::SetOperationParameter(EVP_PKEY_CTX* ctx, const EVPKeyPointer& key) {
const OSSL_PARAM* settable = EVP_PKEY_CTX_settable_params(ctx);
if (settable == nullptr ||
@@ -8382,7 +8232,7 @@ std::optional KEM::Encapsulate(
return std::nullopt;
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!SetOperationParameter(ctx.get(), public_key)) {
return std::nullopt;
}
@@ -8423,7 +8273,7 @@ DataPointer KEM::Decapsulate(const EVPKeyPointer& private_key,
return {};
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (!SetOperationParameter(ctx.get(), private_key)) {
return {};
}
diff --git a/deps/ncrypto/ncrypto.gyp b/deps/ncrypto/ncrypto.gyp
index 804a664fa0a2..ce6670e63bb5 100644
--- a/deps/ncrypto/ncrypto.gyp
+++ b/deps/ncrypto/ncrypto.gyp
@@ -5,22 +5,10 @@
'ncrypto.cc',
'ncrypto.h',
],
- 'ncrypto_engine_sources': [
- 'engine.cc',
- 'ncrypto.h',
- ],
'ncrypto_strict_defines': [
'OPENSSL_API_COMPAT=30000',
'OPENSSL_NO_DEPRECATED',
],
- 'ncrypto_legacy_openssl_defines': [
- 'OPENSSL_API_COMPAT=0x10100000L',
- ],
- 'ncrypto_engine_defines': [
- 'OPENSSL_API_COMPAT=30000',
- 'OPENSSL_SUPPRESS_DEPRECATED',
- 'NCRYPTO_ENGINE_COMPAT=1',
- ],
},
'targets': [
{
@@ -36,23 +24,15 @@
'NCRYPTO_BSSL_LIBDECREPIT_MISSING=<(ncrypto_bssl_libdecrepit_missing)',
],
'conditions': [
- ['openssl_is_boringssl=="false" and openssl_version >= 0x3000000f', {
- 'defines!': [ '<@(ncrypto_legacy_openssl_defines)' ],
+ ['openssl_is_boringssl=="false"', {
'defines': [ '<@(ncrypto_strict_defines)' ],
}],
],
},
'sources': [ '<@(ncrypto_sources)' ],
'conditions': [
- ['openssl_is_boringssl=="false" and openssl_version >= 0x3000000f', {
- 'defines!': [ '<@(ncrypto_legacy_openssl_defines)' ],
+ ['openssl_is_boringssl=="false"', {
'defines': [ '<@(ncrypto_strict_defines)' ],
- 'dependencies': [
- 'ncrypto_engine',
- ],
- }],
- ['openssl_is_boringssl=="false" and openssl_version < 0x3000000f', {
- 'sources': [ '<@(ncrypto_engine_sources)' ],
}],
['node_shared_openssl=="false"', {
'dependencies': [
@@ -62,27 +42,4 @@
]
},
],
- 'conditions': [
- ['openssl_is_boringssl=="false" and openssl_version >= 0x3000000f', {
- 'targets': [
- {
- 'target_name': 'ncrypto_engine',
- 'type': 'static_library',
- 'include_dirs': ['.'],
- 'defines': [
- 'NCRYPTO_BSSL_LIBDECREPIT_MISSING=<(ncrypto_bssl_libdecrepit_missing)',
- '<@(ncrypto_engine_defines)',
- ],
- 'sources': [ '<@(ncrypto_engine_sources)' ],
- 'conditions': [
- ['node_shared_openssl=="false"', {
- 'dependencies': [
- '../openssl/openssl.gyp:openssl'
- ]
- }],
- ]
- },
- ],
- }],
- ],
}
diff --git a/deps/ncrypto/ncrypto.h b/deps/ncrypto/ncrypto.h
index 53151503c364..1fc36adba6dc 100644
--- a/deps/ncrypto/ncrypto.h
+++ b/deps/ncrypto/ncrypto.h
@@ -23,16 +23,16 @@
#include
#include
#include
-#if defined(NCRYPTO_ENGINE_COMPAT) && NCRYPTO_ENGINE_COMPAT && \
- !defined(OPENSSL_NO_ENGINE)
-#include
-#endif // NCRYPTO_ENGINE_COMPAT && !OPENSSL_NO_ENGINE
-
#ifndef OPENSSL_VERSION_PREREQ
#define OPENSSL_VERSION_PREREQ(maj, min) \
(OPENSSL_VERSION_NUMBER >= (((maj) << 28) | ((min) << 20)))
#endif
+// BoringSSL reports itself as OpenSSL 1.1.1, so it has to be excluded here.
+#if !defined(OPENSSL_IS_BORINGSSL) && !OPENSSL_VERSION_PREREQ(3, 0)
+#error "OpenSSL 1.x is no longer supported, v3.0.0 or later is required."
+#endif
+
// BoringSSL declares the EVP_*_do_all* APIs, but their implementation may
// live in libdecrepit. This matches standalone ncrypto's build flag.
#ifndef NCRYPTO_BSSL_LIBDECREPIT_MISSING
@@ -46,46 +46,26 @@
#endif
// Backend split:
-// - OpenSSL >= 3 uses provider APIs and hides deprecated low-level objects.
-// - BoringSSL has its own API-compatible branch.
-// - OpenSSL < 3 remains the legacy fallback branch.
-#if !defined(OPENSSL_IS_BORINGSSL) && OPENSSL_VERSION_PREREQ(3, 0)
-#define NCRYPTO_USE_OPENSSL3_PROVIDER 1
-#else
-#define NCRYPTO_USE_OPENSSL3_PROVIDER 0
-#endif
-
+// - OpenSSL uses provider APIs and hides deprecated low-level objects.
+// - BoringSSL has its own API-compatible branch and keeps using the legacy
+// low-level key types.
#ifdef OPENSSL_IS_BORINGSSL
#define NCRYPTO_USE_BORINGSSL 1
+#define NCRYPTO_USE_OPENSSL_PROVIDER 0
#else
#define NCRYPTO_USE_BORINGSSL 0
+#define NCRYPTO_USE_OPENSSL_PROVIDER 1
#endif
-#if !NCRYPTO_USE_OPENSSL3_PROVIDER && !NCRYPTO_USE_BORINGSSL
-#define NCRYPTO_USE_LEGACY_OPENSSL 1
-#else
-#define NCRYPTO_USE_LEGACY_OPENSSL 0
-#endif
-
-#if NCRYPTO_USE_BORINGSSL || NCRYPTO_USE_LEGACY_OPENSSL
-#define NCRYPTO_USE_LEGACY_KEY_TYPES 1
-#else
-#define NCRYPTO_USE_LEGACY_KEY_TYPES 0
-#endif
+#define NCRYPTO_USE_LEGACY_KEY_TYPES NCRYPTO_USE_BORINGSSL
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
#include
#include
#include
#endif
-// The FIPS-related functions are only available
-// when the OpenSSL itself was compiled with FIPS support.
-#if defined(OPENSSL_FIPS) && !OPENSSL_VERSION_PREREQ(3, 0)
-#include
-#endif // OPENSSL_FIPS
-
-#if OPENSSL_VERSION_PREREQ(3, 0)
+#if !defined(OPENSSL_IS_BORINGSSL)
#define OPENSSL_WITH_AES_OCB 1
#else
#define OPENSSL_WITH_AES_OCB 0
@@ -97,19 +77,15 @@
#define OPENSSL_WITH_ARGON2 0
#endif
-#if OPENSSL_VERSION_PREREQ(3, 0) || defined(OPENSSL_IS_BORINGSSL)
#define OPENSSL_WITH_KEM 1
-#else
-#define OPENSSL_WITH_KEM 0
-#endif
-#if OPENSSL_VERSION_PREREQ(3, 0)
+#if !defined(OPENSSL_IS_BORINGSSL)
#define OPENSSL_WITH_EVP_MAC 1
#else
#define OPENSSL_WITH_EVP_MAC 0
#endif
-#if !defined(OPENSSL_IS_BORINGSSL) && OPENSSL_VERSION_PREREQ(3, 0)
+#if !defined(OPENSSL_IS_BORINGSSL)
#define OPENSSL_WITH_AES_SIV 1
#else
#define OPENSSL_WITH_AES_SIV 0
@@ -121,7 +97,7 @@
#define OPENSSL_WITH_AES_GCM_SIV 0
#endif
-#if OPENSSL_VERSION_PREREQ(3, 0)
+#if !defined(OPENSSL_IS_BORINGSSL)
#define OSSL3_CONST const
#else
#define OSSL3_CONST
@@ -359,7 +335,7 @@ class Digest final {
Digest(const Digest& other);
Digest& operator=(const Digest& other);
inline Digest& operator=(const EVP_MD* md) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
fetched_md_.reset();
#endif
md_ = md;
@@ -384,7 +360,7 @@ class Digest final {
private:
const EVP_MD* md_ = nullptr;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
explicit Digest(DeleteFnPtr md);
DeleteFnPtr fetched_md_;
#endif
@@ -417,7 +393,7 @@ class DigestCache final {
Result lookup(const char* name, uint64_t generation) const;
inline Result lookup(int32_t id, uint64_t generation) const {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (generation_ != generation || id == -1) return {};
const uint32_t unsigned_id = static_cast(id);
if (unsigned_id < first_id_) return {};
@@ -436,7 +412,7 @@ class DigestCache final {
private:
uint64_t generation_ = 0;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
using EVPMDPointer = DeleteFnPtr;
// IDs are not reused across generations because JavaScript caches them
@@ -462,14 +438,14 @@ class CipherCache final {
NCRYPTO_DISALLOW_COPY_AND_MOVE(CipherCache)
const EVP_CIPHER* lookup(const char* name, uint64_t generation);
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
const EVP_CIPHER* insert(const char* name,
DeleteFnPtr&& cipher,
uint64_t generation);
#endif
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
using EVPCipherPointer = DeleteFnPtr;
uint64_t generation_ = 0;
@@ -503,7 +479,7 @@ class Cipher final {
Cipher(const Cipher& other);
Cipher& operator=(const Cipher& other);
inline Cipher& operator=(const EVP_CIPHER* cipher) {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
fetched_cipher_.reset();
#endif
cipher_ = cipher;
@@ -598,7 +574,7 @@ class Cipher final {
private:
const EVP_CIPHER* cipher_ = nullptr;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
explicit Cipher(DeleteFnPtr cipher);
DeleteFnPtr fetched_cipher_;
#endif
@@ -610,14 +586,14 @@ class Cipher final {
class Dsa final {
public:
Dsa();
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
explicit Dsa(const EVP_PKEY* pkey);
#else
Dsa(OSSL3_CONST DSA* dsa);
#endif
NCRYPTO_DISALLOW_COPY_AND_MOVE(Dsa)
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
inline operator bool() const {
return dsa_;
}
@@ -634,7 +610,7 @@ class Dsa final {
size_t getDivisorLength() const;
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
bool dsa_ = false;
DeleteFnPtr p_;
DeleteFnPtr q_;
@@ -649,14 +625,14 @@ class Dsa final {
class Rsa final {
public:
Rsa();
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
explicit Rsa(const EVP_PKEY* pkey);
#else
Rsa(OSSL3_CONST RSA* rsa);
#endif
NCRYPTO_DISALLOW_COPY_AND_MOVE(Rsa)
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
inline operator bool() const {
return rsa_;
}
@@ -730,7 +706,7 @@ class Rsa final {
const Buffer in);
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
bool rsa_ = false;
bool rsa_pss_ = false;
DeleteFnPtr n_;
@@ -751,7 +727,7 @@ class Rsa final {
class Ec final {
public:
Ec();
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
explicit Ec(const EVP_PKEY* pkey);
#else
Ec(OSSL3_CONST EC_KEY* key);
@@ -784,7 +760,7 @@ class Ec final {
static bool GetCurves(GetCurveCallback callback);
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DeleteFnPtr ec_;
DeleteFnPtr pub_;
point_conversion_form_t form_ = POINT_CONVERSION_UNCOMPRESSED;
@@ -1204,7 +1180,7 @@ class EVPKeyPointer final {
static EVPKeyPointer NewRawSeed(const KeyAlgorithm& algorithm,
const Buffer& data);
static EVPKeyPointer NewDH(DHPointer&& dh);
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
static EVPKeyPointer NewRSA(const Rsa& rsa);
#else
static EVPKeyPointer NewRSA(RSAPointer&& rsa);
@@ -1391,7 +1367,7 @@ class DHPointer final {
static DHPointer New(size_t bits, unsigned int generator);
DHPointer() = default;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
explicit DHPointer(EVPKeyPointer&& key, const char* group_name = nullptr);
DHPointer(BignumPointer&& p, BignumPointer&& g, const char* group_name);
#else
@@ -1402,7 +1378,7 @@ class DHPointer final {
NCRYPTO_DISALLOW_COPY(DHPointer)
~DHPointer();
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
inline bool operator==(std::nullptr_t) noexcept {
return !operator bool();
}
@@ -1471,7 +1447,7 @@ class DHPointer final {
const EVPKeyPointer& theirKey);
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DeleteFnPtr dh_;
BignumPointer p_;
BignumPointer g_;
@@ -1799,7 +1775,7 @@ class ECKeyPointer final {
NCRYPTO_DISALLOW_COPY(ECKeyPointer)
~ECKeyPointer();
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
inline bool operator==(std::nullptr_t) noexcept {
return group_ == nullptr;
}
@@ -1844,7 +1820,7 @@ class ECKeyPointer final {
#endif
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
DeleteFnPtr group_;
DeleteFnPtr pub_;
DeleteFnPtr priv_;
@@ -2089,44 +2065,6 @@ class MacCache final {
};
#endif
-#ifndef OPENSSL_NO_ENGINE
-class EnginePointer final {
- public:
- EnginePointer() = default;
-
- explicit EnginePointer(void* engine_, bool finish_on_exit = false);
- EnginePointer(EnginePointer&& other) noexcept;
- EnginePointer& operator=(EnginePointer&& other) noexcept;
- NCRYPTO_DISALLOW_COPY(EnginePointer)
- ~EnginePointer();
-
- inline operator bool() const { return engine != nullptr; }
- inline void setFinishOnExit() { finish_on_exit = true; }
-
- void reset(void* engine_ = nullptr, bool finish_on_exit_ = false);
-
- bool setAsDefault(uint32_t flags, CryptoErrorList* errors = nullptr);
- bool init(bool finish_on_exit = false);
- EVPKeyPointer loadPrivateKey(const char* key_name);
- bool setClientCertEngine(SSL_CTX* ctx);
-
- void* release();
-
- // Retrieve an OpenSSL Engine instance by name. If the name does not
- // identify a valid named engine, the returned EnginePointer will be
- // empty.
- static EnginePointer getEngineByName(const char* name,
- CryptoErrorList* errors = nullptr);
-
- // Call once when initializing OpenSSL at startup for the process.
- static void initEnginesOnce();
-
- private:
- void* engine = nullptr;
- bool finish_on_exit = false;
-};
-#endif // !OPENSSL_NO_ENGINE
-
// ============================================================================
// FIPS
bool isFipsEnabled();
@@ -2246,7 +2184,7 @@ class KEM final {
const Buffer& ciphertext);
private:
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
static bool SetOperationParameter(EVP_PKEY_CTX* ctx,
const EVPKeyPointer& key);
#endif
diff --git a/deps/ncrypto/unofficial.gni b/deps/ncrypto/unofficial.gni
index dad4fbbf16f0..7cb27d22b9b8 100644
--- a/deps/ncrypto/unofficial.gni
+++ b/deps/ncrypto/unofficial.gni
@@ -26,11 +26,7 @@ template("ncrypto_gn_build") {
source_set(target_name) {
forward_variables_from(invoker, "*")
public_configs = [ ":ncrypto_config" ]
- defines = [
- "NCRYPTO_ENGINE_COMPAT=1",
- "OPENSSL_SUPPRESS_DEPRECATED",
- ]
- sources = gypi_values.ncrypto_sources + gypi_values.ncrypto_engine_sources
+ sources = gypi_values.ncrypto_sources
deps = [ "$node_openssl_path" ]
}
}
diff --git a/deps/openssl/openssl.gyp b/deps/openssl/openssl.gyp
index 144085fd33df..d11f72a758d8 100644
--- a/deps/openssl/openssl.gyp
+++ b/deps/openssl/openssl.gyp
@@ -98,36 +98,6 @@
},
}],
]
- }, {
- # openssl-fipsmodule target
- 'target_name': 'openssl-fipsmodule',
- 'type': 'shared_library',
- 'dependencies': ['openssl-cli'],
- 'includes': ['./openssl_common.gypi'],
- 'include_dirs+': ['openssl/apps/include'],
- 'cflags': [ '-fPIC' ],
- #'ldflags': [ '-o', 'fips.so' ],
- #'ldflags': [ '-Wl,--version-script=providers/fips.ld',],
- 'conditions': [
- [ 'openssl_no_asm==1', {
- 'includes': ['./openssl-fips_no_asm.gypi'],
- }, 'target_arch=="arm64" and OS=="win"', {
- # VC-WIN64-ARM inherits from VC-noCE-common that has no asms.
- 'includes': ['./openssl-fips_no_asm.gypi'],
- }, 'gas_version and v(gas_version) >= v("2.26") or '
- 'nasm_version and v(nasm_version) >= v("2.11.8") or '
- 'llvm_version and v(llvm_version) >= v("8.0")', {
- # Require AVX512IFMA supported. See
- # https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_ia32cap.html
- # Currently crypto/poly1305/asm/poly1305-x86_64.pl requires AVX512IFMA.
- 'includes': ['./openssl-fips_asm.gypi'],
- }, {
- 'includes': ['./openssl-fips_asm_avx2.gypi'],
- }],
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [ 'openssl/include', 'openssl/crypto/include']
- }
- },
+ },
]
}
diff --git a/doc/api/cli.md b/doc/api/cli.md
index 1fd1e9864338..68966a8aa92e 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -1015,9 +1015,8 @@ priority than `--dns-result-order`.
added: v6.0.0
-->
-Enable [FIPS mode][] at startup. With OpenSSL 3, a configured provider named
-`fips` must be available and initialize successfully. With OpenSSL 1.1.1,
-Node.js must be built against a FIPS-capable OpenSSL.
+Enable [FIPS mode][] at startup. A configured provider named `fips` must be
+available and initialize successfully.
### `--enable-fips-indicator-events`
@@ -2468,8 +2467,7 @@ added: v6.9.0
-->
Load an OpenSSL configuration file on startup. The file can activate an
-OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
-[FIPS mode][].
+OpenSSL FIPS provider. See [FIPS mode][].
This option takes precedence over the `OPENSSL_CONF` environment variable.
@@ -2481,7 +2479,7 @@ added:
- v16.17.0
-->
-Enable OpenSSL 3.0 legacy provider. For more information please see
+Enable OpenSSL's legacy provider. For more information please see
[OSSL\_PROVIDER-legacy][OSSL_PROVIDER-legacy].
### `--openssl-shared-config`
diff --git a/doc/api/crypto.md b/doc/api/crypto.md
index cc20fd5c7f7c..fba693acc4a0 100644
--- a/doc/api/crypto.md
+++ b/doc/api/crypto.md
@@ -3743,8 +3743,8 @@ defaults to 16 bytes. `SIV` and `GCM-SIV` only support 16-byte authentication
tags.
The `ctsMode` and `xtsStandard` options configure parameters exposed by OpenSSL
-providers. They are available only with OpenSSL 3.0 or later and a provider
-that supports the corresponding parameter. `ctsMode` applies only to CBC-CTS
+providers. They are not available with BoringSSL and require a provider that
+supports the corresponding parameter. `ctsMode` applies only to CBC-CTS
ciphers, and `xtsStandard` applies only to `sm4-xts`. Supplying either option
for an available cipher implementation that does not support it throws an
`ERR_CRYPTO_UNSUPPORTED_OPERATION` error. See [CBC-CTS mode][] and [XTS mode][]
@@ -3848,8 +3848,8 @@ set if a different length is used. For `SIV` and `GCM-SIV`, the `authTagLength`
option defaults to 16 bytes and only 16-byte authentication tags are supported.
The `ctsMode` and `xtsStandard` options configure parameters exposed by OpenSSL
-providers. They are available only with OpenSSL 3.0 or later and a provider
-that supports the corresponding parameter. `ctsMode` applies only to CBC-CTS
+providers. They are not available with BoringSSL and require a provider that
+supports the corresponding parameter. `ctsMode` applies only to CBC-CTS
ciphers, and `xtsStandard` applies only to `sm4-xts`. Supplying either option
for an available cipher implementation that does not support it throws an
`ERR_CRYPTO_UNSUPPORTED_OPERATION` error. See [CBC-CTS mode][] and [XTS mode][]
@@ -4492,7 +4492,7 @@ Key decapsulation using a KEM algorithm with a private key.
Supported key types and their KEM algorithms are:
-* `'rsa'`[^openssl30] RSA Secret Value Encapsulation
+* `'rsa'`[^noboringssl] RSA Secret Value Encapsulation
* `'ec'`[^openssl32] DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
* `'x25519'`[^openssl32] DHKEM(X25519, HKDF-SHA256)
* `'x448'`[^openssl32] DHKEM(X448, HKDF-SHA512)
@@ -4564,7 +4564,7 @@ Key encapsulation using a KEM algorithm with a public key.
Supported key types and their KEM algorithms are:
-* `'rsa'`[^openssl30] RSA Secret Value Encapsulation
+* `'rsa'`[^noboringssl] RSA Secret Value Encapsulation
* `'ec'`[^openssl32] DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
* `'x25519'`[^openssl32] DHKEM(X25519, HKDF-SHA256)
* `'x448'`[^openssl32] DHKEM(X448, HKDF-SHA512)
@@ -4577,18 +4577,6 @@ passed to [`crypto.createPublicKey()`][].
If the `callback` function is provided this function uses libuv's threadpool.
-### `crypto.fips`
-
-
-
-> Stability: 0 - Deprecated
-
-Deprecated property for checking and controlling [FIPS mode][]. Use
-[`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
-
### `crypto.generateKey(type, options, callback)`
-
-> Stability: 0 - Deprecated
-
-* `engine` {string}
-* `flags` {crypto.constants} **Default:** `crypto.constants.ENGINE_METHOD_ALL`
-
-Load and set the `engine` for some or all OpenSSL functions (selected by flags).
-Use of this API is deprecated because custom engine support has been deprecated
-since OpenSSL 3.
-
-`engine` could be either an id or a path to the engine's shared library.
-
-The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`
-is a bit field taking one of or a mix of the following flags (defined in
-`crypto.constants`):
-
-* `crypto.constants.ENGINE_METHOD_RSA`
-* `crypto.constants.ENGINE_METHOD_DSA`
-* `crypto.constants.ENGINE_METHOD_DH`
-* `crypto.constants.ENGINE_METHOD_RAND`
-* `crypto.constants.ENGINE_METHOD_EC`
-* `crypto.constants.ENGINE_METHOD_CIPHERS`
-* `crypto.constants.ENGINE_METHOD_DIGESTS`
-* `crypto.constants.ENGINE_METHOD_PKEY_METHS`
-* `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
-* `crypto.constants.ENGINE_METHOD_ALL`
-* `crypto.constants.ENGINE_METHOD_NONE`
-
### `crypto.setFips(bool)`
-Type: Runtime
+Type: End-of-Life
-The [`crypto.fips`][] property is deprecated. Please use `crypto.setFips()`
+The `crypto.fips` property is no longer supported. Use `crypto.setFips()`
and `crypto.getFips()` instead.
An automated migration is available ([source](https://github.com/nodejs/userland-migrations/tree/main/recipes/crypto-fips-to-getFips)).
@@ -4109,8 +4112,8 @@ that are shorter than the default authentication tag length (i.e., shorter than
-Type: Runtime
+Type: End-of-Life
-OpenSSL 3 has deprecated support for custom engines with a recommendation to
-switch to its new provider model. The `clientCertEngine` option for
-`https.request()`, [`tls.createSecureContext()`][], and [`tls.createServer()`][];
-the `privateKeyEngine` and `privateKeyIdentifier` for [`tls.createSecureContext()`][];
-and [`crypto.setEngine()`][] all depend on this functionality from OpenSSL.
+The `crypto.setEngine()` API and the `crypto.constants.ENGINE_METHOD_*`
+constants have been removed. The `clientCertEngine` option for
+[`https.request()`][], [`tls.createSecureContext()`][], and
+[`tls.createServer()`][] and the `privateKeyEngine` and `privateKeyIdentifier`
+options for [`tls.createSecureContext()`][] now throw
+`ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED` when used. There is no direct
+replacement API in Node.js. OpenSSL's provider model replaces engines upstream.
### DEP0184: Instantiating `node:zlib` classes without `new`
@@ -4846,11 +4851,9 @@ async function example() {
[`crypto.createDecipheriv()`]: crypto.md#cryptocreatedecipherivalgorithm-key-iv-options
[`crypto.createHash()`]: crypto.md#cryptocreatehashalgorithm-options
[`crypto.createHmac()`]: crypto.md#cryptocreatehmacalgorithm-key-options
-[`crypto.fips`]: crypto.md#cryptofips
[`crypto.pbkdf2()`]: crypto.md#cryptopbkdf2password-salt-iterations-keylen-digest-callback
[`crypto.randomBytes()`]: crypto.md#cryptorandombytessize-callback
[`crypto.scrypt()`]: crypto.md#cryptoscryptpassword-salt-keylen-options-callback
-[`crypto.setEngine()`]: crypto.md#cryptosetengineengine-flags
[`decipher.final()`]: crypto.md#decipherfinaloutputencoding
[`decipher.setAuthTag()`]: crypto.md#deciphersetauthtagbuffer-encoding
[`dirent.parentPath`]: fs.md#direntparentpath
diff --git a/doc/api/errors.md b/doc/api/errors.md
index 9e61289e5ab9..b655947f7013 100644
--- a/doc/api/errors.md
+++ b/doc/api/errors.md
@@ -911,9 +911,8 @@ Argon2 is not supported by the current version of OpenSSL being used.
### `ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED`
-An OpenSSL engine was requested (for example, through the `clientCertEngine` or
-`privateKeyEngine` TLS options) that is not supported by the version of OpenSSL
-being used, likely due to the compile-time flag `OPENSSL_NO_ENGINE`.
+An OpenSSL engine-based TLS or HTTPS option was used after support for custom
+engines reached End-of-Life in Node.js.
@@ -930,13 +929,6 @@ An invalid value for the `key` argument has been passed to the
`crypto.ECDH()` class `computeSecret()` method. It means that the public
key lies outside of the elliptic curve.
-
-
-### `ERR_CRYPTO_ENGINE_UNKNOWN`
-
-An invalid crypto engine identifier was passed to
-[`require('node:crypto').setEngine()`][].
-
### `ERR_CRYPTO_FIPS_FORCED`
@@ -4810,7 +4802,6 @@ An error occurred trying to allocate memory. This should never happen.
[`process.send()`]: process.md#processsendmessage-sendhandle-options-callback
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn
[`readable._read()`]: stream.md#readable_readsize
-[`require('node:crypto').setEngine()`]: crypto.md#cryptosetengineengine-flags
[`require()`]: modules.md#requireid
[`server.close()`]: net.md#serverclosecallback
[`server.listen()`]: net.md#serverlisten
diff --git a/doc/api/https.md b/doc/api/https.md
index eba303b6600a..c4a95ee67491 100644
--- a/doc/api/https.md
+++ b/doc/api/https.md
@@ -428,8 +428,9 @@ a `timeout` of 5 seconds.
added: v0.3.6
changes:
- version: REPLACEME
- pr-url: https://github.com/nodejs/node/pull/63966
- description: The `clientCertEngine` option is runtime deprecated.
+ pr-url: https://github.com/nodejs/node/pull/64777
+ description: Using the `clientCertEngine` option now throws
+ `ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED`.
- version:
- v22.4.0
- v20.16.0
@@ -471,10 +472,9 @@ changes:
Makes a request to a secure web server.
The following additional `options` from [`tls.connect()`][] are also accepted:
-`ca`, `cert`, `ciphers`, `clientCertEngine` (deprecated), `crl`, `dhparam`, `ecdhCurve`,
-`honorCipherOrder`, `key`, `passphrase`, `pfx`, `rejectUnauthorized`,
-`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,
-`highWaterMark`.
+`ca`, `cert`, `ciphers`, `crl`, `dhparam`, `ecdhCurve`, `honorCipherOrder`,
+`key`, `passphrase`, `pfx`, `rejectUnauthorized`, `secureOptions`,
+`secureProtocol`, `servername`, `sessionIdContext`, `highWaterMark`.
`options` can be an object, a string, or a [`URL`][] object. If `options` is a
string, it is automatically parsed with [`new URL()`][]. If it is a [`URL`][]
diff --git a/doc/api/permissions.md b/doc/api/permissions.md
index dc5e3e6111ca..dd60f45121bd 100644
--- a/doc/api/permissions.md
+++ b/doc/api/permissions.md
@@ -362,8 +362,6 @@ There are constraints you need to know before using this system:
expanded path is not covered by `--allow-fs-write`. Because the location is
chosen by the operator, gaps like this are treated as regular bugs rather
than vulnerabilities. Please report them through the regular issue tracker.
-* OpenSSL engines cannot be requested at runtime when the Permission
- Model is enabled, affecting the built-in crypto, https, and tls modules.
* Run-Time Loadable Extensions cannot be loaded when the Permission Model is
enabled, affecting the sqlite module.
* Using existing file descriptors via the `node:fs` module bypasses the
diff --git a/doc/api/tls.md b/doc/api/tls.md
index 7df2ab938606..72efd59fd223 100644
--- a/doc/api/tls.md
+++ b/doc/api/tls.md
@@ -182,8 +182,8 @@ On the client connection, a custom `checkServerIdentity` should be passed
because the default one will fail in the absence of a certificate.
According to the [RFC 4279][], PSK identities up to 128 bytes in length and
-PSKs up to 64 bytes in length must be supported. As of OpenSSL 1.1.0
-maximum identity size is 128 bytes, and maximum PSK length is 256 bytes.
+PSKs up to 64 bytes in length must be supported. In OpenSSL the maximum
+identity size is 128 bytes, and the maximum PSK length is 256 bytes.
The current implementation doesn't support asynchronous PSK callbacks due to the
limitations of the underlying OpenSSL API.
@@ -1236,7 +1236,7 @@ For example, a TLSv1.2 protocol with AES256-SHA cipher:
```
See
-[SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html)
+[SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man3.0/man3/SSL_CIPHER_get_name.html)
for more information.
### `tlsSocket.getEphemeralKeyInfo()`
@@ -1488,7 +1488,7 @@ added: v12.11.0
the client in the order of decreasing preference.
See
-[SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html)
+[SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man3.0/man3/SSL_get_shared_sigalgs.html)
for more information.
### `tlsSocket.getTLSTicket()`
@@ -1966,9 +1966,10 @@ argument.
added: v0.11.13
changes:
- version: REPLACEME
- pr-url: https://github.com/nodejs/node/pull/63966
- description: The `clientCertEngine`, `privateKeyEngine` and
- `privateKeyIdentifier` options are runtime deprecated.
+ pr-url: https://github.com/nodejs/node/pull/64777
+ description: Using the `clientCertEngine`, `privateKeyEngine`, or
+ `privateKeyIdentifier` option now throws
+ `ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED`.
- version:
- v26.4.0
- v24.19.0
@@ -2077,14 +2078,12 @@ changes:
The list can contain digest algorithms (`SHA256`, `MD5` etc.), public key
algorithms (`RSA-PSS`, `ECDSA` etc.), combination of both (e.g
'RSA+SHA384') or TLS v1.3 scheme names (e.g. `rsa_pss_pss_sha512`).
- See [OpenSSL man pages](https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set1_sigalgs_list.html)
+ See [OpenSSL man pages](https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set1_sigalgs_list.html)
for more info.
* `ciphers` {string} Cipher suite specification, replacing the default. For
more information, see [Modifying the default TLS cipher suite][]. Permitted
ciphers can be obtained via [`tls.getCiphers()`][]. Cipher names must be
uppercased in order for OpenSSL to accept them.
- * `clientCertEngine` {string} Name of an OpenSSL engine which can provide the
- client certificate. **Deprecated.**
* `crl` {string|string\[]|Buffer|Buffer\[]} PEM formatted CRLs (Certificate
Revocation Lists).
* `dhparam` {string|Buffer} `'auto'` or custom Diffie-Hellman parameters,
@@ -2115,12 +2114,6 @@ changes:
occur in an array. `object.passphrase` is optional. Encrypted keys will be
decrypted with `object.passphrase` if provided, or `options.passphrase` if
it is not.
- * `privateKeyEngine` {string} Name of an OpenSSL engine to get private key
- from. Should be used together with `privateKeyIdentifier`. **Deprecated.**
- * `privateKeyIdentifier` {string} Identifier of a private key managed by
- an OpenSSL engine. Should be used together with `privateKeyEngine`.
- Should not be set together with `key`, because both options define a
- private key in different ways. **Deprecated.**
* `maxVersion` {string} Optionally set the maximum TLS version to allow. One
of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified
along with the `secureProtocol` option; use one or the other.
@@ -2194,8 +2187,9 @@ permissible, use 2048 bits or larger for stronger security.
added: v0.3.2
changes:
- version: REPLACEME
- pr-url: https://github.com/nodejs/node/pull/63966
- description: The `clientCertEngine` option is runtime deprecated.
+ pr-url: https://github.com/nodejs/node/pull/64777
+ description: Using the `clientCertEngine` option now throws
+ `ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED`.
- version:
- v22.4.0
- v20.16.0
@@ -2246,8 +2240,6 @@ changes:
If a string is returned that does not match one of the client's ALPN
protocols, an error will be thrown. This option cannot be used with the
`ALPNProtocols` option, and setting both options will throw an error.
- * `clientCertEngine` {string} Name of an OpenSSL engine which can provide the
- client certificate. **Deprecated.**
* `enableTrace` {boolean} If `true`, [`tls.TLSSocket.enableTrace()`][] will be
called on new connections. Tracing can be enabled after the secure
connection is established, but this option must be used to trace the secure
@@ -2584,7 +2576,7 @@ added: v0.11.3
[RFC 5077]: https://tools.ietf.org/html/rfc5077
[RFC 5929]: https://tools.ietf.org/html/rfc5929
[RFC 8879]: https://tools.ietf.org/html/rfc8879
-[SSL_METHODS]: https://www.openssl.org/docs/man1.1.1/man7/ssl.html#Dealing-with-Protocol-Methods
+[SSL_METHODS]: https://www.openssl.org/docs/man3.0/man7/ssl.html#Dealing-with-Protocol-Methods
[Session Resumption]: #session-resumption
[Stream]: stream.md#stream
[TLS recommendations]: https://wiki.mozilla.org/Security/Server_Side_TLS
@@ -2601,8 +2593,8 @@ added: v0.11.3
[`Duplex`]: stream.md#class-streamduplex
[`NODE_EXTRA_CA_CERTS`]: cli.md#node_extra_ca_certsfile
[`NODE_OPTIONS`]: cli.md#node_optionsoptions
-[`SSL_export_keying_material`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html
-[`SSL_get_version`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html
+[`SSL_export_keying_material`]: https://www.openssl.org/docs/man3.0/man3/SSL_export_keying_material.html
+[`SSL_get_version`]: https://www.openssl.org/docs/man3.0/man3/SSL_get_version.html
[`crypto.getCurves()`]: crypto.md#cryptogetcurves
[`import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
[`net.Server.address()`]: net.md#serveraddress
@@ -2636,6 +2628,6 @@ added: v0.11.3
[`x509.checkHost()`]: crypto.md#x509checkhostname-options
[asn1.js]: https://www.npmjs.com/package/asn1.js
[certificate object]: #certificate-object
-[cipher list format]: https://www.openssl.org/docs/man1.1.1/man1/ciphers.html#CIPHER-LIST-FORMAT
+[cipher list format]: https://www.openssl.org/docs/man3.0/man1/ciphers.html#CIPHER-LIST-FORMAT
[forward secrecy]: https://en.wikipedia.org/wiki/Perfect_forward_secrecy
[perfect forward secrecy]: #perfect-forward-secrecy
diff --git a/doc/api/webcrypto.md b/doc/api/webcrypto.md
index 1d94af41363c..ab105dda8c3e 100644
--- a/doc/api/webcrypto.md
+++ b/doc/api/webcrypto.md
@@ -122,15 +122,15 @@ WICG proposal:
Algorithms:
-* `'AES-OCB'`[^openssl30]
+* `'AES-OCB'`[^noboringssl]
* `'Argon2d'`[^openssl32]
* `'Argon2i'`[^openssl32]
* `'Argon2id'`[^openssl32]
* `'ChaCha20-Poly1305'`
* `'cSHAKE128'`
* `'cSHAKE256'`
-* `'KMAC128'`[^openssl30]
-* `'KMAC256'`[^openssl30]
+* `'KMAC128'`[^noboringssl]
+* `'KMAC256'`[^noboringssl]
* `'KT128'`
* `'KT256'`
* `'ML-DSA-44'`[^openssl35]
@@ -2761,7 +2761,7 @@ added:
[^modern-algos]: See [Modern Algorithms in the Web Cryptography API][]
-[^openssl30]: Requires OpenSSL >= 3.0
+[^noboringssl]: Not available when Node.js is built against BoringSSL
[^openssl32]: Requires OpenSSL >= 3.2
diff --git a/doc/node-config-schema.json b/doc/node-config-schema.json
index 07d4ac4a64ee..f0b933d19f23 100644
--- a/doc/node-config-schema.json
+++ b/doc/node-config-schema.json
@@ -512,7 +512,7 @@
},
"openssl-legacy-provider": {
"type": "boolean",
- "description": "enable OpenSSL 3.0 legacy provider"
+ "description": "enable OpenSSL's legacy provider"
},
"openssl-shared-config": {
"type": "boolean",
diff --git a/doc/node.1 b/doc/node.1
index 1b873d1eccaa..c3a458f9a573 100644
--- a/doc/node.1
+++ b/doc/node.1
@@ -577,9 +577,8 @@ The default is \fBverbatim\fR and \fBdns.setDefaultResultOrder()\fR have higher
priority than \fB--dns-result-order\fR.
.
.It Fl -enable-fips
-Enable FIPS mode at startup. With OpenSSL 3, a configured provider named
-\fBfips\fR must be available and initialize successfully. With OpenSSL 1.1.1,
-Node.js must be built against a FIPS-capable OpenSSL.
+Enable FIPS mode at startup. A configured provider named \fBfips\fR must be
+available and initialize successfully.
.
.It Fl -enable-fips-indicator-events
Publish OpenSSL FIPS indicator results to the
@@ -1236,12 +1235,11 @@ usually only useful for developers debugging Node.js itself.
.
.It Fl -openssl-config Ns = Ns Ar file
Load an OpenSSL configuration file on startup. The file can activate an
-OpenSSL 3 FIPS provider or configure a FIPS-capable OpenSSL 1.1.1 build. See
-FIPS mode.
+OpenSSL FIPS provider. See FIPS mode.
This option takes precedence over the \fBOPENSSL_CONF\fR environment variable.
.
.It Fl -openssl-legacy-provider
-Enable OpenSSL 3.0 legacy provider. For more information please see
+Enable OpenSSL's legacy provider. For more information please see
OSSL_PROVIDER-legacy.
.
.It Fl -openssl-shared-config
diff --git a/lib/crypto.js b/lib/crypto.js
index 3e720cd3bdf6..6e6c3d0552f2 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -124,7 +124,6 @@ const {
getCurves,
getHashes,
getMacs,
- setEngine,
secureHeapUsed,
} = require('internal/crypto/util');
const Certificate = require('internal/crypto/certificate');
@@ -237,7 +236,6 @@ module.exports = {
scrypt,
scryptSync,
sign: signOneShot,
- setEngine,
timingSafeEqual,
getFips,
setFips,
@@ -352,13 +350,6 @@ function getRandomBytesAlias(key) {
}
ObjectDefineProperties(module.exports, {
- fips: {
- __proto__: null,
- get: deprecate(getFips, 'The crypto.fips is deprecated. ' +
- 'Please use crypto.getFips()', 'DEP0093'),
- set: deprecate(setFips, 'The crypto.fips is deprecated. ' +
- 'Please use crypto.setFips()', 'DEP0093'),
- },
constants: {
__proto__: null,
configurable: false,
diff --git a/lib/https.js b/lib/https.js
index 75ec8bb3f895..90f61d2fec26 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -49,6 +49,9 @@ const { ERR_PROXY_TUNNEL } = require('internal/errors').codes;
assertCrypto();
const tls = require('tls');
+const {
+ validateOpenSSLEngineOptions,
+} = require('internal/tls/secure-context');
const kPerRequestCheckServerIdentity = Symbol('per-request checkServerIdentity');
let perRequestCheckServerIdentityIndex = 0;
const {
@@ -478,6 +481,7 @@ function Agent(options) {
return new Agent(options);
options = { __proto__: null, ...options };
+ validateOpenSSLEngineOptions(options);
options.defaultPort ??= 443;
options.protocol ??= 'https:';
FunctionPrototypeCall(HttpAgent, this, options);
@@ -526,6 +530,7 @@ function getPfxAgentKey(pfx, passphrase) {
* @returns {string}
*/
Agent.prototype.getName = function getName(options = kEmptyObject) {
+ validateOpenSSLEngineOptions(options);
let name = FunctionPrototypeCall(HttpAgent.prototype.getName, this, options);
name += ':';
@@ -536,10 +541,6 @@ Agent.prototype.getName = function getName(options = kEmptyObject) {
if (options.cert)
name += options.cert;
- name += ':';
- if (options.clientCertEngine)
- name += options.clientCertEngine;
-
name += ':';
if (options.ciphers)
name += options.ciphers;
@@ -600,14 +601,6 @@ Agent.prototype.getName = function getName(options = kEmptyObject) {
if (options.sigalgs)
name += JSONStringify(options.sigalgs);
- name += ':';
- if (options.privateKeyIdentifier)
- name += options.privateKeyIdentifier;
-
- name += ':';
- if (options.privateKeyEngine)
- name += options.privateKeyEngine;
-
if (options[kPerRequestCheckServerIdentity])
name += `:${options[kPerRequestCheckServerIdentity]}`;
@@ -683,6 +676,7 @@ function request(...args) {
if (args[0] && typeof args[0] !== 'function') {
ObjectAssign(options, ArrayPrototypeShift(args));
}
+ validateOpenSSLEngineOptions(options);
if (options.checkServerIdentity !== undefined &&
options.checkServerIdentity !== tls.checkServerIdentity &&
diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js
index b38db7c6603f..309640eb1afc 100644
--- a/lib/internal/crypto/util.js
+++ b/lib/internal/crypto/util.js
@@ -37,7 +37,6 @@ const {
getCurves: _getCurves,
getHashes: _getHashes,
getMacs: _getMacs,
- setEngine: _setEngine,
secureHeapUsed: _secureHeapUsed,
getCachedAliases,
getCachedMacAliases,
@@ -54,18 +53,10 @@ const isFips = getFipsCrypto() === 1;
const { getOptionValue } = require('internal/options');
-const {
- crypto: {
- ENGINE_METHOD_ALL,
- },
-} = internalBinding('constants');
-
const normalizeHashName = require('internal/crypto/hashnames');
const {
codes: {
- ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED,
- ERR_CRYPTO_ENGINE_UNKNOWN,
ERR_INVALID_ARG_TYPE,
},
hideStackFrames,
@@ -73,7 +64,6 @@ const {
const {
validateArray,
- validateNumber,
validateString,
} = require('internal/validators');
@@ -83,7 +73,6 @@ const {
cachedResult,
emitExperimentalWarning,
filterDuplicateStrings,
- getDeprecationWarningEmitter,
lazyDOMException,
setOwnProperty,
} = require('internal/util');
@@ -195,29 +184,6 @@ const getMacs = cachedArrayByFipsGeneration(
const getCurves = cachedResult(() => filterDuplicateStrings(_getCurves()));
-const emitOpenSSLEngineDeprecation = getDeprecationWarningEmitter(
- 'DEP0183',
- 'OpenSSL engine-based APIs are deprecated.',
-);
-
-function setEngine(id, flags) {
- validateString(id, 'id');
- if (flags)
- validateNumber(flags, 'flags');
- flags = flags >>> 0;
-
- // Use provided engine for everything by default
- if (flags === 0)
- flags = ENGINE_METHOD_ALL;
-
- emitOpenSSLEngineDeprecation();
-
- if (typeof _setEngine !== 'function')
- throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
- if (!_setEngine(id, flags))
- throw new ERR_CRYPTO_ENGINE_UNKNOWN(id);
-}
-
const getArrayBufferOrView = hideStackFrames((buffer, name, encoding) => {
if (isAnyArrayBuffer(buffer))
return buffer;
@@ -1191,9 +1157,7 @@ module.exports = {
getHashes,
getMacs,
getOptionalByteLength,
- emitOpenSSLEngineDeprecation,
kHandle,
- setEngine,
toBuf,
kNamedCurveAliases,
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index 27c8202c04e8..acce506d1b94 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -1175,11 +1175,10 @@ E('ERR_CONSTRUCT_CALL_REQUIRED', 'Class constructor %s cannot be invoked without
E('ERR_CONTEXT_NOT_INITIALIZED', 'context used is not initialized', Error);
E('ERR_CRYPTO_ARGON2_NOT_SUPPORTED', 'Argon2 algorithm not supported', Error);
E('ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
- 'Custom engines not supported by this OpenSSL', Error);
+ 'Custom engines not supported by this version of Node.js', Error);
E('ERR_CRYPTO_ECDH_INVALID_FORMAT', 'Invalid ECDH format: %s', TypeError);
E('ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY',
'Public key is not valid for specified curve', Error);
-E('ERR_CRYPTO_ENGINE_UNKNOWN', 'Engine "%s" was not found', Error);
E('ERR_CRYPTO_FIPS_FORCED',
'Cannot set FIPS mode, it was forced with --force-fips at startup.', Error);
E('ERR_CRYPTO_FIPS_UNAVAILABLE', 'Cannot set FIPS mode in a non-FIPS build.',
diff --git a/lib/internal/tls/secure-context.js b/lib/internal/tls/secure-context.js
index 597d4fce9271..9dccdb8aacfd 100644
--- a/lib/internal/tls/secure-context.js
+++ b/lib/internal/tls/secure-context.js
@@ -34,7 +34,6 @@ const {
} = require('internal/validators');
const {
- emitOpenSSLEngineDeprecation,
toBuf,
} = require('internal/crypto/util');
@@ -128,8 +127,26 @@ function processCiphers(ciphers, name) {
return { cipherList, cipherSuites };
}
+function validateOpenSSLEngineOptions(options) {
+ const {
+ clientCertEngine,
+ privateKeyEngine,
+ privateKeyIdentifier,
+ } = options;
+
+ // OpenSSL engine support has reached End-of-Life. Keep recognizing these
+ // options so that their use throws instead of appearing to work while being
+ // silently ignored.
+ if (clientCertEngine != null ||
+ privateKeyEngine != null ||
+ privateKeyIdentifier != null) {
+ throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
+ }
+}
+
function configSecureContext(context, options = kEmptyObject, name = 'options') {
validateObject(options, name);
+ validateOpenSSLEngineOptions(options);
const {
allowPartialTrustChain,
@@ -137,15 +154,12 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
cert,
certificateCompression,
ciphers = getDefaultCiphers(),
- clientCertEngine,
crl,
dhparam,
ecdhCurve = getDefaultEcdhCurve(),
key,
passphrase,
pfx,
- privateKeyIdentifier,
- privateKeyEngine,
sessionIdContext,
sessionTimeout,
sigalgs,
@@ -256,36 +270,6 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
context.setSigalgs(sigalgs);
}
- if (privateKeyIdentifier !== undefined && privateKeyIdentifier !== null) {
- if (privateKeyEngine === undefined || privateKeyEngine === null) {
- // Engine is required when privateKeyIdentifier is present
- throw new ERR_INVALID_ARG_VALUE(`${name}.privateKeyEngine`,
- privateKeyEngine);
- }
- if (key) {
- // Both data key and engine key can't be set at the same time
- throw new ERR_INVALID_ARG_VALUE(`${name}.privateKeyIdentifier`,
- privateKeyIdentifier);
- }
-
- if (typeof privateKeyIdentifier === 'string' &&
- typeof privateKeyEngine === 'string') {
- emitOpenSSLEngineDeprecation();
- if (context.setEngineKey)
- context.setEngineKey(privateKeyIdentifier, privateKeyEngine);
- else
- throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
- } else if (typeof privateKeyIdentifier !== 'string') {
- throw new ERR_INVALID_ARG_TYPE(`${name}.privateKeyIdentifier`,
- ['string', 'null', 'undefined'],
- privateKeyIdentifier);
- } else {
- throw new ERR_INVALID_ARG_TYPE(`${name}.privateKeyEngine`,
- ['string', 'null', 'undefined'],
- privateKeyEngine);
- }
- }
-
validateString(ecdhCurve, `${name}.ecdhCurve`);
context.setECDHCurve(ecdhCurve);
@@ -331,18 +315,6 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
}
}
- if (typeof clientCertEngine === 'string') {
- emitOpenSSLEngineDeprecation();
- if (typeof context.setClientCertEngine !== 'function')
- throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
- else
- context.setClientCertEngine(clientCertEngine);
- } else if (clientCertEngine !== undefined && clientCertEngine !== null) {
- throw new ERR_INVALID_ARG_TYPE(`${name}.clientCertEngine`,
- ['string', 'null', 'undefined'],
- clientCertEngine);
- }
-
if (ticketKeys !== undefined && ticketKeys !== null) {
validateBuffer(ticketKeys, `${name}.ticketKeys`);
if (ticketKeys.byteLength !== 48) {
@@ -362,4 +334,5 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
module.exports = {
configSecureContext,
+ validateOpenSSLEngineOptions,
};
diff --git a/lib/internal/tls/wrap.js b/lib/internal/tls/wrap.js
index a8d549a1aad9..11d26dbcba00 100644
--- a/lib/internal/tls/wrap.js
+++ b/lib/internal/tls/wrap.js
@@ -46,6 +46,9 @@ const EE = require('events');
const net = require('net');
const tls = require('tls');
const common = require('internal/tls/common');
+const {
+ validateOpenSSLEngineOptions,
+} = require('internal/tls/secure-context');
const { kReinitializeHandle } = require('internal/net');
const JSStreamSocket = require('internal/js_stream_socket');
const { Buffer } = require('buffer');
@@ -621,6 +624,7 @@ function initRead(tlsSocket, socket) {
function TLSSocket(socket, opts) {
const tlsOptions = { ...opts };
+ validateOpenSSLEngineOptions(tlsOptions);
let enableTrace = tlsOptions.enableTrace;
if (enableTrace == null) {
@@ -1454,7 +1458,6 @@ function tlsConnectionListener(rawSocket) {
// - rejectUnauthorized. Boolean, default to true.
// - key. string.
// - cert: string.
-// - clientCertEngine: string.
// - ca: string or array of strings.
// - sessionTimeout: integer.
//
@@ -1546,6 +1549,7 @@ exports.createServer = function createServer(options, listener) {
Server.prototype.setSecureContext = function(options) {
validateObject(options, 'options');
+ validateOpenSSLEngineOptions(options);
if (options.pfx)
this.pfx = options.pfx;
@@ -1567,11 +1571,6 @@ Server.prototype.setSecureContext = function(options) {
else
this.cert = undefined;
- if (options.clientCertEngine)
- this.clientCertEngine = options.clientCertEngine;
- else
- this.clientCertEngine = undefined;
-
if (options.ca)
this.ca = options.ca;
else
@@ -1638,8 +1637,6 @@ Server.prototype.setSecureContext = function(options) {
if (options.ticketKeys)
this.ticketKeys = options.ticketKeys;
- this.privateKeyIdentifier = options.privateKeyIdentifier;
- this.privateKeyEngine = options.privateKeyEngine;
this.certificateCompression = options.certificateCompression;
this._sharedCreds = tls.createSecureContext({
@@ -1647,7 +1644,6 @@ Server.prototype.setSecureContext = function(options) {
key: this.key,
passphrase: this.passphrase,
cert: this.cert,
- clientCertEngine: this.clientCertEngine,
ca: this.ca,
ciphers: this.ciphers,
sigalgs: this.sigalgs,
@@ -1662,8 +1658,6 @@ Server.prototype.setSecureContext = function(options) {
sessionIdContext: this.sessionIdContext,
ticketKeys: this.ticketKeys,
sessionTimeout: this.sessionTimeout,
- privateKeyIdentifier: this.privateKeyIdentifier,
- privateKeyEngine: this.privateKeyEngine,
certificateCompression: this.certificateCompression,
});
};
@@ -1861,6 +1855,7 @@ exports.connect = function connect(...args) {
minDHSize: 1024,
...options,
};
+ validateOpenSSLEngineOptions(options);
if (!options.keepAlive)
options.singleUse = true;
diff --git a/node.gyp b/node.gyp
index 136c1b920ffa..aa8f0fc3f6c4 100644
--- a/node.gyp
+++ b/node.gyp
@@ -770,87 +770,22 @@
},
},
}],
- ['node_fipsinstall=="true"', {
- 'variables': {
- 'openssl-cli': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)openssl-cli<(EXECUTABLE_SUFFIX)',
- 'provider_name': 'libopenssl-fipsmodule',
- 'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
- 'conditions': [
- ['GENERATOR == "ninja"', {
- 'fipsmodule_internal': '<(PRODUCT_DIR)/lib/<(provider_name).so',
- 'fipsmodule': '<(PRODUCT_DIR)/obj/lib/openssl-modules/fips.so',
- 'fipsconfig': '<(PRODUCT_DIR)/obj/lib/fipsmodule.cnf',
- 'opensslconfig_internal': '<(PRODUCT_DIR)/obj/lib/openssl.cnf',
- }, {
- 'fipsmodule_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/<(provider_name).so',
- 'fipsmodule': '<(PRODUCT_DIR)/obj.target/deps/openssl/lib/openssl-modules/fips.so',
- 'fipsconfig': '<(PRODUCT_DIR)/obj.target/deps/openssl/fipsmodule.cnf',
- 'opensslconfig_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/openssl.cnf',
- }],
- ],
- },
- 'actions': [
- {
- 'action_name': 'fipsinstall',
- 'process_outputs_as_sources': 1,
- 'inputs': [
- '<(fipsmodule_internal)',
- ],
- 'outputs': [
- '<(fipsconfig)',
- ],
- 'action': [
- '<(openssl-cli)', 'fipsinstall',
- '-provider_name', '<(provider_name)',
- '-module', '<(fipsmodule_internal)',
- '-out', '<(fipsconfig)',
- #'-quiet',
- ],
- },
- {
- 'action_name': 'copy_fips_module',
- 'inputs': [
- '<(fipsmodule_internal)',
- ],
- 'outputs': [
- '<(fipsmodule)',
- ],
- 'action': [
- '<(python)', 'tools/copyfile.py',
- '<(fipsmodule_internal)',
- '<(fipsmodule)',
- ],
- },
- {
- 'action_name': 'copy_openssl_cnf_and_include_fips_cnf',
- 'inputs': [ '<(opensslconfig)', ],
- 'outputs': [ '<(opensslconfig_internal)', ],
- 'action': [
- '<(python)', 'tools/enable_fips_include.py',
- '<(opensslconfig)',
- '<(opensslconfig_internal)',
- '<(fipsconfig)',
- ],
- },
+ ],
+ 'variables': {
+ 'opensslconfig_internal': '<(obj_dir)/deps/openssl/openssl.cnf',
+ 'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
+ },
+ 'actions': [
+ {
+ 'action_name': 'reset_openssl_cnf',
+ 'inputs': [ '<(opensslconfig)', ],
+ 'outputs': [ '<(opensslconfig_internal)', ],
+ 'action': [
+ '<(python)', 'tools/copyfile.py',
+ '<(opensslconfig)',
+ '<(opensslconfig_internal)',
],
- }, {
- 'variables': {
- 'opensslconfig_internal': '<(obj_dir)/deps/openssl/openssl.cnf',
- 'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
- },
- 'actions': [
- {
- 'action_name': 'reset_openssl_cnf',
- 'inputs': [ '<(opensslconfig)', ],
- 'outputs': [ '<(opensslconfig_internal)', ],
- 'action': [
- '<(python)', 'tools/copyfile.py',
- '<(opensslconfig)',
- '<(opensslconfig_internal)',
- ],
- },
- ],
- }],
+ },
],
}, # node_core_target_name
{
diff --git a/node.gypi b/node.gypi
index bfe2d00ad929..fa6550165764 100644
--- a/node.gypi
+++ b/node.gypi
@@ -403,7 +403,6 @@
'defines': [ 'HAVE_OPENSSL=1' ],
'conditions': [
[ 'node_shared_openssl=="false"', {
- 'defines': [ 'OPENSSL_API_COMPAT=0x10100000L', ],
'dependencies': [
'./deps/openssl/openssl.gyp:openssl',
diff --git a/src/crypto/README.md b/src/crypto/README.md
index de4883c424c4..c613b8b405a1 100644
--- a/src/crypto/README.md
+++ b/src/crypto/README.md
@@ -94,8 +94,8 @@ use their methods to keep that adaptation inside ncrypto.
Examples of these being used are pervasive through the `src/crypto` code.
`HMACCtxPointer` is a dedicated HMAC state wrapper rather than a plain
-`DeleteFnPtr` alias. On OpenSSL 3 and later it owns the provider-backed
-`EVP_MAC`/`EVP_MAC_CTX` state. On OpenSSL 1.1.1 and BoringSSL it owns the
+`DeleteFnPtr` alias. On OpenSSL it owns the provider-backed
+`EVP_MAC`/`EVP_MAC_CTX` state. On BoringSSL it owns the
legacy `HMAC_CTX` state. HMAC call sites should use `HMACCtxPointer::New()`,
`init()`, `update()`, and `digest()`/`digestInto()` so the backend selection
stays contained in ncrypto.
@@ -159,10 +159,9 @@ callers can retain descriptor pointers across asynchronous jobs. For example,
`ML-DSA-44`.
For an existing key, use `key.isA(KeyAlgorithm::RSA_PSS)` or another descriptor.
-On OpenSSL 3 and later this uses `EVP_PKEY_is_a()` to recognize provider aliases.
+On OpenSSL this uses `EVP_PKEY_is_a()` to recognize provider aliases.
Numeric key IDs are unsuitable for provider-only keys: OpenSSL can return `-1`
-for their ID. Numeric adapters for BoringSSL and legacy OpenSSL stay private to
-ncrypto.
+for their ID. Numeric adapters for BoringSSL stay private to ncrypto.
When a function needs algorithm metadata, use `key.getAlgorithm()`. It returns
a pointer to a static descriptor, or `nullptr` for an empty key or an unrecognized
diff --git a/src/crypto/crypto_aes.cc b/src/crypto/crypto_aes.cc
index bea8f5b24be5..c5a4074ad215 100644
--- a/src/crypto/crypto_aes.cc
+++ b/src/crypto/crypto_aes.cc
@@ -145,11 +145,8 @@ WebCryptoCipherStatus AES_Cipher(Environment* env,
auto buf = DataPointer::Alloc(buf_len);
auto ptr = static_cast(buf.get());
- // In some outdated version of OpenSSL (e.g.
- // ubi81_sharedlibs_openssl111fips_x64) may be used in sharedlib mode, the
- // logic will be failed when input size is zero. The newer OpenSSL has fixed
- // it up. But we still have to regard zero as special in Node.js code to
- // prevent old OpenSSL failure.
+ // Some shared OpenSSL builds fail when the input size is zero. Keep handling
+ // zero-length input in Node.js to avoid relying on backend-specific behavior.
//
// Refs:
// https://github.com/openssl/openssl/commit/420cb707b880e4fb649094241371701013eeb15f
diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc
index 348d96e60435..f28ecdae965f 100644
--- a/src/crypto/crypto_cipher.cc
+++ b/src/crypto/crypto_cipher.cc
@@ -830,8 +830,8 @@ bool CipherBase::Final(std::unique_ptr* out) {
static_cast(ctx_.getBlockSize()),
BackingStoreInitializationMode::kUninitialized);
-#if !OPENSSL_VERSION_PREREQ(3, 0)
- // OpenSSL v1.x doesn't verify the presence of the auth tag so do
+#ifdef OPENSSL_IS_BORINGSSL
+ // BoringSSL doesn't verify the presence of the auth tag so do
// it ourselves, see https://github.com/nodejs/node/issues/45874.
if (kind_ == kDecipher && ctx_.isChaCha20Poly1305() &&
auth_tag_state_ != kAuthTagSetByUser) {
diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
index 823d87e7f204..5cc32ef6022d 100644
--- a/src/crypto/crypto_context.cc
+++ b/src/crypto/crypto_context.cc
@@ -35,12 +35,8 @@ namespace node {
using ncrypto::BIOPointer;
using ncrypto::Cipher;
using ncrypto::ClearErrorOnReturn;
-using ncrypto::CryptoErrorList;
using ncrypto::DHPointer;
using ncrypto::Digest;
-#ifndef OPENSSL_NO_ENGINE
-using ncrypto::EnginePointer;
-#endif // !OPENSSL_NO_ENGINE
using ncrypto::EVPKeyPointer;
using ncrypto::KeyAlgorithm;
using ncrypto::MarkPopErrorOnReturn;
@@ -1353,11 +1349,6 @@ Local SecureContext::GetConstructorTemplate(
SetProtoMethodNoSideEffect(
isolate, tmpl, "getIssuer", GetCertificate);
-#ifndef OPENSSL_NO_ENGINE
- SetProtoMethod(isolate, tmpl, "setEngineKey", SetEngineKey);
- SetProtoMethod(isolate, tmpl, "setClientCertEngine", SetClientCertEngine);
-#endif // !OPENSSL_NO_ENGINE
-
#define SET_INTEGER_CONSTANTS(name, value) \
tmpl->Set(FIXED_ONE_BYTE_STRING(isolate, name), \
Integer::NewFromUnsigned(isolate, value));
@@ -1442,11 +1433,6 @@ void SecureContext::RegisterExternalReferences(
registry->Register(GetCertificate);
registry->Register(GetCertificate);
-#ifndef OPENSSL_NO_ENGINE
- registry->Register(SetEngineKey);
- registry->Register(SetClientCertEngine);
-#endif // !OPENSSL_NO_ENGINE
-
registry->Register(CtxGetter);
registry->Register(GetBundledRootCertificates);
@@ -1607,7 +1593,7 @@ void SecureContext::Init(const FunctionCallbackInfo& args) {
// SSLv3 is disabled because it's susceptible to downgrade attacks (POODLE.)
SSL_CTX_set_options(sc->ctx_.get(), SSL_OP_NO_SSLv2);
SSL_CTX_set_options(sc->ctx_.get(), SSL_OP_NO_SSLv3);
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
SSL_CTX_set_options(sc->ctx_.get(), SSL_OP_ALLOW_CLIENT_RENEGOTIATION);
#endif
@@ -1626,16 +1612,16 @@ void SecureContext::Init(const FunctionCallbackInfo& args) {
CHECK(SSL_CTX_set_min_proto_version(sc->ctx_.get(), min_version));
CHECK(SSL_CTX_set_max_proto_version(sc->ctx_.get(), max_version));
- // OpenSSL 1.1.0 changed the ticket key size, but the OpenSSL 1.0.x size was
- // exposed in the public API. To retain compatibility, install a callback
- // which restores the old algorithm.
+ // The ticket key size changed after the original size was exposed in the
+ // public API. To retain compatibility, install a callback which restores
+ // the old algorithm.
if (!ncrypto::CSPRNG(sc->ticket_key_name_, sizeof(sc->ticket_key_name_)) ||
!ncrypto::CSPRNG(sc->ticket_key_hmac_, sizeof(sc->ticket_key_hmac_)) ||
!ncrypto::CSPRNG(sc->ticket_key_aes_, sizeof(sc->ticket_key_aes_))) {
return THROW_ERR_CRYPTO_OPERATION_FAILED(
env, "Error generating ticket keys");
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
SSL_CTX_set_tlsext_ticket_key_evp_cb(sc->ctx_.get(),
TicketCompatibilityCallback);
#else
@@ -1718,54 +1704,6 @@ void SecureContext::SetSigalgs(const FunctionCallbackInfo& args) {
return ThrowCryptoError(env, ERR_get_error());
}
-#ifndef OPENSSL_NO_ENGINE
-void SecureContext::SetEngineKey(const FunctionCallbackInfo& args) {
- Environment* env = Environment::GetCurrent(args);
-
- SecureContext* sc;
- ASSIGN_OR_RETURN_UNWRAP(&sc, args.This());
-
- CHECK_EQ(args.Length(), 2);
-
- if (env->permission()->enabled()) [[unlikely]] {
- return THROW_ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED(
- env,
- "Programmatic selection of OpenSSL engines is unsupported while the "
- "experimental permission model is enabled");
- }
-
- CryptoErrorList errors;
- Utf8Value engine_id(env->isolate(), args[1]);
- auto engine = EnginePointer::getEngineByName(*engine_id, &errors);
- if (!engine) {
- Local exception;
- if (errors.empty()) {
- errors.add(getNodeCryptoErrorString(NodeCryptoError::ENGINE_NOT_FOUND,
- *engine_id));
- }
- if (cryptoErrorListToException(env, errors).ToLocal(&exception))
- env->isolate()->ThrowException(exception);
- return;
- }
-
- if (!engine.init(true /* finish on exit*/)) {
- return THROW_ERR_CRYPTO_OPERATION_FAILED(
- env, "Failure to initialize engine");
- }
-
- Utf8Value key_name(env->isolate(), args[0]);
- auto key = engine.loadPrivateKey(*key_name);
-
- if (!key)
- return ThrowCryptoError(env, ERR_get_error(), "ENGINE_load_private_key");
-
- if (!SSL_CTX_use_PrivateKey(sc->ctx_.get(), key.get()))
- return ThrowCryptoError(env, ERR_get_error(), "SSL_CTX_use_PrivateKey");
-
- sc->private_key_engine_ = std::move(engine);
-}
-#endif // !OPENSSL_NO_ENGINE
-
Maybe SecureContext::AddCert(Environment* env, BIOPointer&& bio) {
ClearErrorOnReturn clear_error_on_return;
// TODO(tniessen): this should be checked by the caller and not treated as ok
@@ -1947,7 +1885,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo& args) {
if (!bio)
return;
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVPKeyPointer params(PEM_read_bio_Parameters(bio.get(), nullptr));
if (params && params.isA(KeyAlgorithm::DH)) dh.reset(params.release());
#else
@@ -1971,7 +1909,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo& args) {
env->isolate(), "DH parameter is less than 2048 bits"));
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVPKeyPointer dh_pkey(dh.release());
if (!SSL_CTX_set0_tmp_dh_pkey(sc->ctx_.get(), dh_pkey.get())) {
#else
@@ -1980,7 +1918,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo& args) {
return THROW_ERR_CRYPTO_OPERATION_FAILED(
env, "Error setting temp DH parameter");
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
dh_pkey.release();
#endif
}
@@ -2188,12 +2126,12 @@ void SecureContext::Close(const FunctionCallbackInfo& args) {
namespace {
// The historical error shape for the TLS `pfx` option: the OpenSSL reason
-// string, except for OpenSSL 3's bare "unsupported" error, which on its own
+// string, except for OpenSSL's bare "unsupported" error, which on its own
// says nothing useful.
// TODO(@jasnell): Should this use ThrowCryptoError?
// NOLINTNEXTLINE(runtime/int) -- matches ERR_get_error()
void ThrowPFXError(Environment* env, unsigned long err) {
-#if OPENSSL_VERSION_MAJOR >= 3
+#ifndef OPENSSL_IS_BORINGSSL
if (ERR_GET_REASON(err) == ERR_R_UNSUPPORTED) {
return THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(
env, "Unsupported PKCS12 PFX data");
@@ -2284,53 +2222,6 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) {
}
}
-#ifndef OPENSSL_NO_ENGINE
-void SecureContext::SetClientCertEngine(
- const FunctionCallbackInfo& args) {
- Environment* env = Environment::GetCurrent(args);
- CHECK_EQ(args.Length(), 1);
- CHECK(args[0]->IsString());
-
- SecureContext* sc;
- ASSIGN_OR_RETURN_UNWRAP(&sc, args.This());
-
- MarkPopErrorOnReturn mark_pop_error_on_return;
-
- // SSL_CTX_set_client_cert_engine does not itself support multiple
- // calls by cleaning up before overwriting the client_cert_engine
- // internal context variable.
- // Instead of trying to fix up this problem we in turn also do not
- // support multiple calls to SetClientCertEngine.
- CHECK(!sc->client_cert_engine_provided_);
-
- if (env->permission()->enabled()) [[unlikely]] {
- return THROW_ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED(
- env,
- "Programmatic selection of OpenSSL engines is unsupported while the "
- "experimental permission model is enabled");
- }
-
- CryptoErrorList errors;
- const Utf8Value engine_id(env->isolate(), args[0]);
- auto engine = EnginePointer::getEngineByName(*engine_id, &errors);
- if (!engine) {
- Local exception;
- if (errors.empty()) {
- errors.add(getNodeCryptoErrorString(NodeCryptoError::ENGINE_NOT_FOUND,
- *engine_id));
- }
- if (cryptoErrorListToException(env, errors).ToLocal(&exception))
- env->isolate()->ThrowException(exception);
- return;
- }
-
- // Note that this takes another reference to `engine`.
- if (!engine.setClientCertEngine(sc->ctx_.get()))
- return ThrowCryptoError(env, ERR_get_error());
- sc->client_cert_engine_provided_ = true;
-}
-#endif // !OPENSSL_NO_ENGINE
-
void SecureContext::GetTicketKeys(const FunctionCallbackInfo& args) {
SecureContext* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
@@ -2370,7 +2261,7 @@ void SecureContext::EnableTicketKeyCallback(
SecureContext* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
SSL_CTX_set_tlsext_ticket_key_evp_cb(wrap->ctx_.get(), TicketKeyCallback);
#else
SSL_CTX_set_tlsext_ticket_key_cb(wrap->ctx_.get(), TicketKeyCallback);
@@ -2378,7 +2269,7 @@ void SecureContext::EnableTicketKeyCallback(
}
namespace {
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
bool InitTicketHmac(EVP_MAC_CTX* hctx,
const unsigned char* key,
size_t key_len) {
@@ -2402,7 +2293,7 @@ int SecureContext::TicketKeyCallback(SSL* ssl,
unsigned char* name,
unsigned char* iv,
EVP_CIPHER_CTX* ectx,
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_MAC_CTX* hctx,
#else
HMAC_CTX* hctx,
@@ -2499,7 +2390,7 @@ int SecureContext::TicketCompatibilityCallback(SSL* ssl,
unsigned char* name,
unsigned char* iv,
EVP_CIPHER_CTX* ectx,
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_MAC_CTX* hctx,
#else
HMAC_CTX* hctx,
diff --git a/src/crypto/crypto_context.h b/src/crypto/crypto_context.h
index 73aff5b628a1..af701f3f7055 100644
--- a/src/crypto/crypto_context.h
+++ b/src/crypto/crypto_context.h
@@ -106,15 +106,12 @@ class SecureContext final : public BaseObject {
static const int kTicketKeyIVIndex = 4;
protected:
- // OpenSSL structures are opaque. This is sizeof(SSL_CTX) for OpenSSL 1.1.1b:
+ // OpenSSL structures are opaque. Estimate SSL_CTX memory usage:
static const int64_t kExternalSize = 1024;
static void New(const v8::FunctionCallbackInfo& args);
static void Init(const v8::FunctionCallbackInfo& args);
static void SetKey(const v8::FunctionCallbackInfo& args);
-#ifndef OPENSSL_NO_ENGINE
- static void SetEngineKey(const v8::FunctionCallbackInfo& args);
-#endif // !OPENSSL_NO_ENGINE
static void SetCert(const v8::FunctionCallbackInfo& args);
static void AddCACert(const v8::FunctionCallbackInfo& args);
static void SetAllowPartialTrustChain(
@@ -141,10 +138,6 @@ class SecureContext final : public BaseObject {
static void GetMaxProto(const v8::FunctionCallbackInfo& args);
static void Close(const v8::FunctionCallbackInfo& args);
static void LoadPKCS12(const v8::FunctionCallbackInfo& args);
-#ifndef OPENSSL_NO_ENGINE
- static void SetClientCertEngine(
- const v8::FunctionCallbackInfo& args);
-#endif // !OPENSSL_NO_ENGINE
static void GetTicketKeys(const v8::FunctionCallbackInfo& args);
static void SetTicketKeys(const v8::FunctionCallbackInfo& args);
static void EnableTicketKeyCallback(
@@ -158,7 +151,7 @@ class SecureContext final : public BaseObject {
unsigned char* name,
unsigned char* iv,
EVP_CIPHER_CTX* ectx,
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_MAC_CTX* hctx,
#else
HMAC_CTX* hctx,
@@ -169,7 +162,7 @@ class SecureContext final : public BaseObject {
unsigned char* name,
unsigned char* iv,
EVP_CIPHER_CTX* ectx,
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
EVP_MAC_CTX* hctx,
#else
HMAC_CTX* hctx,
@@ -185,10 +178,6 @@ class SecureContext final : public BaseObject {
ncrypto::X509Pointer issuer_;
// Non-owning cache for SSL_CTX_get_cert_store(ctx_.get())
X509_STORE* own_cert_store_cache_ = nullptr;
-#ifndef OPENSSL_NO_ENGINE
- bool client_cert_engine_provided_ = false;
- ncrypto::EnginePointer private_key_engine_;
-#endif // !OPENSSL_NO_ENGINE
unsigned char ticket_key_name_[16];
unsigned char ticket_key_aes_[16];
diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc
index 28abba798da9..dc3779608323 100644
--- a/src/crypto/crypto_dh.cc
+++ b/src/crypto/crypto_dh.cc
@@ -81,20 +81,14 @@ MaybeLocal DataPointerToBuffer(Environment* env, DataPointer&& data) {
void PutDhError(int reason) {
#ifdef OPENSSL_IS_BORINGSSL
OPENSSL_PUT_ERROR(DH, reason);
-#elif NCRYPTO_USE_OPENSSL3_PROVIDER
- ERR_raise(ERR_LIB_DH, reason);
#else
- ERR_put_error(ERR_LIB_DH, 0, reason, __FILE__, __LINE__);
+ ERR_raise(ERR_LIB_DH, reason);
#endif
}
-#if defined(OPENSSL_IS_BORINGSSL) || !NCRYPTO_USE_OPENSSL3_PROVIDER
-void PutBnError(int reason) {
#ifdef OPENSSL_IS_BORINGSSL
+void PutBnError(int reason) {
OPENSSL_PUT_ERROR(BN, reason);
-#else
- ERR_put_error(ERR_LIB_BN, 0, reason, __FILE__, __LINE__);
-#endif
}
#endif
@@ -123,11 +117,7 @@ void New(const FunctionCallbackInfo& args) {
int32_t bits = args[0].As()->Value();
if (bits < 2) {
#ifndef OPENSSL_IS_BORINGSSL
-#if OPENSSL_VERSION_MAJOR >= 3
PutDhError(DH_R_MODULUS_TOO_SMALL);
-#else
- PutBnError(BN_R_BITS_TOO_SMALL);
-#endif // OPENSSL_VERSION_MAJOR >= 3
#else // OPENSSL_IS_BORINGSSL
PutBnError(BN_R_BITS_TOO_SMALL);
#endif // OPENSSL_IS_BORINGSSL
@@ -195,7 +185,7 @@ void New(const FunctionCallbackInfo& args) {
}
}
-#if NCRYPTO_USE_OPENSSL3_PROVIDER
+#if NCRYPTO_USE_OPENSSL_PROVIDER
if (BN_num_bits(bn_p.get()) >= 512 && BN_cmp(bn_g.get(), bn_p.get()) >= 0) {
PutDhError(DH_R_BAD_GENERATOR);
return ThrowCryptoError(env, ERR_get_error(), "Invalid generator");
diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc
index 976c921fee94..068a44f0ef86 100644
--- a/src/crypto/crypto_hash.cc
+++ b/src/crypto/crypto_hash.cc
@@ -82,7 +82,7 @@ constexpr BoringSSLDigest kBoringSSLDigests[] = {
void ResetHashCache(Environment* env,
uint64_t generation,
Local