diff options
author | Vitezslav Cizek <vcizek@suse.com> | 2015-10-29 17:13:16 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-03-18 15:48:15 +0100 |
commit | ce1cbe16992a7340edcf8e6576973e3508267640 (patch) | |
tree | ab4d7c4b3429f83878803f1db98df8830a856dc9 /cipher/md.c | |
parent | c478cf175887c84dc071c4f73a7667603b354789 (diff) | |
download | libgcrypt-ce1cbe16992a7340edcf8e6576973e3508267640.tar.gz |
Disable non-allowed algorithms in FIPS mode
* cipher/cipher.c (_gcry_cipher_init),
* cipher/mac.c (_gcry_mac_init),
* cipher/md.c (_gcry_md_init),
* cipher/pubkey.c (_gcry_pk_init): In the FIPS mode, disable all the
non-allowed ciphers.
* cipher/md5.c: Mark MD5 as not allowed in FIPS.
* src/g10lib.h (_gcry_mac_init): New.
* src/global.c (global_init): Call the new _gcry_mac_init.
* tests/basic.c (check_ciphers): Fix a typo.
--
When running in the FIPS mode, disable all the ciphers that don't have
the fips flag set.
Skip the non-allowed algos during testing in the FIPS mode.
Thanks to Ludwig Nussel.
Signed-off-by: Vitezslav Cizek <vcizek@suse.com>
Signed-off-by: Vitezslav Cizek <vcizek@suse.com>
Diffstat (limited to 'cipher/md.c')
-rw-r--r-- | cipher/md.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cipher/md.c b/cipher/md.c index 15d944d4..281db120 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -1296,6 +1296,17 @@ _gcry_md_info (gcry_md_hd_t h, int cmd, void *buffer, size_t *nbytes) gcry_err_code_t _gcry_md_init (void) { + if (fips_mode()) + { + /* disable algorithms that are disallowed in fips */ + int idx; + gcry_md_spec_t *spec; + + for (idx = 0; (spec = digest_list[idx]); idx++) + if (!spec->flags.fips) + spec->flags.disabled = 1; + } + return 0; } |