Fix some missing doc links.
[openssl.git] / doc / man7 / OSSL_PROVIDER-FIPS.pod
1 =pod
2
3 =head1 NAME
4
5 OSSL_PROVIDER-FIPS - OPENSSL FIPS provider
6
7 =head1 DESCRIPTION
8
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.
13
14 =head1 SELF TESTING
15
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)>.
19
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.
25
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.
29
30 The OSSL_PARAM names used are:
31
32 =over 4
33
34 =item "st-phase" (B<OSSL_PROV_PARAM_SELF_TEST_PHASE>) <UTF8 string>
35
36 Each self test calls the callback 3 times with the following string values
37 for the phase.
38
39 =over 4
40
41 =item "Start" (B<OSSL_SELF_TEST_PHASE_START>)
42
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.
46
47 =item "Corrupt" (B<OSSL_SELF_TEST_PHASE_CORRUPT>)
48
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.
53
54 =item "Pass" (B<OSSL_SELF_TEST_PHASE_PASS>)
55
56 =item "Fail" (B<OSSL_SELF_TEST_PHASE_FAIL>)
57
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).
64
65 Note that all self tests run even if a self test failure occurs.
66
67 =back
68
69 =item "st-type" (B<OSSL_PROV_PARAM_SELF_TEST_TYPE>) <UTF8 string>
70
71 Used as a category to identify the type of self test being run.
72 It includes the following string values:
73
74 =over 4
75
76 =item "Module_Integrity" (B<OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY>)
77
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.
81
82 =item "Install_Integrity" (B<OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY>)
83
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.
88
89 =item "KAT_Cipher" (B<OSSL_SELF_TEST_TYPE_KAT_CIPHER>)
90
91 Known answer test for a symmetric cipher.
92
93 =item "KAT_Digest" (B<OSSL_SELF_TEST_TYPE_KAT_DIGEST>)
94
95 Known answer test for a digest.
96
97 =item "KAT_Signature" (B<OSSL_SELF_TEST_TYPE_KAT_SIGNATURE>)
98
99 Known answer test for a signature.
100
101 =item "KAT_KDF" (B<OSSL_SELF_TEST_TYPE_KAT_KDF>)
102
103 Known answer test for a key derivation function.
104
105 =item "KAT_KA" (B<OSSL_SELF_TEST_TYPE_KAT_KA>)
106
107 Known answer test for key agreement.
108
109 =item "DRBG" (B<OSSL_SELF_TEST_TYPE_DRBG>)
110
111 Known answer test for a Deterministic Random Bit Generator.
112
113 =item "Pairwise_Consistency_Test" (B<OSSL_SELF_TEST_TYPE_PCT>)
114
115 Conditional test that is run during the generation of key pairs.
116
117 =back
118
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".
125
126 There is only one instance of the "Module_Integrity" and "Install_Integrity"
127 self tests. All other self tests may have multiple instances.
128
129 =item "st-desc" (B<OSSL_PROV_PARAM_SELF_TEST_DESC>) <UTF8 string>
130
131 Used as a sub category to identify an individual self test.
132 The following description strings are used.
133
134 =over 4
135
136 =item "HMAC" (B<OSSL_SELF_TEST_DESC_INTEGRITY_HMAC>)
137
138 "Module_Integrity" and "Install_Integrity" use this.
139
140 =item "RSA" (B<OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1>)
141
142 =item "ECDSA" (B<OSSL_SELF_TEST_DESC_PCT_ECDSA>)
143
144 =item "DSA" (B<OSSL_SELF_TEST_DESC_PCT_DSA>)
145
146 Key generation tests used with the "Pairwise_Consistency_Test" type.
147
148 =item "AES_GCM" (B<OSSL_SELF_TEST_DESC_CIPHER_AES_GCM>)
149
150 =item "TDES" (B<OSSL_SELF_TEST_DESC_CIPHER_TDES>)
151
152 Symmetric cipher tests used with the "KAT_Cipher" type.
153
154 =item "SHA1" (B<OSSL_SELF_TEST_DESC_MD_SHA1>)
155
156 =item "SHA2" (B<OSSL_SELF_TEST_DESC_MD_SHA2>)
157
158 =item "SHA3" (B<OSSL_SELF_TEST_DESC_MD_SHA3>)
159
160 Digest tests used with the "KAT_Digest" type.
161
162 =item "DSA" (B<OSSL_SELF_TEST_DESC_SIGN_DSA>)
163
164 =item "RSA" (B<OSSL_SELF_TEST_DESC_SIGN_RSA>)
165
166 =item "ECDSA" (B<OSSL_SELF_TEST_DESC_SIGN_ECDSA>)
167
168 Signature tests used with the "KAT_Signature" type.
169
170 =item "ECDH" (B<OSSL_SELF_TEST_DESC_KA_ECDH>)
171
172 =item "ECDSA" (B<OSSL_SELF_TEST_DESC_KA_ECDSA>)
173
174 Key agreement tests used with the "KAT_KA" type.
175
176 =item "HKDF" (B<OSSL_SELF_TEST_DESC_KDF_HKDF>)
177
178 Key Derivation Function tests used with the "KAT_KDF" type.
179
180 =item "CTR" (B<OSSL_SELF_TEST_DESC_DRBG_CTR>)
181
182 =item "HASH" (B<OSSL_SELF_TEST_DESC_DRBG_HASH>)
183
184 =item "HMAC" (B<OSSL_SELF_TEST_DESC_DRBG_HMAC>)
185
186 DRBG tests used with the "DRBG" type.
187
188 =back
189
190 =back
191
192 =head1 EXAMPLES
193
194 A simple self test callback is shown below for illustrative purposes.
195
196   #include <openssl/self_test.h>
197
198   static OSSL_CALLBACK self_test_cb;
199
200   static int self_test_cb(const OSSL_PARAM params[], void *arg)
201   {
202     int ret = 0;
203     const OSSL_PARAM *p = NULL;
204     const char *phase = NULL, *type = NULL, *desc = NULL;
205
206     p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
207     if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
208         goto err;
209     phase = (const char *)p->data;
210
211     p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
212     if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
213         goto err;
214     desc = (const char *)p->data;
215
216     p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
217     if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
218         goto err;
219     type = (const char *)p->data;
220
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);
227
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);
232         return 0;
233     }
234     ret = 1;
235   err:
236     return ret;
237   }
238
239 =head1 SEE ALSO
240
241 L<openssl-fipsinstall(1)>,
242 L<fips_config(5)>,
243 L<OSSL_SELF_TEST_set_callback(3)>,
244 L<OSSL_PARAM(3)>,
245 L<openssl-core.h(7)>
246
247 =head1 HISTORY
248
249 The type and functions described here were added in OpenSSL 3.0.
250
251 =head1 COPYRIGHT
252
253 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
254
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>.
259
260 =cut