Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto/internal: prevent cryptofallback in requirefips mode
In many instances systemcrypto backend is tested for support of a particular algorithm. If it is supported, it is used, otherwise gocrypto fallback code path is used. This means effectively the toolchain allows to use MD5 DES TripleDES Ed25519 RC4 HKDF TLS1PF implemented with gocrypto, when FIPS module blocks these algorithms or doesn't even support them (i.e. when only base+fips providers are loaded). In some cases this might be due to incorrect check and/or incorrect runtime configuration of OpenSSL. It is very common to accidentaly activate "default" and "fips" providers in OpenSSL at the same time - which then exhibits odd properties. Specifically "default+fips" providers will list that RC4 and MD5 are supported without any property query strings. But fail at runtime when attempted to be used with property query string set to "fips=yes". If on the other hand "base" and "fips" providers loaded alone, RC4 and MD5 will not be listed as runtime available, and gocrypto fallback path may be taken by the toolchain. A similar issue is currently also present in cpython please see python/cpython#118224. Note that recommended way to configure OpenSSL in fips only mode is with base+fips providers alone - see https://github.com/openssl/openssl/blob/master/README-PROVIDERS.md such that default & legacy providers algorithms are not exposed at runtime. And this is how OpenSSL is configured in FIPS mode on Ubuntu Pro FIPS and Chainguard FIPS Images, and recommended by upstream. Please note internally md5 is used by go coverage, meaning in requirefips case coverage may fail to generate unless some additional APIs are introduced to allow insecure usage of md5 (equivalent to python's usedforsecurity=True|False flag). Or coverage ported to use SHA256. For a local reproducer use base+fips providers only, for example with following openssl.cnf: ``` config_diagnostics = 1 openssl_conf = openssl_init .include /etc/ssl/fipsmodule.cnf [openssl_init] providers = provider_sect alg_section = algorithm_sect [provider_sect] fips = fips_sect base = base_sect [base_sect] activate = 1 [algorithm_sect] default_properties = fips=yes ``` Or compile openssl without RC4 support by using 'no-rc4' configuration option. Signed-off-by: Dimitri John Ledkov <[email protected]>
- Loading branch information