From b7140b0604bdfaa034452d97648a9c23a97568e4 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Sun, 28 Mar 2021 17:22:40 +1000 Subject: Add migration guide for 3.0 Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/14710) --- doc/build.info | 12 + doc/man3/DH_size.pod | 16 +- doc/man3/PEM_read_CMS.pod | 2 +- doc/man3/PEM_read_bio_PrivateKey.pod | 2 +- doc/man7/OSSL_PROVIDER-legacy.pod | 7 +- doc/man7/crypto.pod | 3 +- doc/man7/fips_module.pod | 443 +++++++++ doc/man7/migration_guide.pod | 1804 ++++++++++++++++++++++++++++++++++ 8 files changed, 2273 insertions(+), 16 deletions(-) create mode 100644 doc/man7/fips_module.pod create mode 100644 doc/man7/migration_guide.pod (limited to 'doc') diff --git a/doc/build.info b/doc/build.info index 02882af91e..f64919a7c4 100644 --- a/doc/build.info +++ b/doc/build.info @@ -4292,6 +4292,10 @@ DEPEND[html/man7/evp.html]=man7/evp.pod GENERATE[html/man7/evp.html]=man7/evp.pod DEPEND[man/man7/evp.7]=man7/evp.pod GENERATE[man/man7/evp.7]=man7/evp.pod +DEPEND[html/man7/fips_module.html]=man7/fips_module.pod +GENERATE[html/man7/fips_module.html]=man7/fips_module.pod +DEPEND[man/man7/fips_module.7]=man7/fips_module.pod +GENERATE[man/man7/fips_module.7]=man7/fips_module.pod DEPEND[html/man7/life_cycle-kdf.html]=man7/life_cycle-kdf.pod GENERATE[html/man7/life_cycle-kdf.html]=man7/life_cycle-kdf.pod DEPEND[man/man7/life_cycle-kdf.7]=man7/life_cycle-kdf.pod @@ -4304,6 +4308,10 @@ DEPEND[html/man7/life_cycle-rand.html]=man7/life_cycle-rand.pod GENERATE[html/man7/life_cycle-rand.html]=man7/life_cycle-rand.pod DEPEND[man/man7/life_cycle-rand.7]=man7/life_cycle-rand.pod GENERATE[man/man7/life_cycle-rand.7]=man7/life_cycle-rand.pod +DEPEND[html/man7/migration_guide.html]=man7/migration_guide.pod +GENERATE[html/man7/migration_guide.html]=man7/migration_guide.pod +DEPEND[man/man7/migration_guide.7]=man7/migration_guide.pod +GENERATE[man/man7/migration_guide.7]=man7/migration_guide.pod DEPEND[html/man7/openssl-core.h.html]=man7/openssl-core.h.pod GENERATE[html/man7/openssl-core.h.html]=man7/openssl-core.h.pod DEPEND[man/man7/openssl-core.h.7]=man7/openssl-core.h.pod @@ -4496,9 +4504,11 @@ html/man7/crypto.html \ html/man7/ct.html \ html/man7/des_modes.html \ html/man7/evp.html \ +html/man7/fips_module.html \ html/man7/life_cycle-kdf.html \ html/man7/life_cycle-mac.html \ html/man7/life_cycle-rand.html \ +html/man7/migration_guide.html \ html/man7/openssl-core.h.html \ html/man7/openssl-core_dispatch.h.html \ html/man7/openssl-core_names.h.html \ @@ -4599,9 +4609,11 @@ man/man7/crypto.7 \ man/man7/ct.7 \ man/man7/des_modes.7 \ man/man7/evp.7 \ +man/man7/fips_module.7 \ man/man7/life_cycle-kdf.7 \ man/man7/life_cycle-mac.7 \ man/man7/life_cycle-rand.7 \ +man/man7/migration_guide.7 \ man/man7/openssl-core.h.7 \ man/man7/openssl-core_dispatch.h.7 \ man/man7/openssl-core_names.h.7 \ diff --git a/doc/man3/DH_size.pod b/doc/man3/DH_size.pod index cb30b27ff5..e4b7e429a0 100644 --- a/doc/man3/DH_size.pod +++ b/doc/man3/DH_size.pod @@ -9,26 +9,26 @@ security bits #include - int DH_bits(const DH *dh); - Deprecated since OpenSSL 3.0, can be hidden entirely by defining B with a suitable version value, see L: + int DH_bits(const DH *dh); + int DH_size(const DH *dh); int DH_security_bits(const DH *dh); =head1 DESCRIPTION +The functions described on this page are deprecated. +Applications should instead use L, +L and L. + DH_bits() returns the number of significant bits. B and Bp> must not be B. -The remaining functions described on this page are deprecated. -Applications should instead use L and -L. - DH_size() returns the Diffie-Hellman prime size in bytes. It can be used to determine how much memory must be allocated for the shared secret computed by L. @@ -55,9 +55,7 @@ L =head1 HISTORY -The DH_size() and DH_security_bits() functions were deprecated in OpenSSL 3.0. - -The DH_bits() function was added in OpenSSL 1.1.0. +All functions were deprecated in OpenSSL 3.0. =head1 COPYRIGHT diff --git a/doc/man3/PEM_read_CMS.pod b/doc/man3/PEM_read_CMS.pod index 6c24c437e5..4024b3219c 100644 --- a/doc/man3/PEM_read_CMS.pod +++ b/doc/man3/PEM_read_CMS.pod @@ -85,7 +85,7 @@ L: =head1 DESCRIPTION All of the functions described on this page are deprecated. -Applications should use OSSL_ENCODER_to_bio() and OSSL_ENCODER_from_bio() +Applications should use OSSL_ENCODER_to_bio() and OSSL_DECODER_from_bio() instead. In the description below, B> is used diff --git a/doc/man3/PEM_read_bio_PrivateKey.pod b/doc/man3/PEM_read_bio_PrivateKey.pod index 2addbb4d61..c053d03a21 100644 --- a/doc/man3/PEM_read_bio_PrivateKey.pod +++ b/doc/man3/PEM_read_bio_PrivateKey.pod @@ -194,7 +194,7 @@ L: All of the functions described on this page that have a I of B, B and B are deprecated. Applications should use OSSL_ENCODER_to_bio() and -OSSL_ENCODER_from_bio() instead. +OSSL_DECODER_from_bio() instead. The PEM functions read or write structures in PEM format. In this sense PEM format is simply base64 encoded data surrounded diff --git a/doc/man7/OSSL_PROVIDER-legacy.pod b/doc/man7/OSSL_PROVIDER-legacy.pod index 86ac3fa9a0..1fa86ab2cd 100644 --- a/doc/man7/OSSL_PROVIDER-legacy.pod +++ b/doc/man7/OSSL_PROVIDER-legacy.pod @@ -64,7 +64,8 @@ Not all of these symmetric cipher algorithms are enabled by default. =item DES -=item IDEA +The algorithm names are: DES_ECB, DES_CBC, DES_OFB, DES_CFB, DES_CFB1, DES_CFB8 +and DESX_CBC. =item RC2 @@ -83,8 +84,6 @@ Disabled by default. Use I config option to enable. When algorithms for other operations start appearing, the following =head2 titles are appropriate to use: -- Symmetric Ciphers - - Message Authentication Code (MAC) - Key Derivation Function (KDF) @@ -108,7 +107,7 @@ L =head1 COPYRIGHT -Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man7/crypto.pod b/doc/man7/crypto.pod index 9db62e5aab..b45404cce0 100644 --- a/doc/man7/crypto.pod +++ b/doc/man7/crypto.pod @@ -75,6 +75,7 @@ Similarly when the application exits the default library context is automatically destroyed. No explicit de-initialisation steps need to be taken. See L for more information about library contexts. +See also L. =head2 Multi-threaded applications @@ -303,7 +304,7 @@ provider can also be selected with the property "fips=yes". The FIPS provider may also contain non-approved algorithm implementations and these can be selected with the property "fips=no". -See L. +See L and L. =head2 Legacy provider diff --git a/doc/man7/fips_module.pod b/doc/man7/fips_module.pod new file mode 100644 index 0000000000..b8a343eb09 --- /dev/null +++ b/doc/man7/fips_module.pod @@ -0,0 +1,443 @@ +=pod + +=head1 NAME + +fips_module - OpenSSL fips module guide + +=head1 SYNOPSIS + +See the individual manual pages for details. + +=head1 DESCRIPTION + +This guide details different ways that OpenSSL can be used in conjunction +with the FIPS module. Which is the correct approach to use will depend on your +own specific circumstances and what you are attempting to achieve. + +Note that the old functions 'FIPS_mode()` and `FIPS_mode_set()` are no longer +present so you must remove them from your application if you use them. + +Applications written to use the OpenSSL 3.0 FIPS module should not use any +legacy APIs or features that avoid the FIPS module. Specifically this includes: + +- Low level cryptographic APIs (use the high level APIs, such as EVP, instead) +- Engines +- Any functions that create or modify custom "METHODS" (for example +`EVP_MD_meth_new`, `EVP_CIPHER_meth_new`, `EVP_PKEY_meth_new`, `RSA_meth_new`, +`EC_KEY_METHOD_new`, etc.) + +All of the above APIs are deprecated in OpenSSL 3.0 - so a simple rule is to +avoid using all deprecated functions. See L for a list of +deprecated functions. + +=head2 Making all applications use the FIPS module by default + +One simple approach is to cause all applications that are using OpenSSL to only +use the FIPS module for cryptographic algorithms by default. + +This approach can be done purely via configuration. As long as applications are +built and linked against OpenSSL 3.0 and do not override the loading of the +default config file or its settings then they can automatically start using the +FIPS module without the need for any further code changes. + +To do this the default OpenSSL config file will have to be modified. The +location of this config file will depend on the platform, and any options that +were given during the build process. You can check the location of the config +file by running this command: + + $ openssl version -d + OPENSSLDIR: "/usr/local/ssl" + +Caution: Many Operating Systems install OpenSSL by default. It is a common error +to not have the correct version of OpenSSL in your $PATH. Check that you are +running an OpenSSL 3.0 version like this: + + $ openssl version -v + OpenSSL 3.0.0-dev xx XXX xxxx (Library: OpenSSL 3.0.0-dev xx XXX xxxx) + +The OPENSSLDIR value above gives the directory name for where the default config +file is stored. So in this case the default config file will be called +`/usr/local/ssl/openssl.cnf` + +Edit the config file to add the following lines near the beginning: + + openssl_conf = openssl_init + + .include /usr/local/ssl/fipsmodule.cnf + + [openssl_init] + providers = provider_sect + + [provider_sect] + fips = fips_sect + base = base_sect + + [base_sect] + activate = 1 + +Obviously the include file location above should match the path and name of the +FIPS module config file that you installed earlier. +See L. + +Any applications that use OpenSSL 3.0 and are started after these changes are +made will start using only the FIPS module unless those applications take +explicit steps to avoid this default behaviour. Note that this configuration +also activates the "base" provider. The base provider does not include any +cryptographic algorithms (and therefore does not impact the validation status of +any cryptographic operations), but does include other supporting algorithms that +may be required. It is designed to be used in conjunction with the FIPS module. + +This approach has the primary advantage that it is simple, and no code changes +are required in applications in order to benefit from the FIPS module. There are +some disadvantages to this approach: + +=over 4 + +=item You may not want all applications to use the FIPS module. + +It may be the case that some applications should and some should not use the +FIPS module. + +=item If applications take explicit steps to not load the default config file or +set different settings. + +This method will not work for these cases. + +=item The algorithms available in the FIPS module are a subset of the algorithms +that are available in the default OpenSSL Provider. + +If any applications attempt to use any algorithms that are not present, +then they will fail. + +-=item Usage of certain deprecated APIs avoids the use of the FIPS module. + +If any applications use those APIs then the FIPS module will not be used. + +=back + +=head2 Selectively making applications use the FIPS module by default + +A variation on the above approach is to do the same thing on an individual +application basis. The default OpenSSL config file depends on the compiled in +value for OPENSSLDIR as described in the section above. However it is also +possible to override the config file to be used via the `OPENSSL_CONF` +environment variable. For example the following, on Unix, will cause the +application to be executed with a non-standard config file location: + + $ OPENSSL_CONF=/my/nondefault/openssl.cnf myapplication + +Using this mechanism you can control which config file is loaded (and hence +whether the FIPS module is loaded) on an application by application basis. + +This removes the disadvantage listed above that you may not want all +applications to use the FIPS module. All the other advantages and disadvantages +still apply. + +=head2 Programmatically loading the FIPS module (default library context) + +Applications may choose to load the FIPS provider explicitly rather than relying +on config to do this. The config file is still necessary in order to hold the +FIPS module config data (such as its self test status and integrity data). But +in this case we do not automatically activate the FIPS provider via that config +file. + +To do things this way configure as per +L above, but edit the +`fipsmodule.cnf` file to remove or comment out the line which says +`activate = 1` (note that setting this value to 0 is I sufficient). +This means all the required config information will be available to load the +FIPS module, but it is not automatically loaded when the application starts. The +FIPS provider can then be loaded programmatically like this: + + #include + + int main(void) + { + OSSL_PROVIDER *fips; + OSSL_PROVIDER *base; + + fips = OSSL_PROVIDER_load(NULL, "fips"); + if (fips == NULL) { + printf("Failed to load FIPS provider\n"); + exit(EXIT_FAILURE); + } + base = OSSL_PROVIDER_load(NULL, "base"); + if (base == NULL) { + OSSL_PROVIDER_unload(fips); + printf("Failed to load base provider\n"); + exit(EXIT_FAILURE); + } + + /* Rest of application */ + + OSSL_PROVIDER_unload(base); + OSSL_PROVIDER_unload(fips); + exit(EXIT_SUCCESS); + } + +Note that this should be one of the first things that you do in your +application. If any OpenSSL functions get called that require the use of +cryptographic functions before this occurs then, if no provider has yet been +loaded, then the default provider will be automatically loaded. If you then +later explicitly load the FIPS provider then you will have both the FIPS and the +default provider loaded at the same time. It is undefined which implementation +of an algorithm will be used if multiple implementations are available and you +have not explicitly specified via a property query (see below) which one should +be used. + +Also note that in this example we have additionally loaded the "base" provider. +This loads a sub-set of algorithms that are also available in the default +provider - specifically non cryptographic ones which may be used in conjunction +with the FIPS provider. For example this contains algorithms for encoding and +decoding keys. If you decide not to load the default provider then you +will usually want to load the base provider instead. + +In this example we are using the "default" library context. OpenSSL functions +operate within the scope of a library context. If no library context is +explicitly specified then the default library context is used. For further +details about library contexts see the L man page. + +=head2 Loading the FIPS module at the same time as other providers + +It is possible to have the FIPS provider and other providers (such as the +default provider) all loaded at the same time into the same library context. You +can use a property query string during algorithm fetches to specify which +implementation you would like to use. + +For example to fetch an implementation of SHA256 which conforms to FIPS +standards you can specify the property query `fips=yes` like this: + + EVP_MD *sha256; + + sha256 = EVP_MD_fetch(NULL, "SHA2-256", "fips=yes"); + +If no property query is specified, or more than one implementation matches the +property query then it is undefined which implementation of a particular +algorithm will be returned. + +This example shows an explicit request for an implementation of SHA256 from the +default provider: + + EVP_MD *sha256; + + sha256 = EVP_MD_fetch(NULL, "SHA2-256", "provider=default"); + +It is also possible to set a default property query string. The following +example sets the default property query of "fips=yes" for all fetches within the +default library context: + + EVP_set_default_properties(NULL, "fips=yes"); + +If a fetch function has both an explicit property query specified, and a +default property query is defined then the two queries are merged together and +both apply. The local property query overrides the default properties if the +same property name is specified in both. + +There are two important built-in properties that you should be aware of: + +The "provider" property enables you to specify which provider you want an +implementation to be fetched from, e.g. `provider=default` or `provider=fips`. +All algorithms implemented in a provider have this property set on them. + +There is also the `fips` property. All FIPS algorithms match against the +property query `fips=yes`. There are also some non-cryptographic algorithms +available in the default and base providers that also have the `fips=yes` +property defined for them. These are the encoder and decoder algorithms that +can (for example) be used to write out a key generated in the FIPS provider to a +file. The encoder and decoder algorithms are not in the FIPS module itself but +are allowed to be used in conjunction with the FIPS algorithms. + +It is possible to specify default properties within a config file. For example +the following config file automatically loads the default and fips providers and +sets the default property value to be `fips=yes`. Note that this config file +does not load the "base" provider. All supporting algorithms that are in "base" +are also in "default", so it is unnecessary in this case: + + openssl_conf = openssl_init + + .include /usr/local/ssl/fipsmodule.cnf + + [openssl_init] + providers = provider_sect + alg_section = algorithm_sect + + [provider_sect] + fips = fips_sect + default = default_sect + + [default_sect] + activate = 1 + + [algorithm_sect] + default_properties = fips=yes + +=head2 Programmatically loading the FIPS module (nondefault library context) + +In addition to using properties to separate usage of the FIPS module from other +usages this can also be achieved using library contexts. In this example we +create two library contexts. In one we assume the existence of a config file +called "openssl-fips.cnf" that automatically loads and configures the FIPS and +base providers. The other library context will just use the default provider. + + OSSL_LIB_CTX *fips_libctx, *nonfips_libctx; + OSSL_PROVIDER *defctxnull = NULL; + EVP_MD *fipssha256 = NULL, *nonfipssha256 = NULL; + int ret = 1; + + /* + * Create two nondefault library contexts. One for fips usage and one for + * non-fips usage + */ + fips_libctx = OSSL_LIB_CTX_new(); + nonfips_libctx = OSSL_LIB_CTX_new(); + if (fips_libctx == NULL || nonfips_libctx == NULL) + goto err; + + /* Prevent anything from using the default library context */ + defctxnull = OSSL_PROVIDER_load(NULL, "null"); + + /* + * Load config file for the FIPS library context. We assume that this + * config file will automatically activate the FIPS and base providers so we + * don't need to explicitly load them here. + */ + if (!OSSL_LIB_CTX_load_config(fips_libctx, "openssl-fips.cnf")) + goto err; + + /* + * We don't need to do anything special to load the default provider into + * nonfips_libctx. This happens automatically if no other providers are + * loaded. Because we don't call OSSL_LIB_CTX_load_config() explicitly for + * nonfips_libctx it will just use the default config file. + */ + + /* As an example get some digests */ + + /* Get a FIPS validated digest */ + fipssha256 = EVP_MD_fetch(fips_libctx, "SHA2-256", NULL); + if (fipssha256 == NULL) + goto err; + + /* Get a non-FIPS validated digest */ + nonfipssha256 = EVP_MD_fetch(nonfips_libctx, "SHA2-256", NULL); + if (nonfipssha256 == NULL) + goto err; + + /* Use the digests */ + + printf("Success\n"); + ret = 0; + + err: + EVP_MD_free(fipssha256); + EVP_MD_free(nonfipssha256); + OSSL_LIB_CTX_free(fips_libctx); + OSSL_LIB_CTX_free(nonfips_libctx); + OSSL_PROVIDER_unload(defctxnull); + + return ret; + +Note that we have made use of the special "null" provider here which we load +into the default library context. We could have chosen to use the default +library context for FIPS usage, and just create one additional library context +for other usages - or vice versa. However if code has not been converted to use +library contexts then the default library context will be automatically used. +This could be the case for your own existing applications as well as certain +parts of OpenSSL itself. Not all parts of OpenSSL are library context aware. If +this happens then you could "accidentally" use the wrong library context for a +particular operation. To be sure this doesn't happen you can load the "null" +provider into the default library context. Because a provider has been +explicitly loaded, the default provider will not automatically load. This means +code using the default context by accident will fail because no algorithms will +be available. + +See L for additional information about the +Library Context. + +=head2 Using Encoders and Decoders with the FIPS module + +Encoders and decoders are used to read and write keys or parameters from or to +some external format (for example a PEM file). If your application generates +keys or parameters that then need to be written into PEM or DER format +then it is likely that you will need to use an encoder to do this. Similarly +you need a decoder to read previously saved keys and parameters. In most cases +this will be invisible to you if you are using APIs that existed in +OpenSSL 1.1.1 or earlier such as L. However the appropriate +encoder/decoder will need to be available in the library context associated with +the key or parameter object. The built-in OpenSSL encoders and decoders are +implemented in both the default and base providers and are not in the FIPS +module boundary. However since they are not cryptographic algorithms themselves +it is still possible to use them in conjunction with the FIPS module, and +therefore these encoders/decoders have the "fips=yes" property against them. +You should ensure that either the default or base provider is loaded into the +library context in this case. + +=head2 Using the FIPS module in SSL/TLS + +Writing an application that uses libssl in conjunction with the FIPS module is +much the same as writing a normal libssl application. If you are using global +properties and the default library context to specify usage of FIPS validated +algorithms then this will happen automatically for all cryptographic algorithms +in libssl. If you are using a nondefault library context to load the FIPS +provider then you can supply this to libssl using the function +L. This works as a drop in replacement for the function +L except it provides you with the capability to specify the +library context to be used. You can also use the same function to specify +libssl specific properties to use. + +In this first example we create two SSL_CTX objects using two different library +contexts. + + /* + * We assume that a nondefault library context with the FIPS provider + * loaded has been created called fips_libctx. + / + SSL_CTX *fips_ssl_ctx = SSL_CTX_new_ex(fips_libctx, NULL, TLS_method()); + /* + * We assume that a nondefault library context with the default provider + * loaded has been created called non_fips_libctx. + */ + SSL_CTX *non_fips_ssl_ctx = SSL_CTX_new_ex(non_fips_libctx, NULL, + TLS_method()); + +In this second example we create two SSL_CTX objects using different properties +to specify FIPS usage: + + /* + * The "fips=yes" property includes all FIPS approved algorithms as well as + * encoders from the default provider that are allowed to be used. The NULL + * below indicates that we are using the default library context. + */ + SSL_CTX *fips_ssl_ctx = SSL_CTX_new_ex(NULL, "fips=yes", TLS_method()); + /* + * The "provider!=fips" property allows algorithms from any provider except + * the FIPS provider + */ + SSL_CTX *non_fips_ssl_ctx = SSL_CTX_new_ex(NULL, "provider!=fips", + TLS_method()); + +=head2 Confirming that an algorithm is being provided by the FIPS module + +A chain of links needs to be followed to go from an algorithm instance to the +provider that implements it. The process is similar for all algorithms. Here the +example of a digest is used. + +To go from an B to an B, use L . +To go from the B to its B, use L. +To extract the name from the B, use L. + +=head1 SEE ALSO + +L, +L + +=head1 COPYRIGHT + +Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/man7/migration_guide.pod b/doc/man7/migration_guide.pod new file mode 100644 index 0000000000..58260860de --- /dev/null +++ b/doc/man7/migration_guide.pod @@ -0,0 +1,1804 @@ +=pod + +=head1 NAME + +migration_guide - OpenSSL migration guide + +=head1 SYNOPSIS + +See the individual manual pages for details. + +=head1 DESCRIPTION + +This guide details the changes required to migrate to new versions of OpenSSL. +Currently this covers OpenSSL 3.0. For earlier versions refer to +L. +For an overview of some of the key concepts introduced in OpenSSL 3.0 see +L. + +=head1 OPENSSL 3_0 + +=head2 Main Changes from OpenSSL 1.1.1 + +=head3 Major Release + +OpenSSL 3.0 is a major release and consequently any application that currently +uses an older version of OpenSSL will at the very least need to be recompiled in +order to work with the new version. It is the intention that the large majority +of applications will work unchanged with OpenSSL 3.0 if those applications +previously worked with OpenSSL 1.1.1. However this is not guaranteed and some +changes may be required in some cases. Changes may also be required if +applications need to take advantage of some of the new features available in +OpenSSL 3.0 such as the availability of the FIPS module. + +=head3 License Change + +In previous versions, OpenSSL was licensed under the L +(both licenses apply). From OpenSSL 3.0 this is replaced by the +L. + +=head3 Providers and FIPS support + +One of the key changes from OpenSSL 1.1.1 is the introduction of the Provider +concept. Providers collect together and make available algorithm implementations. +With OpenSSL 3.0 it is possible to specify, either programmatically or via a +config file, which providers you want to use for any given application. +OpenSSL 3.0 comes with 5 different providers as standard. Over time third +parties may distribute additional providers that can be plugged into OpenSSL. +All algorithm implementations available via providers are accessed through the +"high level" APIs (for example those functions prefixed with "EVP"). They cannot +be accessed using the L. +One of the standard providers available is the FIPS provider. This makes +available FIPS validated cryptographic algorithms. +The FIPS provider is disabled by default and needs to be enabled explicitly +at configuration time using the `enable-fips` option. If it is enabled, +the FIPS provider gets built and installed in addition to the other standard +providers. No separate installation procedure is necessary. +There is however a dedicated `install_fips` make target, which serves the +special purpose of installing only the FIPS provider into an existing +OpenSSL installation. + +See also L for information on the legacy provider. + +See also L and +L. + +=head3 Low Level APIs + +OpenSSL has historically provided two sets of APIs for invoking cryptographic +algorithms: the "high level" APIs (such as the "EVP" APIs) and the "low level" +APIs. The high level APIs are typically designed to work across all algorithm +types. The "low level" APIs are targeted at a specific algorithm implementation. +For example, the EVP APIs provide the functions L, +L and L to perform symmetric +encryption. Those functions can be used with the algorithms AES, CHACHA, 3DES etc. +On the other hand, to do AES encryption using the low level APIs you would have +to call AES specific functions such as L, +L, and so on. The functions for 3DES are different. +Use of the low level APIs has been informally discouraged by the OpenSSL +development team for a long time. However in OpenSSL 3.0 this is made more +formal. All such low level APIs have been deprecated. You may still use them in +your applications, but you may start to see deprecation warnings during +compilation (dependent on compiler support for this). Deprecated APIs may be +removed from future versions of OpenSSL so you are strongly encouraged to update +your code to use the high level APIs instead. + +This is described in more detail in L + +=head3 Legacy Algorithms + +Some cryptographic algorithms such as B and B that were available via +the EVP APIs are now considered legacy and their use is strongly discouraged. +These legacy EVP algorithms are still available in OpenSSL 3.0 but not by +default. If you want to use them then you must load the legacy provider. +This can be as simple as a config file change, or can be done programmatically. +See L for a complete list of algorithms. +Applications using the EVP APIs to access these algorithms should instead use +more modern algorithms. If that is not possible then these applications +should ensure that the legacy provider has been loaded. This can be achieved +either programmatically or via configuration. See L man page for +more information about providers. + +=head3 Engines and "METHOD" APIs + +The refactoring to support Providers conflicts internally with the APIs used to +support engines, including the ENGINE API and any function that creates or +modifies custom "METHODS" (for example L, +L, L, L, +L, etc.). These functions are being deprecated in +OpenSSL 3.0, and users of these APIs should know that their use can likely +bypass provider selection and configuration, with unintended consequences. +This is particularly relevant for applications written to use the OpenSSL 3.0 +FIPS module, as detailed below. Authors and maintainers of external engines are +strongly encouraged to refactor their code transforming engines into providers +using the new Provider API and avoiding deprecated methods. + +=head3 Versioning Scheme + +The OpenSSL versioning scheme has changed with the OpenSSL 3.0 release. The new +versioning scheme has this format: + +MAJOR.MINOR.PATCH + +For OpenSSL 1.1.1 and below, different patch levels were indicated by a letter +at the end of the release version number. This will no longer be used and +instead the patch level is indicated by the final number in the version. A +change in the second (MINOR) number indicates that new features may have been +added. OpenSSL versions with the same major number are API and ABI compatible. +If the major number changes then API and ABI compatibility is not guaranteed. + +=head3 Other major new features + +=head4 Certificate Management Protocol (CMP, RFC 4210) + +This also covers CRMF (RFC 4211) and HTTP transfer (RFC 6712) +See L and L as starting points. + +=head4 HTTP(S) client + +A proper HTTP(S) client that supports GET and POST, redirection, plain and +ASN.1-encoded contents, proxies, and timeouts. + +=head4 Key Derivation Function API (EVP_KDF) + +This simplifies the process of adding new KDF and PRF implementations. + +Previously KDF algorithms had been shoe-horned into using the EVP_PKEY object +which was not a logical mapping. +Existing applications that use KDF algorithms using EVP_PKEY +(scrypt, TLS1 PRF and HKDF) may be slower as they use an EVP_KDF bridge +internally. +All new applications should use the new L interface. +See also L and +L. + +=head4 Message Authentication Code API (EVP_MAC) + +This simplifies the process of adding MAC implementations. + +This includes a generic EVP_PKEY to EVP_MAC bridge, to facilitate the continued +use of MACs through raw private keys in functionality such as +L and L. + +All new applications should use the new L interface. +See also L +and L. + +=head4 Support for Linux Kernel TLS + +In order to use KTLS, support for it must be compiled in using the 'enable-ktls' +compile time option. It must also be enabled at run time using the +B option. + +=head4 New Algorithms + +=over 4 + +=item KDF algorithms "SINGLE STEP" and "SSH" + +See L and L + +=item MAC Algorithms "GMAC" and "KMAC" + +See L and L. + +=item KEM Algorithm "RSASVE" + +See L. + +=item Cipher Algorithm "AES-SIV" + +See L. + +=item AES Key Wrap inverse ciphers supported by EVP layer. + +The inverse ciphers use AES decryption for wrapping, and AES encryption for +unwrapping. The algorithms are: "AES-128-WRAP-INV", "AES-192-WRAP-INV", +"AES-256-WRAP-INV", "AES-128-WRAP-PAD-INV", "AES-192-WRAP-PAD-INV" and +"AES-256-WRAP-PAD-INV". + +=item AES CTS cipher added to EVP layer. + +The algorithms are "AES-128-CBC-CTS", "AES-192-CBC-CTS" and "AES-256-CBC-CTS". +CS1, CS2 and CS3 variants are supported. + +=back + +=head4 CMS and PKCS#7 updates + +=over 4 + +=item Added CAdES-BES signature verification support. + +=item Added CAdES-BES signature scheme and attributes support (RFC 5126) to CMS API. + +=item Added AuthEnvelopedData content type structure (RFC 5083) using AES_GCM + +This uses the AES-GCM parameter (RFC 5084) for the Cryptographic Message Syntax. +Its purpose is to support encryption and decryption of a digital envelope that +is both authenticated and encrypted using AES GCM mode. + +=item L and L were made public. + +=back + +=head4 PKCS#12 API updates + +The default algorithms for pkcs12 creation with the PKCS12_create() function +were changed to more modern PBKDF2 and AES based algorithms. The default +MAC iteration count was changed to PKCS12_DEFAULT_ITER to make it equal +with the password-based encryption iteration count. The default digest +algorithm for the MAC computation was changed to SHA-256. The pkcs12 +application now supports -legacy option that restores the previous +default algorithms to support interoperability with legacy systems. + +Added enhanced PKCS#12 APIs which accept a library context `OSSL_LIB_CTX` +and (where relevant) a property query. Other APIs which handle PKCS#7 and +PKCS#8 objects have also been enhanced where required. This includes: + +L, L, L, +L, L, L, +L, L, +L, L, L, +L, L, L, +L, L, +L, L, L, +L, L, +L, L, L. + +As part of this change the EVP_PBE_xxx APIs can also accept a library +context and property query and will call an extended version of the key/IV +derivation function which supports these parameters. This includes +L, L and L. + +=head4 Windows thread synchronization changes + +Windows thread synchronization uses read/write primitives (SRWLock) when +supported by the OS, otherwise CriticalSection continues to be used. + +=head4 Trace API + +A new generic trace API has been added which provides support for enabling +instrumentation through trace output. This feature is mainly intended as an aid +for developers and is disabled by default. To utilize it, OpenSSL needs to be +configured with the `enable-trace` option. + +If the tracing API is enabled, the application can activate trace output by +registering BIOs as trace channels for a number of tracing and debugging +categories. See L. + +=head4 Key validation updates + +L and L now work for +more key types. This includes RSA, DSA, ED25519, X25519, ED448 and X448. +Previously (in 1.1.1) they would return -2. For key types that do not have +parameters then L will always return 1. + +=head3 Other notable deprecations and changes + +=head4 The function code part of an OpenSSL error code is no longer relevant + +This code is now always set to zero. Related functions are deprecated. + +=head4 STACK and HASH macro's have been cleaned up + +The type-safe wrappers are declared everywhere and implemented once. +See L and L. + +=head4 The RAND_DRBG subsystem has been removed + +The new L is a partial replacement: the DRBG callback framework is +absent. The RAND_DRBG API did not fit well into the new provider concept as +implemented by EVP_RAND and EVP_RAND_CTX. + +=head4 Removed FIPS_mode() and FIPS_mode_set() + +These functions are legacy APIs that are not applicable to the new provider +model. Applications should instead use +L and +L. + +=head4 Key generation is slower + +The Miller-Rabin test now uses 64 rounds, which is used for all prime generation, +including RSA key generation. This affects the time for larger keys sizes. + +The default key generation method for the regular 2-prime RSA keys was changed +to the FIPS 186-4 B.3.6 method (Generation of Probable Primes with Conditions +Based on Auxiliary Probable Primes). This method is slower than the original +method. + +=head4 Change PBKDF2 to conform to SP800-132 instead of the older PKCS5 RFC2898 + +This checks that the salt length is at least 128 bits, the derived key length is +at least 112 bits, and that the iteration count is at least 1000. +For backwards compatibility these checks are disabled by default in the +default provider, but are enabled by default in the fips provider. + +To enable or disable the checks see B in +L. The parameter can be set using L. + +=head4 Enforce a minimum DH modulus size of 512 bits + +Smaller sizes now result in an error. + +=head4 SM2 key changes + +EC EVP_PKEYs with the SM2 curve have been reworked to automatically become +EVP_PKEY_SM2 rather than EVP_PKEY_EC. + +Unlike in previous OpenSSL versions, this means that applications cannot +call `EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)` to get SM2 computations. + +Parameter and key generation is also reworked to make it possible +to generate EVP_PKEY_SM2 parameters and keys. Applications must now generate +SM2 keys directly and must not create an EVP_PKEY_EC key first. + +Validation of SM2 keys has been separated from the validation of regular EC +keys, allowing to improve the SM2 validation process to reject loaded private +keys that are not conforming to the SM2 ISO standard. +In particular, a private scalar `k` outside the range `1 <= k < n-1` is now +correctly rejected. + +=head4 EVP_PKEY_set_alias_type() method has been removed + +This function made a B object mutable after it had been set up. In +OpenSSL 3.0 it was decided that a provided key should not be able to change its +type, so this function has been removed. + +=head4 Functions that return an internal key should be treated as read only + +Functions such as L behave slightly differently in +OpenSSL 3.0. Previously they returned a pointer to the low-level key used +internally by libcrypto. From OpenSSL 3.0 this key may now be held in a +provider. Calling these functions will only return a handle on the internal key +where the EVP_PKEY was constructed using this key in the first place, for +example using a function or macro such as L, +L, etc. +Where the EVP_PKEY holds a provider managed key, then these functions now return +a cached copy of the key. Changes to the internal provider key that take place +after the first time the cached key is accessed will not be reflected back in +the cached copy. Similarly any changes made to the cached copy by application +code will not be reflected back in the internal provider key. + +For the above reasons the keys returned from these functions should typically be +treated as read-only. To emphasise this the value returned from +L, L, L and +L have been made const. This may break some existing code. +Applications broken by this change should be modified. The preferred solution is +to refactor the code to avoid the use of these deprecated functions. Failing +this the code should be modified to use a const pointer instead. +The L, L, L +and L functions continue to return a non-const pointer to +enable them to be "freed". However they should also be treated as read-only. + +=head4 The public key check has moved from EVP_PKEY_derive() to EVP_PKEY_derive_set_peer() + +This may mean result in an error in L rather than +during L. +To disable this check use EVP_PKEY_derive_set_peer_ex(dh, peer, 0). + +=head4 The print format has cosmetic changes for some functions + +The output from numerous "printing" functions such as L, +L, L, and other similar functions has been +amended such that there may be cosmetic differences between the output +observed in 1.1.1 and 3.0. This also applies to the "-text" output from the +x509 and crl applications. + +=head4 Interactive mode from the `openssl` program has been removed + +From now on, running it without arguments is equivalent to `openssl help`. + +=head4 The error return values from some control calls (ctrl) have changed + +One significant change is that controls which used to return -2 for +invalid inputs, now return -1 indicating a generic error condition instead. + +=head4 DH and DHX key types have different settable parameters + +Previously (in 1.1.1) these conflicting parameters were allowed, but will now +result in errors. See L for further details. This affects the +behaviour of L for DH parameter generation. + +=head2 Installation and Compilation + +Please refer to the INSTALL.md file in the top of the distribution for +instructions on how to build and install OpenSSL 3.0. Please also refer to the +various platform specific NOTES files for your specific platform. + +=head2 Upgrading from OpenSSL 1.1.1 + +Upgrading to OpenSSL 3.0 from OpenSSL 1.1.1 should be relatively straight +forward in most cases. The most likely area where you will encounter problems +is if you have used low level APIs in your code (as discussed above). In that +case you are likely to start seeing deprecation warnings when compiling your +application. If this happens you have 3 options: + +=over 4 + +=item 1) Ignore the warnings. They are just warnings. The deprecated functions are still present and you may still use them. However be aware that they may be removed from a future version of OpenSSL. + +=item 2) Suppress the warnings. Refer to your compiler documentation on how to do this. + +=item 3) Remove your usage of the low level APIs. In this case you will need to rewrite your code to use the high level APIs instead + +=back + +=head2 Upgrading from OpenSSL 1.0.2 + +Upgrading to OpenSSL 3.0 from OpenSSL 1.0.2 is likely to be significantly more +difficult. In addition to the issues discussed above in the section about +L, the main things to be aware of are: + +=over 4 + +=item 1) The build and installation procedure has changed significantly. + +Check the file INSTALL.md in the top of the installation for instructions on how +to build and install OpenSSL for your platform. Also read the various NOTES +files in the same directory, as applicable for your platform. + +=item 2) Many structures have been made opaque in OpenSSL 3.0. + +The structure definitions have been removed from the public header files and +moved to internal header files. In practice this means that you can no longer +stack allocate some structures. Instead they must be heap allocated through some +function call (typically those function names have a `_new` suffix to them). +Additionally you must use "setter" or "getter" functions to access the fields +within those structures. + +For example code that previously looked like this: + + EVP_MD_CTX md_ctx; + + /* This line will now generate compiler errors */ + EVP_MD_CTX_init(&md_ctx); + + The code needs to be amended to look like this: + EVP_MD_CTX *md_ctx; + + md_ctx = EVP_MD_CTX_new(); + ... + ... + EVP_MD_CTX_free(md_ctx); + +=item 3) Support for TLSv1.3 has been added. + +This has a number of implications for SSL/TLS applications. See the +L for further details. + +=back + +More details about the breaking changes between OpenSSL versions 1.0.2 and 1.1.0 +can be found on the +L. + +=head3 Upgrading from the OpenSSL 2.0 FIPS Object Module + +The OpenSSL 2.0 FIPS Object Module was a separate download that had to be built +separately and then integrated into your main OpenSSL 1.0.2 build. +In OpenSSL 3.0 the FIPS support is fully integrated into the mainline version of +OpenSSL and is no longer a separate download. For further information see +L. + +The function calls 'FIPS_mode()' and 'FIPS_mode_set()' have been removed +from OpenSSL 3.0. You should rewrite your application to not use them. +See L and L for details. + +=head2 Completing the installation of the FIPS Module + +The FIPS Module will be built and installed automatically if FIPS support has +been configured. The current documentation can be found in the +L file. + +=head2 Programming + +Applications written to work with OpenSSL 1.1.1 will mostly just work with +OpenSSL 3.0. However changes will be required if you want to take advantage of +some of the new features that OpenSSL 3.0 makes available. In order to do that +you need to understand some new concepts introduced in OpenSSL 3.0. +Read L for further information. + +=head3 Library Context + +A library context allows different components of a complex application to each +use a different library context and have different providers loaded with +different configuration settings. +See L for further info. + +If the user creates an B via L then many +functions may need to be changed to pass additional parameters to handle the +library context. + +=head4 Using a Library Context - Old functions that should be changed + +If a library context is needed then all EVP_* digest functions that return a +B such as EVP_sha256() should be replaced with a call to +L. See L. + +If a library context is needed then all EVP_* cipher functions that return a +B such as EVP_aes_128_cbc() should be replaced vith a call to +L. See L. + +Some functions can be passed an object that has already been set up with a library +context such as L, L and L. +If NULL is passed instead then the created object will be set up with the +default library context. Use L, L and +L if a library context is required. + +All functions listed below with a I have a replacment function I +that takes B as an additional argument. Functions that have other +mappings are listed along with the respective name. + +=over 4 + +=item L and L + +=item L and L + +=item L, L, L, +L, L, L, +L, L and L + +=item L + +=item L, L and L + +=item L + +=item L, L and L + +=item L and L + +Use L and L + +=item L + +Use L or L. + +=item L and L + +=item L, L and L + +=item L + +=item L + +Use L + +=item L, L +and L + +=item L and L + +=item L + +=item L and L + +=item L + +=item L + +=item L, L, L, +L and L + +=item L, L, L +and L + +=item L and L + +=item L, L, L, +L, L, L, L, +L, L, L, +L, L, L, +L, L + +=item L, L, L, +L and L + +=item L, L and L + +=item L, L and L + +=item L and L + +=item L + +=item L + +=item L + +=item L and L + +=item L and L + +=item L + +=item L + +=item L and L + +=item L, L, L, +L and L + +=back + +=head4 New functions that use a Library context + +The following functions can be passed a library context if required. +Passing NULL will use the default library context. + +=over 4 + +=item L and L + +=item L and L + +=item L and +L + +=item L and L + +=item L and L + +=item L and L + +=item L and L + +=item L and L + +=item L and L + +=item L + +=item L + +=item L and L + +=item L and L + +=item L + +=item L and L + +=item L and L + +=item L + +=item L and L + +=item L and L + +=item L and L + +=item L and L + +=item L + +=item L and L + +=item L, L and L + +=item L, L, +L, L, +L and L + +=item L and L + +=item L + +=item L and L + +=item L, L, L, +L and L + +=back + +=head3 Providers + +Providers are described in detail here L. +See also L. + +=head3 Fetching algorithms and property queries + +Implicit and Explicit Fetching is described in detail here +L. + +=head3 Deprecation of Low Level Functions + +A significant number of APIs have been deprecated in OpenSSL 3.0. +This section describes some common categories of deprecations. +See L for the list of deprecated functions +that refer to these categories. + +=head4 Providers are a replacement for engines and low-level method overrides + +Any accessor that uses an ENGINE is deprecated (such as EVP_PKEY_set1_engine()). +Applications using engines should instead use providers. + +Before providers were added algorithms were overriden by changing the methods +used by algorithms. All these methods such as RSA_new_method() and RSA_meth_new() +are now deprecated and can be replaced by using providers instead. + +=head4 Deprecated i2d and d2i functions for low-level key types + +Any i2d and d2i functions such as d2i_DHparams() that take a low-level key type +have been deprecated. Applications should instead use the L and +L APIs to read and write files. +See L for further details. + +=head4 Deprecated low-level key object getters and setters + +Applications that set or get low-level key objects (such as EVP_PKEY_set1_DH() +or EVP_PKEY_get0()) should instead use the OSSL_ENCODER +(See L) or OSSL_DECODER (See L) +APIs, or alternatively use L or L. + +=head4 Deprecated low-level key parameter getters + +Functions that access low-level objects directly such as L are now +deprecated. Applications should use one of L, +L, l, +L, L or +L to access fields from an EVP_PKEY. +Gettable parameters are listed in L, +L, L, +L, L and +L. +Applications may also use L to return all fields. + +=head4 Deprecated low-level key parameter setters + +Functions that access low-level objects directly such as L +are now deprecated. Applications should use L to create +new keys from user provided key data. Keys should be immutable once they are +created, so if required the user may use L, L, +and L to create a modified key. +See L for more information. +See L for information on +generating a key using parameters. + +=head4 Deprecated low-level object creation + +Low-level objects were created using methods such as L, +L and L. Applications should instead use the +high-level EVP_PKEY APIs, e.g. L, L and +L. +See also L and L. + +EVP_PKEY's may be created in a variety of ways: +See also L, +L and +L. + +=head4 Deprecated low-level encryption functions + +Low-level encryption functions such as L and L +have been informally discouraged from use for a long time. Applications should +instead use the high level EVP APIs L, +L, and L or +L, L and L. + +=head4 Deprecated low-level digest functions + +Use of low-level digest functions such as L have been +informally discouraged from use for a long time. Applications should instead +use the the high level EVP APIs L, L +and L, or the quick one-shot L. + +Note that the functions L, L, L, L +and L have changed to macros that use L. + +=head4 Deprecated low-level signing functions + +Use of low-level signing functions such as L have been +informally discouraged for a long time. Instead applications should use +L and L. +See also L, L, +L and L. + +=head4 Deprecated low-level MAC functions + +Low-level mac functions such as L are deprecated. +Applications should instead use the new L interface, using +L, L, L, +L and L or the single-shot MAC function +L. +See L, L, L, L, +L, L, L and +L for additional information. + +Note that the one-shot method HMAC() is still available for compatability purposes. + +=head4 Deprecated low-level validation functions + +Low-level validation functions such as L have been informally +discouraged from use for a long time. Applications should instead use the high-level +EVP_PKEY APIs such as L, L, +L, L, +L, L, +and L. + +=head4 Deprecated low-level key exchange functions + +Many low-level functions have been informally discouraged from use for a long +time. Applications should instead use L. +See L, L and L. + +=head4 Deprecated low-level key generation functions + +Many low-level functions have been informally discouraged from use for a long +time. Applications should instead use L and +L as described in L, L, +L, L and L. +The 'quick' one-shot function L and macros for the most +common cases: and L may also be used. + +=head4 Deprecated low-level key reading and writing functions + +Use of low-level objects (such as DSA) has been informally discouraged from use +for a long time. Functions to read and write these low-level objects (such as +PEM_read_DSA_PUBKEY()) should be replaced. Applications should instead use +L and L. + +=head4 Deprecated low-level key printing functions + +Use of low-level objects (such as DSA) has been informally discouraged from use +for a long time. Functions to print these low-level objects such as +DSA_print() should be replaced with the equivalent EVP_PKEY functions. +Application should use one of L, +L, L, +L, L or +L. Note that internally these use +L and L. + +=head3 Deprecated function mappings + +The following functions have been deprecated in 3.0. + +=over 4 + +=item AES_bi_ige_encrypt and AES_ige_encrypt + +There is no replacement for the IGE functions. New code should not use these modes. +These undocumented functions were never integrated into the EVP layer. +They implemented the AES Infinite Garble Extension (IGE) mode and AES +Bi-directional IGE mode. These modes were never formally standardised and +usage of these functions is believed to be very small. In particular +AES_bi_ige_encrypt() has a known bug. It accepts 2 AES keys, but only one +is ever used. The security implications are believed to be minimal, but +this issue was never fixed for backwards compatibility reasons. + +=item AES_encrypt, AES_decrypt, AES_set_encrypt_key, AES_set_decrypt_key, +AES_cbc_encrypt, AES_cfb128_encrypt, AES_cfb1_encrypt, AES_cfb8_encrypt, +AES_ecb_encrypt and AES_ofb128_encrypt + +=item AES_unwrap_key, AES_wr