5 OSSL_PROVIDER-FIPS - OPENSSL FIPS provider
9 The OPENSSL FIPS provider is a special provider that conforms to the Federal
10 Information Processing Standards (FIPS) specified in FIPS 140-2. This 'module'
11 contains an approved set of cryptographic algorithms that is validated by an
12 accredited testing laboratory.
16 One of the requirements for the FIPS module is self testing. An optional callback
17 mechanism is available to return information to the user using
18 L<OSSL_SELF_TEST_set_callback(3)>.
20 The OPENSSL FIPS module uses the following mechanism to provide information
21 about the self tests as they run.
22 This is useful for debugging if a self test is failing.
23 The callback also allows forcing any self test to fail, in order to check that
24 it operates correctly on failure.
26 The 'args' parameter of B<OSSL_CALLBACK> contains the B<OPENSSL_CTX> associated
27 with the provider that is triggering the self test. This may be useful if
28 multiple fips providers are present.
30 The OSSL_PARAM names used are:
34 =item "st-phase" (B<OSSL_PROV_PARAM_SELF_TEST_PHASE>) <UTF8 string>
36 Each self test calls the callback 3 times with the following string values
41 =item "Start" (B<OSSL_SELF_TEST_PHASE_START>)
43 This is the initial phase before the self test has run.
44 This is used for informational purposes only.
45 The value returned by the callback is ignored.
47 =item "Corrupt" (B<OSSL_SELF_TEST_PHASE_CORRUPT>)
49 The corrupt phase is run after the self test has calculated its known value.
50 The callback may be used to force the self test to fail by returning a value
51 of 0 from the callback during this phase.
52 Returning any other value from the callback causes the self test to run normally.
54 =item "Pass" (B<OSSL_SELF_TEST_PHASE_PASS>)
56 =item "Fail" (B<OSSL_SELF_TEST_PHASE_FAIL>)
58 The final phase runs after the self test is complete and indicates if a self
59 test passed or failed. This is used for informational purposes only.
60 The value returned by the callback is ignored.
61 "Fail" should normally only be returned if any self test was forced to fail
62 during the "Corrupt" phase (or if there was an error such as the integrity
63 check of the module failed).
65 Note that all self tests run even if a self test failure occurs.
69 =item "st-type" (B<OSSL_PROV_PARAM_SELF_TEST_TYPE>) <UTF8 string>
71 Used as a category to identify the type of self test being run.
72 It includes the following string values:
76 =item "Module_Integrity" (B<OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY>)
78 Uses HMAC SHA256 on the module file to validate that the module has not been
79 modified. The integrity value is compared to a value written to a configuration
80 file during installation.
82 =item "Install_Integrity" (B<OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY>)
84 Uses HMAC SHA256 on a fixed string to validate that the installation process
85 has already been performed and the self test KATS have already been tested,
86 The integrity value is compared to a value written to a configuration
87 file after successfully running the self tests during installation.
89 =item "KAT_Cipher" (B<OSSL_SELF_TEST_TYPE_KAT_CIPHER>)
91 Known answer test for a symmetric cipher.
93 =item "KAT_Digest" (B<OSSL_SELF_TEST_TYPE_KAT_DIGEST>)
95 Known answer test for a digest.
97 =item "KAT_Signature" (B<OSSL_SELF_TEST_TYPE_KAT_SIGNATURE>)
99 Known answer test for a signature.
101 =item "KAT_KDF" (B<OSSL_SELF_TEST_TYPE_KAT_KDF>)
103 Known answer test for a key derivation function.
105 =item "KAT_KA" (B<OSSL_SELF_TEST_TYPE_KAT_KA>)
107 Known answer test for key agreement.
109 =item "DRBG" (B<OSSL_SELF_TEST_TYPE_DRBG>)
111 Known answer test for a Deterministic Random Bit Generator.
113 =item "Pairwise_Consistency_Test" (B<OSSL_SELF_TEST_TYPE_PCT>)
115 Conditional test that is run during the generation of key pairs.
119 The "Module_Integrity" self test is always run at startup.
120 The "Install_Integrity" self test is used to check if the self tests have
121 already been run at installation time. If they have already run then the
122 self tests are not run on subsequent startups.
123 All other self test categories are run once at installation time, except for the
124 "Pairwise_Consistency_Test".
126 There is only one instance of the "Module_Integrity" and "Install_Integrity"
127 self tests. All other self tests may have multiple instances.
129 =item "st-desc" (B<OSSL_PROV_PARAM_SELF_TEST_DESC>) <UTF8 string>
131 Used as a sub category to identify an individual self test.
132 The following description strings are used.
136 =item "HMAC" (B<OSSL_SELF_TEST_DESC_INTEGRITY_HMAC>)
138 "Module_Integrity" and "Install_Integrity" use this.
140 =item "RSA" (B<OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1>)
142 =item "ECDSA" (B<OSSL_SELF_TEST_DESC_PCT_ECDSA>)
144 =item "DSA" (B<OSSL_SELF_TEST_DESC_PCT_DSA>)
146 Key generation tests used with the "Pairwise_Consistency_Test" type.
148 =item "AES_GCM" (B<OSSL_SELF_TEST_DESC_CIPHER_AES_GCM>)
150 =item "TDES" (B<OSSL_SELF_TEST_DESC_CIPHER_TDES>)
152 Symmetric cipher tests used with the "KAT_Cipher" type.
154 =item "SHA1" (B<OSSL_SELF_TEST_DESC_MD_SHA1>)
156 =item "SHA2" (B<OSSL_SELF_TEST_DESC_MD_SHA2>)
158 =item "SHA3" (B<OSSL_SELF_TEST_DESC_MD_SHA3>)
160 Digest tests used with the "KAT_Digest" type.
162 =item "DSA" (B<OSSL_SELF_TEST_DESC_SIGN_DSA>)
164 =item "RSA" (B<OSSL_SELF_TEST_DESC_SIGN_RSA>)
166 =item "ECDSA" (B<OSSL_SELF_TEST_DESC_SIGN_ECDSA>)
168 Signature tests used with the "KAT_Signature" type.
170 =item "ECDH" (B<OSSL_SELF_TEST_DESC_KA_ECDH>)
172 =item "ECDSA" (B<OSSL_SELF_TEST_DESC_KA_ECDSA>)
174 Key agreement tests used with the "KAT_KA" type.
176 =item "HKDF" (B<OSSL_SELF_TEST_DESC_KDF_HKDF>)
178 Key Derivation Function tests used with the "KAT_KDF" type.
180 =item "CTR" (B<OSSL_SELF_TEST_DESC_DRBG_CTR>)
182 =item "HASH" (B<OSSL_SELF_TEST_DESC_DRBG_HASH>)
184 =item "HMAC" (B<OSSL_SELF_TEST_DESC_DRBG_HMAC>)
186 DRBG tests used with the "DRBG" type.
194 A simple self test callback is shown below for illustrative purposes.
196 #include <openssl/self_test.h>
198 static OSSL_CALLBACK self_test_cb;
200 static int self_test_cb(const OSSL_PARAM params[], void *arg)
203 const OSSL_PARAM *p = NULL;
204 const char *phase = NULL, *type = NULL, *desc = NULL;
206 p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
207 if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
209 phase = (const char *)p->data;
211 p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
212 if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
214 desc = (const char *)p->data;
216 p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
217 if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
219 type = (const char *)p->data;
221 /* Do some logging */
222 if (strcmp(phase, OSSL_SELF_TEST_PHASE_START) == 0)
223 BIO_printf(bio_out, "%s : (%s) : ", desc, type);
224 if (strcmp(phase, OSSL_SELF_TEST_PHASE_PASS) == 0
225 || strcmp(phase, OSSL_SELF_TEST_PHASE_FAIL) == 0)
226 BIO_printf(bio_out, "%s\n", phase);
228 /* Corrupt the SHA1 self test during the 'corrupt' phase by returning 0 */
229 if (strcmp(phase, OSSL_SELF_TEST_PHASE_CORRUPT) == 0
230 && strcmp(desc, OSSL_SELF_TEST_DESC_MD_SHA1) == 0) {
231 BIO_printf(bio_out, "%s %s", phase, desc);
241 L<openssl-fipsinstall(1)>,
243 L<OSSL_SELF_TEST_set_callback(3)>,
249 The type and functions described here were added in OpenSSL 3.0.
253 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
255 Licensed under the Apache License 2.0 (the "License"). You may not use
256 this file except in compliance with the License. You can obtain a copy
257 in the file LICENSE in the source distribution or at
258 L<https://www.openssl.org/source/license.html>.