xref: /freebsd/crypto/openssl/README-FIPS.md (revision aa7957345732816fb0ba8308798d2f79f45597f9)
1b077aed3SPierre ProncheryOpenSSL FIPS support
2b077aed3SPierre Pronchery====================
3b077aed3SPierre Pronchery
4b077aed3SPierre ProncheryThis release of OpenSSL includes a cryptographic module that can be
5*aa795734SPierre ProncheryFIPS validated. The module is implemented as an OpenSSL provider.
6b077aed3SPierre ProncheryA provider is essentially a dynamically loadable module which implements
7b077aed3SPierre Proncherycryptographic algorithms, see the [README-PROVIDERS](README-PROVIDERS.md) file
8b077aed3SPierre Proncheryfor further details.
9b077aed3SPierre Pronchery
10b077aed3SPierre ProncheryA cryptographic module is only FIPS validated after it has gone through the complex
11b077aed3SPierre ProncheryFIPS 140 validation process. As this process takes a very long time, it is not
12b077aed3SPierre Proncherypossible to validate every minor release of OpenSSL.
13b077aed3SPierre ProncheryIf you need a FIPS validated module then you must ONLY generate a FIPS provider
14b077aed3SPierre Proncheryusing OpenSSL versions that have valid FIPS certificates. A FIPS certificate
15b077aed3SPierre Proncherycontains a link to a Security Policy, and you MUST follow the instructions
16b077aed3SPierre Proncheryin the Security Policy in order to be FIPS compliant.
17b077aed3SPierre ProncherySee <https://www.openssl.org/source/> for information related to OpenSSL
18b077aed3SPierre ProncheryFIPS certificates and Security Policies.
19b077aed3SPierre Pronchery
20b077aed3SPierre ProncheryNewer OpenSSL Releases that include security or bug fixes can be used to build
21b077aed3SPierre Proncheryall other components (such as the core API's, TLS and the default, base and
22b077aed3SPierre Proncherylegacy providers) without any restrictions, but the FIPS provider must be built
23b077aed3SPierre Proncheryas specified in the Security Policy (normally with a different version of the
24b077aed3SPierre Proncherysource code).
25b077aed3SPierre Pronchery
26b077aed3SPierre ProncheryThe OpenSSL FIPS provider is a shared library called `fips.so` (on Unix), or
27b077aed3SPierre Proncheryresp. `fips.dll` (on Windows). The FIPS provider does not get built and
28b077aed3SPierre Proncheryinstalled automatically. To enable it, you need to configure OpenSSL using
29b077aed3SPierre Proncherythe `enable-fips` option.
30b077aed3SPierre Pronchery
31*aa795734SPierre ProncheryInstalling the FIPS provider
32*aa795734SPierre Pronchery============================
33*aa795734SPierre Pronchery
34*aa795734SPierre ProncheryIn order to be FIPS compliant you must only use FIPS validated source code.
35*aa795734SPierre ProncheryRefer to <https://www.openssl.org/source/> for information related to
36*aa795734SPierre Proncherywhich versions are FIPS validated. The instructions given below build OpenSSL
37*aa795734SPierre Proncheryjust using the FIPS validated source code.
38*aa795734SPierre Pronchery
39*aa795734SPierre ProncheryIf you want to use a validated FIPS provider, but also want to use the latest
40*aa795734SPierre ProncheryOpenSSL release to build everything else, then refer to the next section.
41b077aed3SPierre Pronchery
42b077aed3SPierre ProncheryThe following is only a guide.
43b077aed3SPierre ProncheryPlease read the Security Policy for up to date installation instructions.
44b077aed3SPierre Pronchery
45b077aed3SPierre ProncheryIf the FIPS provider is enabled, it gets installed automatically during the
46b077aed3SPierre Proncherynormal installation process. Simply follow the normal procedure (configure,
47b077aed3SPierre Proncherymake, make test, make install) as described in the [INSTALL](INSTALL.md) file.
48b077aed3SPierre Pronchery
49b077aed3SPierre ProncheryFor example, on Unix the final command
50b077aed3SPierre Pronchery
51b077aed3SPierre Pronchery    $ make install
52b077aed3SPierre Pronchery
53b077aed3SPierre Proncheryeffectively executes the following install targets
54b077aed3SPierre Pronchery
55b077aed3SPierre Pronchery    $ make install_sw
56b077aed3SPierre Pronchery    $ make install_ssldirs
57b077aed3SPierre Pronchery    $ make install_docs
58b077aed3SPierre Pronchery    $ make install_fips     # for `enable-fips` only
59b077aed3SPierre Pronchery
60b077aed3SPierre ProncheryThe `install_fips` make target can also be invoked explicitly to install
61b077aed3SPierre Proncherythe FIPS provider independently, without installing the rest of OpenSSL.
62b077aed3SPierre Pronchery
63b077aed3SPierre ProncheryThe Installation of the FIPS provider consists of two steps. In the first step,
64b077aed3SPierre Proncherythe shared library is copied to its installed location, which by default is
65b077aed3SPierre Pronchery
66b077aed3SPierre Pronchery    /usr/local/lib/ossl-modules/fips.so                  on Unix, and
67b077aed3SPierre Pronchery    C:\Program Files\OpenSSL\lib\ossl-modules\fips.dll   on Windows.
68b077aed3SPierre Pronchery
69b077aed3SPierre ProncheryIn the second step, the `openssl fipsinstall` command is executed, which completes
70b077aed3SPierre Proncherythe installation by doing the following two things:
71b077aed3SPierre Pronchery
72b077aed3SPierre Pronchery- Runs the FIPS module self tests
73b077aed3SPierre Pronchery- Generates the so-called FIPS module configuration file containing information
74*aa795734SPierre Pronchery  about the module such as the module checksum (and for OpenSSL 3.0 the
75*aa795734SPierre Pronchery  self test status).
76b077aed3SPierre Pronchery
77b077aed3SPierre ProncheryThe FIPS module must have the self tests run, and the FIPS module config file
78*aa795734SPierre Proncheryoutput generated on every machine that it is to be used on. For OpenSSL 3.0,
79*aa795734SPierre Proncheryyou must not copy the FIPS module config file output data from one machine to another.
80b077aed3SPierre Pronchery
81b077aed3SPierre ProncheryOn Unix the `openssl fipsinstall` command will be invoked as follows by default:
82b077aed3SPierre Pronchery
83b077aed3SPierre Pronchery    $ openssl fipsinstall -out /usr/local/ssl/fipsmodule.cnf -module /usr/local/lib/ossl-modules/fips.so
84b077aed3SPierre Pronchery
85b077aed3SPierre ProncheryIf you configured OpenSSL to be installed to a different location, the paths will
86b077aed3SPierre Proncheryvary accordingly. In the rare case that you need to install the fipsmodule.cnf
87*aa795734SPierre Proncheryto a non-standard location, you can execute the `openssl fipsinstall` command manually.
88*aa795734SPierre Pronchery
89*aa795734SPierre ProncheryInstalling the FIPS provider and using it with the latest release
90*aa795734SPierre Pronchery=================================================================
91*aa795734SPierre Pronchery
92*aa795734SPierre ProncheryThis normally requires you to download 2 copies of the OpenSSL source code.
93*aa795734SPierre Pronchery
94*aa795734SPierre ProncheryDownload and build a validated FIPS provider
95*aa795734SPierre Pronchery--------------------------------------------
96*aa795734SPierre Pronchery
97*aa795734SPierre ProncheryRefer to <https://www.openssl.org/source/> for information related to
98*aa795734SPierre Proncherywhich versions are FIPS validated. For this example we use OpenSSL 3.0.0.
99*aa795734SPierre Pronchery
100*aa795734SPierre Pronchery    $ wget https://www.openssl.org/source/openssl-3.0.0.tar.gz
101*aa795734SPierre Pronchery    $ tar -xf openssl-3.0.0.tar.gz
102*aa795734SPierre Pronchery    $ cd openssl-3.0.0
103*aa795734SPierre Pronchery    $ ./Configure enable-fips
104*aa795734SPierre Pronchery    $ make
105*aa795734SPierre Pronchery    $ cd ..
106*aa795734SPierre Pronchery
107*aa795734SPierre ProncheryDownload and build the latest release of OpenSSL
108*aa795734SPierre Pronchery------------------------------------------------
109*aa795734SPierre Pronchery
110*aa795734SPierre ProncheryWe use OpenSSL 3.1.0 here, (but you could also use the latest 3.0.X)
111*aa795734SPierre Pronchery
112*aa795734SPierre Pronchery    $ wget https://www.openssl.org/source/openssl-3.1.0.tar.gz
113*aa795734SPierre Pronchery    $ tar -xf openssl-3.1.0.tar.gz
114*aa795734SPierre Pronchery    $ cd openssl-3.1.0
115*aa795734SPierre Pronchery    $ ./Configure enable-fips
116*aa795734SPierre Pronchery    $ make
117*aa795734SPierre Pronchery
118*aa795734SPierre ProncheryUse the OpenSSL FIPS provider for testing
119*aa795734SPierre Pronchery-----------------------------------------
120*aa795734SPierre Pronchery
121*aa795734SPierre ProncheryWe do this by replacing the artifact for the OpenSSL 3.1.0 FIPS provider.
122*aa795734SPierre ProncheryNote that the OpenSSL 3.1.0 FIPS provider has not been validated
123*aa795734SPierre Proncheryso it must not be used for FIPS purposes.
124*aa795734SPierre Pronchery
125*aa795734SPierre Pronchery    $ cp ../openssl-3.0.0/providers/fips.so providers/.
126*aa795734SPierre Pronchery    $ cp ../openssl-3.0.0/providers/fipsmodule.cnf providers/.
127*aa795734SPierre Pronchery    // Note that for OpenSSL 3.0 that the `fipsmodule.cnf` file should not
128*aa795734SPierre Pronchery    // be copied across multiple machines if it contains an entry for
129*aa795734SPierre Pronchery    // `install-status`. (Otherwise the self tests would be skipped).
130*aa795734SPierre Pronchery
131*aa795734SPierre Pronchery    // Validate the output of the following to make sure we are using the
132*aa795734SPierre Pronchery    // OpenSSL 3.0.0 FIPS provider
133*aa795734SPierre Pronchery    $ ./util/wrap.pl -fips apps/openssl list -provider-path providers \
134*aa795734SPierre Pronchery    -provider fips -providers
135*aa795734SPierre Pronchery
136*aa795734SPierre Pronchery    // Now run the current tests using the OpenSSL 3.0 FIPS provider.
137*aa795734SPierre Pronchery    $ make tests
138*aa795734SPierre Pronchery
139*aa795734SPierre ProncheryCopy the FIPS provider artifacts (`fips.so` & `fipsmodule.cnf`) to known locations
140*aa795734SPierre Pronchery-------------------------------------------------------------------------------------
141*aa795734SPierre Pronchery
142*aa795734SPierre Pronchery    $ cd ../openssl-3.0.0
143*aa795734SPierre Pronchery    $ sudo make install_fips
144*aa795734SPierre Pronchery
145*aa795734SPierre ProncheryCheck that the correct FIPS provider is being used
146*aa795734SPierre Pronchery--------------------------------------------------
147*aa795734SPierre Pronchery
148*aa795734SPierre Pronchery    $./util/wrap.pl -fips apps/openssl list -provider-path providers \
149*aa795734SPierre Pronchery    -provider fips -providers
150*aa795734SPierre Pronchery
151*aa795734SPierre Pronchery    // This should produce the following output
152*aa795734SPierre Pronchery    Providers:
153*aa795734SPierre Pronchery      base
154*aa795734SPierre Pronchery        name: OpenSSL Base Provider
155*aa795734SPierre Pronchery        version: 3.1.0
156*aa795734SPierre Pronchery        status: active
157*aa795734SPierre Pronchery      fips
158*aa795734SPierre Pronchery        name: OpenSSL FIPS Provider
159*aa795734SPierre Pronchery        version: 3.0.0
160*aa795734SPierre Pronchery        status: active
161b077aed3SPierre Pronchery
162b077aed3SPierre ProncheryUsing the FIPS Module in applications
163b077aed3SPierre Pronchery=====================================
164b077aed3SPierre Pronchery
165b077aed3SPierre ProncheryDocumentation about using the FIPS module is available on the [fips_module(7)]
166b077aed3SPierre Proncherymanual page.
167b077aed3SPierre Pronchery
168b077aed3SPierre Pronchery [fips_module(7)]: https://www.openssl.org/docs/man3.0/man7/fips_module.html
169