@@ -4302,11 +4302,8 @@ deprecated: v10.0.0
43024302
43034303> Stability: 0 - Deprecated
43044304
4305- Property for checking and controlling whether a FIPS compliant crypto provider
4306- is currently in use. Setting to true requires a FIPS build of Node.js.
4307-
4308- This property is deprecated. Please use `crypto.setFips()` and
4309- `crypto.getFips()` instead.
4305+ Deprecated property for checking and controlling [FIPS mode][]. Use
4306+ [`crypto.getFips()`][] and [`crypto.setFips()`][] instead.
43104307
43114308### `crypto.generateKey(type, options, callback)`
43124309
@@ -4897,9 +4894,14 @@ console.log(aliceSecret === bobSecret);
48974894added: v10.0.0
48984895-->
48994896
4900- * Returns: {number} `1` if and only if a FIPS compliant crypto provider is
4901- currently in use, `0` otherwise. A future semver-major release may change
4902- the return type of this API to a {boolean}.
4897+ * Returns: {number} `1` if FIPS mode is enabled, `0` otherwise. A future
4898+ semver-major release may change the return type of this API to a {boolean}.
4899+
4900+ With OpenSSL 3, this reports whether the default property query includes
4901+ `fips=yes`. It does not establish that a FIPS provider is loaded or validated.
4902+ It can return `1` even when a requested cryptographic implementation cannot be
4903+ fetched because no loaded provider supplies a match for `fips=yes`. See [FIPS
4904+ mode][].
49034905
49044906### `crypto.getHashes()`
49054907
@@ -6171,10 +6173,33 @@ is a bit field taking one of or a mix of the following flags (defined in
61716173added: v10.0.0
61726174-->
61736175
6174- * `bool` {boolean} `true` to enable FIPS mode.
6176+ * `bool` {boolean} `true` to enable FIPS mode, `false` to disable it.
6177+
6178+ Changes [FIPS mode][]. With OpenSSL 3, this only adds or removes `fips=yes` in
6179+ the default property query. It does not install, load, initialize, or validate
6180+ a FIPS provider. For a usable FIPS configuration, install the provider and
6181+ configure OpenSSL to load it when Node.js starts, as described in [FIPS
6182+ mode][].
6183+
6184+ If no loaded provider supplies a requested cryptographic implementation
6185+ matching `fips=yes`, the call can still succeed and `crypto.getFips()` can still
6186+ return `1`, but fetching that implementation fails. Affected `node:crypto`
6187+ operations typically fail with `ERR_OSSL_EVP_UNSUPPORTED`. Operations that do
6188+ not require a new fetch, including those using previously fetched
6189+ implementations or initialized operation contexts, may still succeed. Call this
6190+ method during application initialization, before application code uses other
6191+ OpenSSL-backed APIs.
6192+
6193+ This method only affects subsequent algorithm fetches. Node.js initializes some
6194+ OpenSSL state before application code runs. When the property query must be
6195+ active from process startup, set `default_properties = fips=yes` in the OpenSSL
6196+ configuration or use [`--enable-fips`][] or [`--force-fips`][]. The command-line
6197+ flags additionally require a configured provider named `fips` to initialize and
6198+ pass its self-test; Node.js fails to start otherwise.
61756199
6176- Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
6177- Throws an error if FIPS mode is not available.
6200+ Throws an error if OpenSSL cannot change the state. FIPS mode cannot be
6201+ disabled when Node.js was started with `--force-fips`. With OpenSSL 1.1.1,
6202+ enabling FIPS mode requires a FIPS-capable OpenSSL build.
61786203
61796204### `crypto.sign(algorithm, data, key[, callback])`
61806205
@@ -6609,83 +6634,120 @@ console.log(receivedPlaintext);
66096634
66106635### FIPS mode
66116636
6612- When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
6613- OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
6614- installed by following the instructions in [OpenSSL's FIPS README file][].
6637+ Node.js exposes the FIPS support provided by the linked OpenSSL library. Node.js
6638+ is not itself FIPS validated. Validation belongs to a specific OpenSSL module or
6639+ provider and only applies when it is deployed according to its security policy.
6640+ Vendor-provided Node.js or OpenSSL builds can require a different configuration;
6641+ follow the vendor's documentation for those builds.
66156642
6616- For FIPS support in Node.js you will need:
6643+ With OpenSSL 1.1.1, Node.js must be built against a FIPS-capable OpenSSL library.
6644+
6645+ With OpenSSL 3, FIPS support uses the provider model described in the
6646+ [OpenSSL FIPS module guide][]. Using FIPS-approved implementations requires:
66176647
66186648* A correctly installed OpenSSL 3 FIPS provider.
66196649* An OpenSSL 3 [FIPS module configuration file][].
6620- * An OpenSSL 3 configuration file that references the FIPS module
6621- configuration file.
6650+ * The FIPS provider to be loaded into the OpenSSL library context used by
6651+ Node.js, normally by activating it in an OpenSSL configuration file when
6652+ Node.js starts.
6653+ * The default property query to include `fips=yes` when cryptographic
6654+ implementations are fetched. This can be set from process startup by the
6655+ OpenSSL configuration, [`--enable-fips`][], or [`--force-fips`][], or for
6656+ subsequent fetches by `crypto.setFips(true)`.
66226657
6623- Node.js will need to be configured with an OpenSSL configuration file that
6624- points to the FIPS provider. An example configuration file looks like this:
6658+ An example OpenSSL 3 configuration file looks like this:
66256659
66266660```text
66276661nodejs_conf = nodejs_init
6662+ config_diagnostics = 1
66286663
66296664.include /<absolute path>/fipsmodule.cnf
66306665
66316666[nodejs_init]
66326667providers = provider_sect
6668+ alg_section = algorithm_sect
66336669
66346670[provider_sect]
6635- default = default_sect
66366671# The fips section name should match the section name inside the
66376672# included fipsmodule.cnf.
66386673fips = fips_sect
6674+ base = base_sect
66396675
6640- [default_sect ]
6676+ [base_sect ]
66416677activate = 1
6642- ```
6643-
6644- where `fipsmodule.cnf` is the FIPS module configuration file generated from the
6645- FIPS provider installation step:
66466678
6647- ```bash
6648- openssl fipsinstall
6679+ [algorithm_sect]
6680+ default_properties = fips=yes
66496681```
66506682
6651- Set the `OPENSSL_CONF` environment variable to point to
6652- your configuration file and `OPENSSL_MODULES` to the location of the FIPS
6653- provider dynamic library. e.g.
6683+ The `fipsmodule.cnf` file is generated as part of the FIPS provider installation
6684+ and contains module integrity and self-test information. The exact command and
6685+ arguments are installation-specific; see [OpenSSL FIPS configuration][] and the
6686+ [OpenSSL FIPS module guide][]. The installation uses `openssl fipsinstall`.
6687+
6688+ The example activates the provider and enables the `fips=yes` property query
6689+ when Node.js starts. To activate the provider at startup but enable the property
6690+ query later with `crypto.setFips(true)`, omit `alg_section = algorithm_sect` and
6691+ the `[algorithm_sect]` block. The provider must still be loaded; when using this
6692+ startup configuration, keep its activation enabled. `crypto.setFips(true)`
6693+ should be called before application code uses other OpenSSL-backed APIs. It is
6694+ not equivalent to enabling the property query from process startup because
6695+ Node.js initializes some OpenSSL state before application code runs. Use the
6696+ example as written, [`--enable-fips`][], or [`--force-fips`][] when the property
6697+ query must be active from process startup.
6698+
6699+ `config_diagnostics` causes configuration errors to prevent startup instead of
6700+ being ignored. The `base` provider supplies non-cryptographic supporting
6701+ algorithms, such as encoders and decoders, that are commonly needed alongside
6702+ the FIPS provider. `default_properties = fips=yes` restricts OpenSSL's default
6703+ algorithm selection to implementations that match `fips=yes`.
6704+
6705+ Set `OPENSSL_CONF` to the OpenSSL configuration file. For a dynamically loaded
6706+ provider, `OPENSSL_MODULES` can set the directory containing the provider module.
6707+ For example:
66546708
66556709```bash
66566710export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
66576711export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
66586712```
66596713
6660- FIPS mode can then be enabled in Node.js either by:
6661-
6662- * Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
6663- * Programmatically calling `crypto.setFips(true)`.
6664-
6665- Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
6666- file. e.g.
6667-
6668- ```text
6669- nodejs_conf = nodejs_init
6670-
6671- .include /<absolute path>/fipsmodule.cnf
6672-
6673- [nodejs_init]
6674- providers = provider_sect
6675- alg_section = algorithm_sect
6676-
6677- [provider_sect]
6678- default = default_sect
6679- # The fips section name should match the section name inside the
6680- # included fipsmodule.cnf.
6681- fips = fips_sect
6682-
6683- [default_sect]
6684- activate = 1
6685-
6686- [algorithm_sect]
6687- default_properties = fips=yes
6688- ```
6714+ The [`--openssl-config`][] command-line option selects the configuration file and
6715+ takes precedence over `OPENSSL_CONF`. If neither is set, OpenSSL's default
6716+ configuration file is used.
6717+
6718+ By default, Node.js reads the `nodejs_conf` section instead of OpenSSL's usual
6719+ `openssl_conf` section. Use [`--openssl-shared-config`][] to read `openssl_conf`,
6720+ or build Node.js with `./configure --openssl-conf-name=<name>` to change the
6721+ default section name.
6722+
6723+ On OpenSSL 3, the configuration above enables the `fips=yes` property query at
6724+ startup. The following controls are also available:
6725+
6726+ * [`--enable-fips`][] and [`--force-fips`][] enable the property query and
6727+ additionally require the configured provider named `fips` to initialize and
6728+ pass its self-test. Node.js exits if that check fails. `--force-fips` also
6729+ prevents FIPS mode from being disabled from script code.
6730+ * [`crypto.setFips()`][] changes the FIPS/property-query state. On OpenSSL 3, it
6731+ does not install, load, initialize, or validate a provider. Implementations
6732+ fetched before the call are not changed.
6733+ * [`crypto.getFips()`][] reports the FIPS/property-query state. On OpenSSL 3, a
6734+ return value of `1` does not prove that a FIPS provider is loaded or validated.
6735+
6736+ With OpenSSL 1.1.1, these controls use the library's FIPS mode support and
6737+ require a FIPS-capable OpenSSL build.
6738+
6739+ Only algorithms available under the active FIPS settings can be used. With
6740+ OpenSSL 3, if no loaded provider supplies a requested cryptographic
6741+ implementation matching `fips=yes`, fetching it fails, typically with
6742+ `ERR_OSSL_EVP_UNSUPPORTED`. The same error can occur for algorithms that
6743+ Node.js supports when FIPS mode is disabled but that are unavailable under the
6744+ active FIPS settings.
6745+
6746+ OpenSSL documents that the same FIPS provider cannot be used by multiple copies
6747+ of `libcrypto` in one process. This can affect native addons that load another
6748+ copy of `libcrypto`; OpenSSL's documented workaround is to use a separate copy
6749+ of the provider for each `libcrypto` instance. See [OpenSSL FIPS provider
6750+ limitations][].
66896751
66906752## Crypto constants
66916753
@@ -6968,15 +7030,17 @@ See the [list of SSL OP Flags][] for details.
69687030[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
69697031[Caveats]: #support-for-weak-or-compromised-algorithms
69707032[Crypto constants]: #crypto-constants
6971- [FIPS module configuration file ]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
6972- [FIPS provider from OpenSSL 3 ]: https://www .openssl.org/docs/man3 .0/man7/crypto.html#FIPS-provider
7033+ [FIPS mode ]: #fips-mode
7034+ [FIPS module configuration file ]: https://docs .openssl.org/3 .0/man5/fips_config/
69737035[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
69747036[JWK]: https://tools.ietf.org/html/rfc7517
69757037[Key usages]: webcrypto.md#cryptokeyusages
69767038[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
69777039[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
69787040[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6979- [OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
7041+ [OpenSSL FIPS configuration]: https://docs.openssl.org/3.0/man5/fips_config/
7042+ [OpenSSL FIPS module guide]: https://docs.openssl.org/master/man7/fips_module/
7043+ [OpenSSL FIPS provider limitations]: https://docs.openssl.org/3.6/man7/OSSL_PROVIDER-FIPS/
69807044[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
69817045[Permission Model]: permissions.md#permission-model
69827046[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6993,6 +7057,10 @@ See the [list of SSL OP Flags][] for details.
69937057[RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562.txt
69947058[Web Crypto API documentation]: webcrypto.md
69957059[`--allow-openssl-store`]: cli.md#--allow-openssl-store
7060+ [`--enable-fips`]: cli.md#--enable-fips
7061+ [`--force-fips`]: cli.md#--force-fips
7062+ [`--openssl-config`]: cli.md#--openssl-configfile
7063+ [`--openssl-shared-config`]: cli.md#--openssl-shared-config
69967064[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
69977065[`Buffer`]: buffer.md
69987066[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
@@ -7019,6 +7087,7 @@ See the [list of SSL OP Flags][] for details.
70197087[`crypto.generateKeyPair()`]: #cryptogeneratekeypairtype-options-callback
70207088[`crypto.getCurves()`]: #cryptogetcurves
70217089[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
7090+ [`crypto.getFips()`]: #cryptogetfips
70227091[`crypto.getHashes()`]: #cryptogethashes
70237092[`crypto.hash()`]: #cryptohashalgorithm-data-options
70247093[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
@@ -7027,6 +7096,7 @@ See the [list of SSL OP Flags][] for details.
70277096[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
70287097[`crypto.randomBytes()`]: #cryptorandombytessize-callback
70297098[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
7099+ [`crypto.setFips()`]: #cryptosetfipsbool
70307100[`crypto.sign()`]: #cryptosignalgorithm-data-key-callback
70317101[`crypto.verify()`]: #cryptoverifyalgorithm-data-key-signature-callback
70327102[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray
0 commit comments