1b0d17251Schristos=pod 2b0d17251Schristos 3b0d17251Schristos=head1 NAME 4b0d17251Schristos 5b0d17251Schristosfips_module - OpenSSL fips module guide 6b0d17251Schristos 7b0d17251Schristos=head1 SYNOPSIS 8b0d17251Schristos 9b0d17251SchristosSee the individual manual pages for details. 10b0d17251Schristos 11b0d17251Schristos=head1 DESCRIPTION 12b0d17251Schristos 13b0d17251SchristosThis guide details different ways that OpenSSL can be used in conjunction 14b0d17251Schristoswith the FIPS module. Which is the correct approach to use will depend on your 15b0d17251Schristosown specific circumstances and what you are attempting to achieve. 16b0d17251Schristos 17*4778aedeSchristosFor information related to installing the FIPS module see 18*4778aedeSchristosL<https://github.com/openssl/openssl/blob/master/README-FIPS.md>. 19*4778aedeSchristos 20b0d17251SchristosNote that the old functions FIPS_mode() and FIPS_mode_set() are no longer 21b0d17251Schristospresent so you must remove them from your application if you use them. 22b0d17251Schristos 23b0d17251SchristosApplications written to use the OpenSSL 3.0 FIPS module should not use any 24b0d17251Schristoslegacy APIs or features that avoid the FIPS module. Specifically this includes: 25b0d17251Schristos 26b0d17251Schristos=over 4 27b0d17251Schristos 28b0d17251Schristos=item * 29b0d17251Schristos 30b0d17251SchristosLow level cryptographic APIs (use the high level APIs, such as EVP, instead) 31b0d17251Schristos 32b0d17251Schristos=item * 33b0d17251Schristos 34b0d17251SchristosEngines 35b0d17251Schristos 36b0d17251Schristos=item * 37b0d17251Schristos 38b0d17251SchristosAny functions that create or modify custom "METHODS" (for example 39b0d17251SchristosEVP_MD_meth_new(), EVP_CIPHER_meth_new(), EVP_PKEY_meth_new(), RSA_meth_new(), 40b0d17251SchristosEC_KEY_METHOD_new(), etc.) 41b0d17251Schristos 42b0d17251Schristos=back 43b0d17251Schristos 44b0d17251SchristosAll of the above APIs are deprecated in OpenSSL 3.0 - so a simple rule is to 45b0d17251Schristosavoid using all deprecated functions. See L<migration_guide(7)> for a list of 46b0d17251Schristosdeprecated functions. 47b0d17251Schristos 48b0d17251Schristos=head2 Making all applications use the FIPS module by default 49b0d17251Schristos 50b0d17251SchristosOne simple approach is to cause all applications that are using OpenSSL to only 51b0d17251Schristosuse the FIPS module for cryptographic algorithms by default. 52b0d17251Schristos 53b0d17251SchristosThis approach can be done purely via configuration. As long as applications are 54b0d17251Schristosbuilt and linked against OpenSSL 3.0 and do not override the loading of the 55b0d17251Schristosdefault config file or its settings then they can automatically start using the 56b0d17251SchristosFIPS module without the need for any further code changes. 57b0d17251Schristos 58b0d17251SchristosTo do this the default OpenSSL config file will have to be modified. The 59b0d17251Schristoslocation of this config file will depend on the platform, and any options that 60b0d17251Schristoswere given during the build process. You can check the location of the config 61b0d17251Schristosfile by running this command: 62b0d17251Schristos 63b0d17251Schristos $ openssl version -d 64b0d17251Schristos OPENSSLDIR: "/usr/local/ssl" 65b0d17251Schristos 66b0d17251SchristosCaution: Many Operating Systems install OpenSSL by default. It is a common error 67b0d17251Schristosto not have the correct version of OpenSSL in your $PATH. Check that you are 68b0d17251Schristosrunning an OpenSSL 3.0 version like this: 69b0d17251Schristos 70b0d17251Schristos $ openssl version -v 71b0d17251Schristos OpenSSL 3.0.0-dev xx XXX xxxx (Library: OpenSSL 3.0.0-dev xx XXX xxxx) 72b0d17251Schristos 73b0d17251SchristosThe B<OPENSSLDIR> value above gives the directory name for where the default 74b0d17251Schristosconfig file is stored. So in this case the default config file will be called 75b0d17251SchristosF</usr/local/ssl/openssl.cnf>. 76b0d17251Schristos 77b0d17251SchristosEdit the config file to add the following lines near the beginning: 78b0d17251Schristos 79b0d17251Schristos config_diagnostics = 1 80b0d17251Schristos openssl_conf = openssl_init 81b0d17251Schristos 82b0d17251Schristos .include /usr/local/ssl/fipsmodule.cnf 83b0d17251Schristos 84b0d17251Schristos [openssl_init] 85b0d17251Schristos providers = provider_sect 86b0d17251Schristos 87b0d17251Schristos [provider_sect] 88b0d17251Schristos fips = fips_sect 89b0d17251Schristos base = base_sect 90b0d17251Schristos 91b0d17251Schristos [base_sect] 92b0d17251Schristos activate = 1 93b0d17251Schristos 94b0d17251SchristosObviously the include file location above should match the path and name of the 95b0d17251SchristosFIPS module config file that you installed earlier. 96b0d17251SchristosSee L<https://github.com/openssl/openssl/blob/master/README-FIPS.md>. 97b0d17251Schristos 98*4778aedeSchristosFor FIPS usage, it is recommended that the B<config_diagnostics> option is 99b0d17251Schristosenabled to prevent accidental use of non-FIPS validated algorithms via broken 100b0d17251Schristosor mistaken configuration. See L<config(5)>. 101b0d17251Schristos 102b0d17251SchristosAny applications that use OpenSSL 3.0 and are started after these changes are 103b0d17251Schristosmade will start using only the FIPS module unless those applications take 104b0d17251Schristosexplicit steps to avoid this default behaviour. Note that this configuration 105b0d17251Schristosalso activates the "base" provider. The base provider does not include any 106b0d17251Schristoscryptographic algorithms (and therefore does not impact the validation status of 107b0d17251Schristosany cryptographic operations), but does include other supporting algorithms that 108b0d17251Schristosmay be required. It is designed to be used in conjunction with the FIPS module. 109b0d17251Schristos 110b0d17251SchristosThis approach has the primary advantage that it is simple, and no code changes 111b0d17251Schristosare required in applications in order to benefit from the FIPS module. There are 112b0d17251Schristossome disadvantages to this approach: 113b0d17251Schristos 114b0d17251Schristos=over 4 115b0d17251Schristos 116b0d17251Schristos=item * 117b0d17251Schristos 118b0d17251SchristosYou may not want all applications to use the FIPS module. 119b0d17251Schristos 120b0d17251SchristosIt may be the case that some applications should and some should not use the 121b0d17251SchristosFIPS module. 122b0d17251Schristos 123b0d17251Schristos=item * 124b0d17251Schristos 125b0d17251SchristosIf applications take explicit steps to not load the default config file or 126b0d17251Schristosset different settings. 127b0d17251Schristos 128b0d17251SchristosThis method will not work for these cases. 129b0d17251Schristos 130b0d17251Schristos=item * 131b0d17251Schristos 132b0d17251SchristosThe algorithms available in the FIPS module are a subset of the algorithms 133b0d17251Schristosthat are available in the default OpenSSL Provider. 134b0d17251Schristos 135b0d17251SchristosIf any applications attempt to use any algorithms that are not present, 136b0d17251Schristosthen they will fail. 137b0d17251Schristos 138b0d17251Schristos=item * 139b0d17251Schristos 140b0d17251SchristosUsage of certain deprecated APIs avoids the use of the FIPS module. 141b0d17251Schristos 142b0d17251SchristosIf any applications use those APIs then the FIPS module will not be used. 143b0d17251Schristos 144b0d17251Schristos=back 145b0d17251Schristos 146b0d17251Schristos=head2 Selectively making applications use the FIPS module by default 147b0d17251Schristos 148b0d17251SchristosA variation on the above approach is to do the same thing on an individual 149b0d17251Schristosapplication basis. The default OpenSSL config file depends on the compiled in 150b0d17251Schristosvalue for B<OPENSSLDIR> as described in the section above. However it is also 151b0d17251Schristospossible to override the config file to be used via the B<OPENSSL_CONF> 152b0d17251Schristosenvironment variable. For example the following, on Unix, will cause the 153b0d17251Schristosapplication to be executed with a non-standard config file location: 154b0d17251Schristos 155b0d17251Schristos $ OPENSSL_CONF=/my/nondefault/openssl.cnf myapplication 156b0d17251Schristos 157b0d17251SchristosUsing this mechanism you can control which config file is loaded (and hence 158b0d17251Schristoswhether the FIPS module is loaded) on an application by application basis. 159b0d17251Schristos 160b0d17251SchristosThis removes the disadvantage listed above that you may not want all 161b0d17251Schristosapplications to use the FIPS module. All the other advantages and disadvantages 162b0d17251Schristosstill apply. 163b0d17251Schristos 164b0d17251Schristos=head2 Programmatically loading the FIPS module (default library context) 165b0d17251Schristos 166b0d17251SchristosApplications may choose to load the FIPS provider explicitly rather than relying 167b0d17251Schristoson config to do this. The config file is still necessary in order to hold the 168b0d17251SchristosFIPS module config data (such as its self test status and integrity data). But 169b0d17251Schristosin this case we do not automatically activate the FIPS provider via that config 170b0d17251Schristosfile. 171b0d17251Schristos 172b0d17251SchristosTo do things this way configure as per 173b0d17251SchristosL</Making all applications use the FIPS module by default> above, but edit the 174b0d17251SchristosF<fipsmodule.cnf> file to remove or comment out the line which says 175b0d17251SchristosC<activate = 1> (note that setting this value to 0 is I<not> sufficient). 176b0d17251SchristosThis means all the required config information will be available to load the 177b0d17251SchristosFIPS module, but it is not automatically loaded when the application starts. The 178b0d17251SchristosFIPS provider can then be loaded programmatically like this: 179b0d17251Schristos 180b0d17251Schristos #include <openssl/provider.h> 181b0d17251Schristos 182b0d17251Schristos int main(void) 183b0d17251Schristos { 184b0d17251Schristos OSSL_PROVIDER *fips; 185b0d17251Schristos OSSL_PROVIDER *base; 186b0d17251Schristos 187b0d17251Schristos fips = OSSL_PROVIDER_load(NULL, "fips"); 188b0d17251Schristos if (fips == NULL) { 189b0d17251Schristos printf("Failed to load FIPS provider\n"); 190b0d17251Schristos exit(EXIT_FAILURE); 191b0d17251Schristos } 192b0d17251Schristos base = OSSL_PROVIDER_load(NULL, "base"); 193b0d17251Schristos if (base == NULL) { 194b0d17251Schristos OSSL_PROVIDER_unload(fips); 195b0d17251Schristos printf("Failed to load base provider\n"); 196b0d17251Schristos exit(EXIT_FAILURE); 197b0d17251Schristos } 198b0d17251Schristos 199b0d17251Schristos /* Rest of application */ 200b0d17251Schristos 201b0d17251Schristos OSSL_PROVIDER_unload(base); 202b0d17251Schristos OSSL_PROVIDER_unload(fips); 203b0d17251Schristos exit(EXIT_SUCCESS); 204b0d17251Schristos } 205b0d17251Schristos 206b0d17251SchristosNote that this should be one of the first things that you do in your 207b0d17251Schristosapplication. If any OpenSSL functions get called that require the use of 208b0d17251Schristoscryptographic functions before this occurs then, if no provider has yet been 209b0d17251Schristosloaded, then the default provider will be automatically loaded. If you then 210b0d17251Schristoslater explicitly load the FIPS provider then you will have both the FIPS and the 211b0d17251Schristosdefault provider loaded at the same time. It is undefined which implementation 212b0d17251Schristosof an algorithm will be used if multiple implementations are available and you 213b0d17251Schristoshave not explicitly specified via a property query (see below) which one should 214b0d17251Schristosbe used. 215b0d17251Schristos 216b0d17251SchristosAlso note that in this example we have additionally loaded the "base" provider. 217b0d17251SchristosThis loads a sub-set of algorithms that are also available in the default 218b0d17251Schristosprovider - specifically non cryptographic ones which may be used in conjunction 219b0d17251Schristoswith the FIPS provider. For example this contains algorithms for encoding and 220b0d17251Schristosdecoding keys. If you decide not to load the default provider then you 221b0d17251Schristoswill usually want to load the base provider instead. 222b0d17251Schristos 223b0d17251SchristosIn this example we are using the "default" library context. OpenSSL functions 224b0d17251Schristosoperate within the scope of a library context. If no library context is 225b0d17251Schristosexplicitly specified then the default library context is used. For further 226b0d17251Schristosdetails about library contexts see the L<OSSL_LIB_CTX(3)> man page. 227b0d17251Schristos 228b0d17251Schristos=head2 Loading the FIPS module at the same time as other providers 229b0d17251Schristos 230b0d17251SchristosIt is possible to have the FIPS provider and other providers (such as the 231b0d17251Schristosdefault provider) all loaded at the same time into the same library context. You 232b0d17251Schristoscan use a property query string during algorithm fetches to specify which 233b0d17251Schristosimplementation you would like to use. 234b0d17251Schristos 235b0d17251SchristosFor example to fetch an implementation of SHA256 which conforms to FIPS 236b0d17251Schristosstandards you can specify the property query C<fips=yes> like this: 237b0d17251Schristos 238b0d17251Schristos EVP_MD *sha256; 239b0d17251Schristos 240b0d17251Schristos sha256 = EVP_MD_fetch(NULL, "SHA2-256", "fips=yes"); 241b0d17251Schristos 242b0d17251SchristosIf no property query is specified, or more than one implementation matches the 243b0d17251Schristosproperty query then it is undefined which implementation of a particular 244b0d17251Schristosalgorithm will be returned. 245b0d17251Schristos 246b0d17251SchristosThis example shows an explicit request for an implementation of SHA256 from the 247b0d17251Schristosdefault provider: 248b0d17251Schristos 249b0d17251Schristos EVP_MD *sha256; 250b0d17251Schristos 251b0d17251Schristos sha256 = EVP_MD_fetch(NULL, "SHA2-256", "provider=default"); 252b0d17251Schristos 253b0d17251SchristosIt is also possible to set a default property query string. The following 254b0d17251Schristosexample sets the default property query of C<fips=yes> for all fetches within 255b0d17251Schristosthe default library context: 256b0d17251Schristos 257b0d17251Schristos EVP_set_default_properties(NULL, "fips=yes"); 258b0d17251Schristos 259b0d17251SchristosIf a fetch function has both an explicit property query specified, and a 260b0d17251Schristosdefault property query is defined then the two queries are merged together and 261b0d17251Schristosboth apply. The local property query overrides the default properties if the 262b0d17251Schristossame property name is specified in both. 263b0d17251Schristos 264b0d17251SchristosThere are two important built-in properties that you should be aware of: 265b0d17251Schristos 266b0d17251SchristosThe "provider" property enables you to specify which provider you want an 267b0d17251Schristosimplementation to be fetched from, e.g. C<provider=default> or C<provider=fips>. 268b0d17251SchristosAll algorithms implemented in a provider have this property set on them. 269b0d17251Schristos 270b0d17251SchristosThere is also the C<fips> property. All FIPS algorithms match against the 271b0d17251Schristosproperty query C<fips=yes>. There are also some non-cryptographic algorithms 272b0d17251Schristosavailable in the default and base providers that also have the C<fips=yes> 273b0d17251Schristosproperty defined for them. These are the encoder and decoder algorithms that 274b0d17251Schristoscan (for example) be used to write out a key generated in the FIPS provider to a 275b0d17251Schristosfile. The encoder and decoder algorithms are not in the FIPS module itself but 276b0d17251Schristosare allowed to be used in conjunction with the FIPS algorithms. 277b0d17251Schristos 278b0d17251SchristosIt is possible to specify default properties within a config file. For example 279b0d17251Schristosthe following config file automatically loads the default and FIPS providers and 280b0d17251Schristossets the default property value to be C<fips=yes>. Note that this config file 281b0d17251Schristosdoes not load the "base" provider. All supporting algorithms that are in "base" 282b0d17251Schristosare also in "default", so it is unnecessary in this case: 283b0d17251Schristos 284b0d17251Schristos config_diagnostics = 1 285b0d17251Schristos openssl_conf = openssl_init 286b0d17251Schristos 287b0d17251Schristos .include /usr/local/ssl/fipsmodule.cnf 288b0d17251Schristos 289b0d17251Schristos [openssl_init] 290b0d17251Schristos providers = provider_sect 291b0d17251Schristos alg_section = algorithm_sect 292b0d17251Schristos 293b0d17251Schristos [provider_sect] 294b0d17251Schristos fips = fips_sect 295b0d17251Schristos default = default_sect 296b0d17251Schristos 297b0d17251Schristos [default_sect] 298b0d17251Schristos activate = 1 299b0d17251Schristos 300b0d17251Schristos [algorithm_sect] 301b0d17251Schristos default_properties = fips=yes 302b0d17251Schristos 303b0d17251Schristos=head2 Programmatically loading the FIPS module (nondefault library context) 304b0d17251Schristos 305b0d17251SchristosIn addition to using properties to separate usage of the FIPS module from other 306b0d17251Schristosusages this can also be achieved using library contexts. In this example we 307b0d17251Schristoscreate two library contexts. In one we assume the existence of a config file 308b0d17251Schristoscalled F<openssl-fips.cnf> that automatically loads and configures the FIPS and 309b0d17251Schristosbase providers. The other library context will just use the default provider. 310b0d17251Schristos 311b0d17251Schristos OSSL_LIB_CTX *fips_libctx, *nonfips_libctx; 312b0d17251Schristos OSSL_PROVIDER *defctxnull = NULL; 313b0d17251Schristos EVP_MD *fipssha256 = NULL, *nonfipssha256 = NULL; 314b0d17251Schristos int ret = 1; 315b0d17251Schristos 316b0d17251Schristos /* 317b0d17251Schristos * Create two nondefault library contexts. One for fips usage and 318b0d17251Schristos * one for non-fips usage 319b0d17251Schristos */ 320b0d17251Schristos fips_libctx = OSSL_LIB_CTX_new(); 321b0d17251Schristos nonfips_libctx = OSSL_LIB_CTX_new(); 322b0d17251Schristos if (fips_libctx == NULL || nonfips_libctx == NULL) 323b0d17251Schristos goto err; 324b0d17251Schristos 325b0d17251Schristos /* Prevent anything from using the default library context */ 326b0d17251Schristos defctxnull = OSSL_PROVIDER_load(NULL, "null"); 327b0d17251Schristos 328b0d17251Schristos /* 329b0d17251Schristos * Load config file for the FIPS library context. We assume that 330b0d17251Schristos * this config file will automatically activate the FIPS and base 331b0d17251Schristos * providers so we don't need to explicitly load them here. 332b0d17251Schristos */ 333b0d17251Schristos if (!OSSL_LIB_CTX_load_config(fips_libctx, "openssl-fips.cnf")) 334b0d17251Schristos goto err; 335b0d17251Schristos 336b0d17251Schristos /* 337b0d17251Schristos * We don't need to do anything special to load the default 338b0d17251Schristos * provider into nonfips_libctx. This happens automatically if no 339b0d17251Schristos * other providers are loaded. 340b0d17251Schristos * Because we don't call OSSL_LIB_CTX_load_config() explicitly for 341b0d17251Schristos * nonfips_libctx it will just use the default config file. 342b0d17251Schristos */ 343b0d17251Schristos 344b0d17251Schristos /* As an example get some digests */ 345b0d17251Schristos 346b0d17251Schristos /* Get a FIPS validated digest */ 347b0d17251Schristos fipssha256 = EVP_MD_fetch(fips_libctx, "SHA2-256", NULL); 348b0d17251Schristos if (fipssha256 == NULL) 349b0d17251Schristos goto err; 350b0d17251Schristos 351b0d17251Schristos /* Get a non-FIPS validated digest */ 352b0d17251Schristos nonfipssha256 = EVP_MD_fetch(nonfips_libctx, "SHA2-256", NULL); 353b0d17251Schristos if (nonfipssha256 == NULL) 354b0d17251Schristos goto err; 355b0d17251Schristos 356b0d17251Schristos /* Use the digests */ 357b0d17251Schristos 358b0d17251Schristos printf("Success\n"); 359b0d17251Schristos ret = 0; 360b0d17251Schristos 361b0d17251Schristos err: 362b0d17251Schristos EVP_MD_free(fipssha256); 363b0d17251Schristos EVP_MD_free(nonfipssha256); 364b0d17251Schristos OSSL_LIB_CTX_free(fips_libctx); 365b0d17251Schristos OSSL_LIB_CTX_free(nonfips_libctx); 366b0d17251Schristos OSSL_PROVIDER_unload(defctxnull); 367b0d17251Schristos 368b0d17251Schristos return ret; 369b0d17251Schristos 370b0d17251SchristosNote that we have made use of the special "null" provider here which we load 371b0d17251Schristosinto the default library context. We could have chosen to use the default 372b0d17251Schristoslibrary context for FIPS usage, and just create one additional library context 373b0d17251Schristosfor other usages - or vice versa. However if code has not been converted to use 374b0d17251Schristoslibrary contexts then the default library context will be automatically used. 375b0d17251SchristosThis could be the case for your own existing applications as well as certain 376b0d17251Schristosparts of OpenSSL itself. Not all parts of OpenSSL are library context aware. If 377b0d17251Schristosthis happens then you could "accidentally" use the wrong library context for a 378b0d17251Schristosparticular operation. To be sure this doesn't happen you can load the "null" 379b0d17251Schristosprovider into the default library context. Because a provider has been 380b0d17251Schristosexplicitly loaded, the default provider will not automatically load. This means 381b0d17251Schristoscode using the default context by accident will fail because no algorithms will 382b0d17251Schristosbe available. 383b0d17251Schristos 384b0d17251SchristosSee L<migration_guide(7)/Library Context> for additional information about the 385b0d17251SchristosLibrary Context. 386b0d17251Schristos 387b0d17251Schristos=head2 Using Encoders and Decoders with the FIPS module 388b0d17251Schristos 389b0d17251SchristosEncoders and decoders are used to read and write keys or parameters from or to 390b0d17251Schristossome external format (for example a PEM file). If your application generates 391b0d17251Schristoskeys or parameters that then need to be written into PEM or DER format 392b0d17251Schristosthen it is likely that you will need to use an encoder to do this. Similarly 393b0d17251Schristosyou need a decoder to read previously saved keys and parameters. In most cases 394b0d17251Schristosthis will be invisible to you if you are using APIs that existed in 395b0d17251SchristosOpenSSL 1.1.1 or earlier such as L<i2d_PrivateKey(3)>. However the appropriate 396b0d17251Schristosencoder/decoder will need to be available in the library context associated with 397b0d17251Schristosthe key or parameter object. The built-in OpenSSL encoders and decoders are 398b0d17251Schristosimplemented in both the default and base providers and are not in the FIPS 399b0d17251Schristosmodule boundary. However since they are not cryptographic algorithms themselves 400b0d17251Schristosit is still possible to use them in conjunction with the FIPS module, and 401b0d17251Schristostherefore these encoders/decoders have the C<fips=yes> property against them. 402b0d17251SchristosYou should ensure that either the default or base provider is loaded into the 403b0d17251Schristoslibrary context in this case. 404b0d17251Schristos 405b0d17251Schristos=head2 Using the FIPS module in SSL/TLS 406b0d17251Schristos 407b0d17251SchristosWriting an application that uses libssl in conjunction with the FIPS module is 408b0d17251Schristosmuch the same as writing a normal libssl application. If you are using global 409b0d17251Schristosproperties and the default library context to specify usage of FIPS validated 410b0d17251Schristosalgorithms then this will happen automatically for all cryptographic algorithms 411b0d17251Schristosin libssl. If you are using a nondefault library context to load the FIPS 412b0d17251Schristosprovider then you can supply this to libssl using the function 413b0d17251SchristosL<SSL_CTX_new_ex(3)>. This works as a drop in replacement for the function 414b0d17251SchristosL<SSL_CTX_new(3)> except it provides you with the capability to specify the 415b0d17251Schristoslibrary context to be used. You can also use the same function to specify 416b0d17251Schristoslibssl specific properties to use. 417b0d17251Schristos 418b0d17251SchristosIn this first example we create two SSL_CTX objects using two different library 419b0d17251Schristoscontexts. 420b0d17251Schristos 421b0d17251Schristos /* 422b0d17251Schristos * We assume that a nondefault library context with the FIPS 423b0d17251Schristos * provider loaded has been created called fips_libctx. 424b0d17251Schristos */ 425b0d17251Schristos SSL_CTX *fips_ssl_ctx = SSL_CTX_new_ex(fips_libctx, NULL, TLS_method()); 426b0d17251Schristos /* 427b0d17251Schristos * We assume that a nondefault library context with the default 428b0d17251Schristos * provider loaded has been created called non_fips_libctx. 429b0d17251Schristos */ 430b0d17251Schristos SSL_CTX *non_fips_ssl_ctx = SSL_CTX_new_ex(non_fips_libctx, NULL, 431b0d17251Schristos TLS_method()); 432b0d17251Schristos 433b0d17251SchristosIn this second example we create two SSL_CTX objects using different properties 434b0d17251Schristosto specify FIPS usage: 435b0d17251Schristos 436b0d17251Schristos /* 437b0d17251Schristos * The "fips=yes" property includes all FIPS approved algorithms 438b0d17251Schristos * as well as encoders from the default provider that are allowed 439b0d17251Schristos * to be used. The NULL below indicates that we are using the 440b0d17251Schristos * default library context. 441b0d17251Schristos */ 442b0d17251Schristos SSL_CTX *fips_ssl_ctx = SSL_CTX_new_ex(NULL, "fips=yes", TLS_method()); 443b0d17251Schristos /* 444b0d17251Schristos * The "provider!=fips" property allows algorithms from any 445b0d17251Schristos * provider except the FIPS provider 446b0d17251Schristos */ 447b0d17251Schristos SSL_CTX *non_fips_ssl_ctx = SSL_CTX_new_ex(NULL, "provider!=fips", 448b0d17251Schristos TLS_method()); 449b0d17251Schristos 450b0d17251Schristos=head2 Confirming that an algorithm is being provided by the FIPS module 451b0d17251Schristos 452b0d17251SchristosA chain of links needs to be followed to go from an algorithm instance to the 453b0d17251Schristosprovider that implements it. The process is similar for all algorithms. Here the 454b0d17251Schristosexample of a digest is used. 455b0d17251Schristos 456b0d17251SchristosTo go from an B<EVP_MD_CTX> to an B<EVP_MD>, use L<EVP_MD_CTX_md(3)> . 457b0d17251SchristosTo go from the B<EVP_MD> to its B<OSSL_PROVIDER>, 458b0d17251Schristosuse L<EVP_MD_get0_provider(3)>. 459b0d17251SchristosTo extract the name from the B<OSSL_PROVIDER>, use 460b0d17251SchristosL<OSSL_PROVIDER_get0_name(3)>. 461b0d17251Schristos 462*4778aedeSchristos=head1 NOTES 463*4778aedeSchristos 464*4778aedeSchristosSome released versions of OpenSSL do not include a validated 465*4778aedeSchristosFIPS provider. To determine which versions have undergone 466*4778aedeSchristosthe validation process, please refer to the 467*4778aedeSchristosL<OpenSSL Downloads page|https://www.openssl.org/source/>. If you 468*4778aedeSchristosrequire FIPS-approved functionality, it is essential to build your FIPS 469*4778aedeSchristosprovider using one of the validated versions listed there. Normally, 470*4778aedeSchristosit is possible to utilize a FIPS provider constructed from one of the 471*4778aedeSchristosvalidated versions alongside F<libcrypto> and F<libssl> compiled from any 472*4778aedeSchristosrelease within the same major release series. This flexibility enables 473*4778aedeSchristosyou to address bug fixes and CVEs that fall outside the FIPS boundary. 474*4778aedeSchristos 475b0d17251Schristos=head1 SEE ALSO 476b0d17251Schristos 477*4778aedeSchristosL<migration_guide(7)>, L<crypto(7)>, L<fips_config(5)>, 478*4778aedeSchristosL<https://www.openssl.org/source/> 479b0d17251Schristos 480b0d17251Schristos=head1 HISTORY 481b0d17251Schristos 482b0d17251SchristosThe FIPS module guide was created for use with the new FIPS provider 483b0d17251Schristosin OpenSSL 3.0. 484b0d17251Schristos 485b0d17251Schristos=head1 COPYRIGHT 486b0d17251Schristos 487*4778aedeSchristosCopyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved. 488b0d17251Schristos 489b0d17251SchristosLicensed under the Apache License 2.0 (the "License"). You may not use 490b0d17251Schristosthis file except in compliance with the License. You can obtain a copy 491b0d17251Schristosin the file LICENSE in the source distribution or at 492b0d17251SchristosL<https://www.openssl.org/source/license.html>. 493b0d17251Schristos 494b0d17251Schristos=cut 495