From a242e3d9185e6e2dc13902ea9331131755bbba01 Mon Sep 17 00:00:00 2001 From: Vitezslav Cizek Date: Tue, 27 Oct 2015 14:29:11 +0100 Subject: ecc: ECDSA adjustments for FIPS 186-4 * cipher/ecc-curves.c: Unmark curve P-192 for FIPS. * cipher/ecc.c: Add ECDSA self test. * cipher/pubkey-util.c (_gcry_pk_util_init_encoding_ctx): Use SHA-2 in FIPS mode. * tests/fipsdrv.c: Add support for ECDSA signatures. -- Enable ECC in FIPS mode. According to NIST SP 800-131A, curve P-192 and SHA-1 are disallowed for key pair generation and signature generation after 2013. Thanks to Jan Matejek for the patch. Signed-off-by: Vitezslav Cizek Minor source code re-formatting by -wk. --- cipher/pubkey-util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cipher/pubkey-util.c') diff --git a/cipher/pubkey-util.c b/cipher/pubkey-util.c index d0d6003a..76d39232 100644 --- a/cipher/pubkey-util.c +++ b/cipher/pubkey-util.c @@ -617,7 +617,14 @@ _gcry_pk_util_init_encoding_ctx (struct pk_encoding_ctx *ctx, ctx->nbits = nbits; ctx->encoding = PUBKEY_ENC_UNKNOWN; ctx->flags = 0; - ctx->hash_algo = GCRY_MD_SHA1; + if (fips_mode ()) + { + ctx->hash_algo = GCRY_MD_SHA256; + } + else + { + ctx->hash_algo = GCRY_MD_SHA1; + } ctx->label = NULL; ctx->labellen = 0; ctx->saltlen = 20; -- cgit v1.2.1