|
|
5bcc82 |
diff -up libgcrypt-1.8.4/cipher/dsa.c.fips-keygen libgcrypt-1.8.4/cipher/dsa.c
|
|
|
5bcc82 |
--- libgcrypt-1.8.4/cipher/dsa.c.fips-keygen 2017-11-23 19:16:58.000000000 +0100
|
|
|
5bcc82 |
+++ libgcrypt-1.8.4/cipher/dsa.c 2019-02-12 14:29:25.629513989 +0100
|
|
|
5bcc82 |
@@ -457,11 +457,22 @@ generate_fips186 (DSA_secret_key *sk, un
|
|
|
5bcc82 |
&prime_q, &prime_p,
|
|
|
5bcc82 |
r_counter,
|
|
|
5bcc82 |
r_seed, r_seedlen);
|
|
|
5bcc82 |
- else
|
|
|
5bcc82 |
- ec = _gcry_generate_fips186_3_prime (nbits, qbits, NULL, 0,
|
|
|
5bcc82 |
+ else if (!domain->p || !domain->q)
|
|
|
5bcc82 |
+ ec = _gcry_generate_fips186_3_prime (nbits, qbits,
|
|
|
5bcc82 |
+ initial_seed.seed,
|
|
|
5bcc82 |
+ initial_seed.seedlen,
|
|
|
5bcc82 |
&prime_q, &prime_p,
|
|
|
5bcc82 |
r_counter,
|
|
|
5bcc82 |
r_seed, r_seedlen, NULL);
|
|
|
5bcc82 |
+ else
|
|
|
5bcc82 |
+ {
|
|
|
5bcc82 |
+ /* Domain parameters p and q are given; use them. */
|
|
|
5bcc82 |
+ prime_p = mpi_copy (domain->p);
|
|
|
5bcc82 |
+ prime_q = mpi_copy (domain->q);
|
|
|
5bcc82 |
+ gcry_assert (mpi_get_nbits (prime_p) == nbits);
|
|
|
5bcc82 |
+ gcry_assert (mpi_get_nbits (prime_q) == qbits);
|
|
|
5bcc82 |
+ ec = 0;
|
|
|
5bcc82 |
+ }
|
|
|
5bcc82 |
sexp_release (initial_seed.sexp);
|
|
|
5bcc82 |
if (ec)
|
|
|
5bcc82 |
goto leave;
|
|
|
5bcc82 |
@@ -855,13 +866,12 @@ dsa_generate (const gcry_sexp_t genparms
|
|
|
5bcc82 |
sexp_release (l1);
|
|
|
5bcc82 |
sexp_release (domainsexp);
|
|
|
5bcc82 |
|
|
|
5bcc82 |
- /* Check that all domain parameters are available. */
|
|
|
5bcc82 |
- if (!domain.p || !domain.q || !domain.g)
|
|
|
5bcc82 |
+ /* Check that p and q domain parameters are available. */
|
|
|
5bcc82 |
+ if (!domain.p || !domain.q || (!domain.g && !(flags & PUBKEY_FLAG_USE_FIPS186)))
|
|
|
5bcc82 |
{
|
|
|
5bcc82 |
_gcry_mpi_release (domain.p);
|
|
|
5bcc82 |
_gcry_mpi_release (domain.q);
|
|
|
5bcc82 |
_gcry_mpi_release (domain.g);
|
|
|
5bcc82 |
- sexp_release (deriveparms);
|
|
|
5bcc82 |
return GPG_ERR_MISSING_VALUE;
|
|
|
5bcc82 |
}
|
|
|
5bcc82 |
|
|
|
5bcc82 |
diff -up libgcrypt-1.8.4/cipher/rsa.c.fips-keygen libgcrypt-1.8.4/cipher/rsa.c
|
|
|
5bcc82 |
--- libgcrypt-1.8.4/cipher/rsa.c.fips-keygen 2017-11-23 19:16:58.000000000 +0100
|
|
|
5bcc82 |
+++ libgcrypt-1.8.4/cipher/rsa.c 2019-02-12 14:29:25.630513971 +0100
|
|
|
5bcc82 |
@@ -389,7 +389,7 @@ generate_fips (RSA_secret_key *sk, unsig
|
|
|
5bcc82 |
|
|
|
5bcc82 |
if (nbits < 1024 || (nbits & 0x1FF))
|
|
|
5bcc82 |
return GPG_ERR_INV_VALUE;
|
|
|
5bcc82 |
- if (_gcry_enforced_fips_mode() && nbits != 2048 && nbits != 3072)
|
|
|
5bcc82 |
+ if (fips_mode() && nbits < 2048)
|
|
|
5bcc82 |
return GPG_ERR_INV_VALUE;
|
|
|
5bcc82 |
|
|
|
5bcc82 |
/* The random quality depends on the transient_key flag. */
|
|
|
5bcc82 |
@@ -696,7 +696,7 @@ generate_x931 (RSA_secret_key *sk, unsig
|
|
|
5bcc82 |
|
|
|
5bcc82 |
*swapped = 0;
|
|
|
5bcc82 |
|
|
|
5bcc82 |
- if (e_value == 1) /* Alias for a secure value. */
|
|
|
5bcc82 |
+ if (e_value == 1 || e_value == 0) /* Alias for a secure value. */
|
|
|
5bcc82 |
e_value = 65537;
|
|
|
5bcc82 |
|
|
|
5bcc82 |
/* Point 1 of section 4.1: k = 1024 + 256s with S >= 0 */
|