Difference between revisions of "OpenSSL 3.0"

From OpenSSLWiki
Jump to navigationJump to search
Line 542: Line 542:
| ECDH                                || default, FIPS  || 100%              || ??
| ECDH                                || default, FIPS  || 100%              || ??
| X25519, X448                        || default, FIPS  || 100%              || ??
| X25519, X448                        || default, FIPS  || 100%              || ?? || These cannot yet be FIPS validated.

Revision as of 06:43, 22 April 2020


OpenSSL 3.0 is the next release of OpenSSL that is currently in development. This page is intended as a collection of notes for people downloading the alpha/beta releases or who are planning to upgrade from a previous version of OpenSSL to 3.0.

Main Changes in OpenSSL 3.0 from OpenSSL 1.1.1

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.

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 4 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 "EVP" set of APIs. They cannot be accessed using the "low level" APIs (see below).

Low Level APIs

OpenSSL has historically provided two sets of APIs for invoking cryptographic algorithms: the "EVP" APIs and the "low level" APIs. The EVP 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 `EVP_EncryptInit_ex`, `EVP_EncryptUpdate` and `EVP_EncryptFinal` 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 `AES_set_encrypt_key`, `AES_encrypt`, 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 EVP APIs instead.

Legacy Algorithms

Some cryptographic algorithms 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 below).

Upgrading to OpenSSL 3.0 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:

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.

2) Suppress the warnings. Refer to your compiler documentation on how to do this.

3) Remove your usage of the low level APIs. In this case you will need to rewrite your code to use the EVP APIs instead.

Upgrading to OpenSSL 3.0 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 upgrading from 1.1.1, the main things to be aware of are:

1) The build and installation procedure has changed significantly since OpenSSL 1.0.2. Check the file INSTALL.md in the top of the installation for instructions on how to build and install OpenSSL for your platform. Also checkout the various NOTES files in the same directory, as applicable for your platform.

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;


/* Do something with the md_ctx */

will now generate compiler errors. For example:

md_ctx.c:6:16: error: storage size of ‘md_ctx’ isn’t known

The code needs to be amended to look like this:

EVP_MD_CTX *md_ctx;

md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL)
   /* Error */;

/* Do something with the md_ctx */


3) Support for TLSv1.3 has been added which has a number of implications for SSL/TLS applications. See the TLS1.3 page for further details.

Upgrading from the 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. You do not need to take separate build steps to add the FIPS support - it is built by default. You do need to take steps to ensure that your application is using the FIPS module in OpenSSL 3.0. See the further notes below on configuring this.

The function calls 'FIPS_mode()' and 'FIPS_mode_set()' are present in OpenSSL 3.0 but always fail. You should rewrite your application to not use them. See the sections below on how to write applications to use the FIPS Module in OpenSSL 3.0.

Completing the installation of the FIPS Module

Once OpenSSL has been built and installed you will need to take explicit steps to complete the installation of the FIPS module. The OpenSSL 3.0 FIPS support is in the form of the FIPS provider which, on Unix, is in a `fips.so` file. On Windows this will be called `fips.dll`. Following installation of OpenSSL 3.0 the default location for this file is '/usr/local/lib/ossl-modules/fips.so' on Unix or 'C:\Program Files\OpenSSL\lib\fips.dll' on Windows. (Drafting note: need to check the locations are correct!)

To complete the installation you need to run the 'fipsinstall' command line application. This does 2 things:

  • Runs the FIPS module self tests
  • Generates FIPS module config file output containing information about the module such as the self test status, and the module checksum

The FIPS module must have the self tests run, and the FIPS module config file output generated on every machine that it is to be used on. You must not copy the FIPS module config file output data from one machine to another.

For example, to install the module:

$ openssl fipsinstall -out /usr/local/ssl/fipsinstall.cnf -module /usr/local/lib/ossl-modules/fips.so -provider_name fips -mac_name HMAC -macopt digest:SHA256 -macopt hexkey:00 -section_name fips_sect

Programming in OpenSSL 3.0

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.

Library Contexts

A library context can be thought of as a "scope" for OpenSSL operations. All functionality operates with the scope of a library context. Multiple library contexts may exist at the same time, and they each may be configured differently. A library context is represented by the newly introduced OPENSSL_CTX type. See the man page here.

Many new functions have been introduced into OpenSSL that take an OPENSSL_CTX parameter. In many cases these are variants of some other function that existed in 1.1.1 and work in much the same way - except that they now operate within the scope of the given library context.

All applications have available to them the "default library context". This library context always exists and, if you don't otherwise specify one, this is the library context that will be used. Any function that takes an OPENSSL_CTX value as a parameter will accept the value NULL for that parameter in order to refer to the default library context. You can also explicitly create new ones via the OPENSSL_CTX_new() function. See the man page for further details.

Config files affect a given library context. It is quite possible to have multiple library contexts in use, with each one having been configured with a different config file (see the OPENSSL_CTX_load_config() function described on the man page).


Providers are containers for algorithm implementations. Whenever a cryptographic algorithm is used via the EVP APIs a provider is selected. It is that provider implementation that actually does the required work. There are four providers distributed with OpenSSL. In the future we expect third parties to distribute their own providers which can be added to OpenSSL dynamically. Documentation about writing providers is available on the man page here.

The standard providers are:

  • The default provider. This collects together all of the standard built-in OpenSSL algorithm implementations. If an application doesn't specify anything else explicitly or via config, then this is the provider that will be used. It is loaded automatically the first time that we try to get an algorithm from a provider if no other provider has been loaded yet. This is a "built-in" provider which means that it is built into libcrypto and does not exist as a separate standalone module.
  • The legacy provider. This is a collection of legacy algorithms that are either no longer in common use or strongly discouraged from use. However some applications may need to use these algorithms for backwards compatibility reasons. This provider is NOT loaded by default. This may mean that some applications upgrading from earlier versions of OpenSSL may find that some algorithms are no longer available unless they load the legacy provider explicitly. Algorithms in the legacy provider include MD2, MD4, MDC2, RMD160, CAST5, BF (Blowfish), IDEA, SEED, RC2, RC4, RC5 and DES (but not 3DES).
  • The FIPS provider. This contains a sub-set of the algorithm implementations available from the default provider. Algorithms available in this provider conform to FIPS standards. It is intended that this provider will be FIPS140-2 validated. In some cases there maybe minor behavioural differences between algorithm implementations in this provider compared to the equivalent algorithm in the default provider. This is typically in order to conform to FIPS standards.
  • The null provider. This provider is "built-in" to libcrypto and contains no algorithm implementations. It can be useful in some situations where you want to avoid the automatic loading of the default provider.

Providers to be loaded can be specified in the OpenSSL config file. See the man page herefor information about how to configure providers via the config file, and how to automatically activate them. It is also possible to load them programmatically. For example you can load the legacy provider into the default library context as shown below. Note that once you have explicitly loaded a provider into the library context the default provider will no longer be automatically loaded. Therefore you will often also want to explicitly load the default provider, as is done here:

   #include <openssl/provider.h>
   int main(void)
       OSSL_PROVIDER *legacy;
       OSSL_PROVIDER *deflt;
       legacy = OSSL_PROVIDER_load(NULL, "legacy");
       if (legacy == NULL) {
           printf("Failed to load Legacy provider\n");
       deflt = OSSL_PROVIDER_load(NULL, "default");
       if (deflt == NULL) {
           printf("Failed to load Default provider\n");
       /* Rest of application */

Fetching algorithms and property queries

In order to use a cryptographic algorithm (such as AES) then an implementation for it must first be "fetched" from the available providers that have been loaded into the library context being used. This can be done either implicitly or explicitly.

With implicit fetching the application does not need to do anything special. Algorithms implementations will be fetched automatically by the relevant APIs. For example:

   EVP_MD_CTX *mdctx;
   mdctx = EVP_MD_CTX_new();
   if (mdctx == NULL)
       goto err;
   if (EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL) != 1)
       goto err;

In this code we are initialising a digest operation to use the SHA256 algorithm. The EVP_DigestInit_ex() function will automatically fetch an implementation of the SHA256 algorithm from the available providers when it needs to. It will do so using the default library context and the default property query string (see below).

With explicit fetching an application fetches the implementation to be used up front, and then passes that to the relevant EVP API. For example:

   EVP_MD_CTX *mdctx;
   EVP_MD *sha256;
   mdctx = EVP_MD_CTX_new();
   if (mdctx == NULL)
       goto err;
   sha256 = EVP_MD_fetch(NULL, "SHA2-256", NULL);
   if (sha256 == NULL)
       goto err;
   if (EVP_DigestInit_ex(mdctx, sha256, NULL) != 1)
       goto err;

In this example we have explicitly fetched an implementation of SHA256 from the set of available providers loaded into the default library context.

With an explicit fetch we can additionally supply a property query to further specify which implementation we wish to obtain. For example:

   sha256 = EVP_MD_fetch(NULL, "SHA2-256", "fips=yes");

Here we are explicitly fetching a FIPS validated implementation of the SHA256 algorithm. Such an implementation exists in the FIPS provider, so we would need to have ensured that the FIPS provider was loaded into the default library context in order for this to be successful. If no algorithm implementation that matches the criteria can be located then the fetch will fail.

See the section on fetching algorithms in the provider man page for further details: [1].


Using the FIPS Module in applications

There are a number of 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.

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 will 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 on 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/fipsinstall.cnf

providers = provider_sect

fips = fips_sect

Obviously the include file location above should match the name of the FIPS module config file that you installed earlier.

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.

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:

  • You may not want all applications to use the FIPS module. It may be the case that some applications should and some should not.
  • If applications take explicit steps to not load the default config file or set different settings then this method will not work for them
  • The algorithms available in the FIPS module are a subset of the algorithms that are available in the default OpenSSL Provider. If those applications attempt to use any algorithms that are not present, then they will fail.
  • Usage of certain APIs avoids the use of the FIPS module. If any applications use those APIs then the FIPS module will not be used.

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/non-default/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.

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 the section "Making all applications use the FIPS module by default" above, but edit the fipsinstall.cnf file to remove or comment out the line which says "activate = 1". This means all the required config information will be available to load the FIPS module, but it is not actually automatically loaded when the application starts. The FIPS provider can then be loaded programmatically like this:

   #include <openssl/provider.h>
   int main(void)
       OSSL_PROVIDER *fips;
       fips = OSSL_PROVIDER_load(NULL, "fips");
       if (fips == NULL) {
           printf("Failed to load FIPS provider\n");
       /* Rest of application */

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.

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 EVP APIs instead). All such APIs are deprecated in OpenSSL 3.0 - so a simple rule is to avoid using all deprecated functions.
  • Engines
  • Any functions that create or modify custom "METHODS" (for example EVP_MD_meth_new, EVP_CIPHER_meth_new, EVP_PKEY_meth_new, etc)

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 conform 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. It is also possible for a locally specified property query to override the default properties.

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 approved algorithms match against the property query "fips=yes". The FIPS module also has some non-approved algorithms contained within it (currently X25519, X448, Ed25519 and Ed448). These algorithms do not have the "fips=yes" property defined for them. There are also some non-cryptographic algorithms available in the default provider that also have the "fips=yes" property defined for them. These are the serializer algorithms that can (for example) be used to write out a key generated in the FIPS provider to a file. The serializer 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":

  openssl_conf = openssl_init
  .include /usr/local/ssl/fipsinstall.cnf
  providers = provider_sect
  alg_section = algorithm_sect
  fips = fips_sect
  default = default sect
  activate = 1
  default_properties = fips=yes

Programmatically loading the FIPS module (non-default library context)


Using Serializers with the FIPS module


Non-approved alogrithms available in the FIPS module

STUFF HERE (X25519, X448, ED25519, ED448)

Using the FIPS module in SSL/TLS


STATUS of current development

[this is a collection of notes, changing as time and alpha / beta releases go]

The current status of OpenSSL 3.0 is in development
The next status is expected to be alpha


These are platforms that have been observed so far. More will be added.

Platform Builds Tests Comment
Linux - x86 / x86_64 Yes Yes
Linux - s390x Yes Yes
Windows + Visual C - x86 / x86_64 Yes Yes
MacOS X Yes Mostly
OpenVMS - Alpha / Itanium No Unknown New include directories need to be dealt with, and more elegantly than the 1.1.1 kludge


All the core support features are in.

Provider implemented operation types

Operation type Code completion % Documentation completion % Comment
EVP_DIGEST 100% ??
EVP_CIPHER 100% ??
EVP_MAC 100% ??
EVP_KDF 100% ??
EVP_KEYMGMT 95% 70% Missing functionality for loading HSM keys
OSSL_SERIALIZER 50% 50% Serializer implemented, deserializer not implemented

Provider implemented ciphers

Algorithm Providers Code completion % Documentation completion % Comment
AES default, FIPS 100% ??
ARIA default 100% ??
BF legacy 100% ??
CAMELLIA default 100% ??
CAST legacy 100% ??
DES legacy 100% ??
DESX legacy 100% ??
DES-EDE3 default, FIPS 100% ?? For FIPS, only DES-EDE3-ECB and DES-EDE3-CBC
IDEA legacy 100% ??
RC2 legacy 100% ??
RC4 legacy 100% ??
RC5 legacy 100% ??
SEED legacy 100% ??
SM4 default 100% ??

Provider implemented digests

Algorithm Providers Code completion % Documentation completion % Comment
BLAKE2 default 100% ??
SM3 default 100% ??
MD2 legacy 100% ??
MD4 legacy 100% ??
MD5, MD5-SHA1 default 100% ?? MD5-SHA1 is a TLS special, not otherwise useful
MDC2 legacy 100% ??
SHA1 default, FIPS 100% ??
SHA2 default, FIPS 100% ??
SHA3 default, FIPS 100% ??
SHAKE default, FIPS 100% ?? For FIPS, only SHAKE-256, not SHAKE-128. SHAKE-256 will not be undergoing FIPS validation.
RIPEMD-160 leagcy 100% ??
WHIRLPOOL legacy 100% ??

Provider implemented MACs


Algorithm Providers Code completion % Documentation completion % Comment

Provider implemented KDFs


Algorithm Providers Code completion % Documentation completion % Comment

Provider implemented asymmetric key types

Key type Providers Code completion % Documentation completion % Comment
DH default, FIPS 95% ??
DSA default, FIPS 100% ??
EC default, FIPS 100% ??
ED25519, X25519, ED448, X448 default, FIPS 100% ?? These cannot yet be FIPS validated.
RSA default, FIPS 100% ?? RSA-PSS or RSA-OAEP are considered separate key types, although the RSA EVP_ASYM_CIPHER and EVP_SIGNATURE implementations carry some of the corresponding properties.
RSA-PSS default 0% ?? Scheduled for alpha 2
RSA-OAEP default 0% ??
SM2 default 0% ??

Provider implemented asymmetric ciphers

Algorithm Providers Code completion % Documentation completion % Comment
RSA, RSAES-OAEP default, FIPS 80% ??

Provider implemented signature

Algorithm Providers Code completion % Documentation completion % Comment
DSA default, FIPS 100% ??
ECDSA default, FIPS 100% ??
ED25519, ED448 default, FIPS 100% ?? These cannot yet be FIPS validated.
RSA, RSASSA-PSS default 80% ?? RSASSA-PSS support untested

Provider implemented key exchange

Algorithm Providers Code completion % Documentation completion % Comment
DH default, FIPS 70% ?? We lack support for X9.42 DH, which is needed by CMS
ECDH default, FIPS 100% ??
X25519, X448 default, FIPS 100% ?? These cannot yet be FIPS validated.

Provider implemented serializers / deserializers



Serializer Providers Code completion % Documentation completion % Comment


Deserializer Providers Code completion % Documentation completion % Comment

Provider implemented OSSL_STORE URI schemes


URI scheme Providers Code completion % Documentation completion % Comment

Provider implementation support in other OpenSSL APIs

Diverse OpenSSL APIs have been modified and continue to be modified to support provider implementations.

API Code completion % Documentation completion % Comment
CMS 0% 0% There are hacks in place that downgrade a key to legacy when used with CMS
CMP ?? ?? We need to investigate if we need to change anything
CRMF 5% 0%
PKCS#7 0% 0% There are hacks in place that downgrade a key to legacy when used with PKCS#7
SSL / TLS 50% ??