215 lines
9.5 KiB
Diff
215 lines
9.5 KiB
Diff
diff -up libgcrypt-1.5.0/cipher/dsa.c.tests libgcrypt-1.5.0/cipher/dsa.c
|
|
--- libgcrypt-1.5.0/cipher/dsa.c.tests 2011-06-13 12:24:46.000000000 +0200
|
|
+++ libgcrypt-1.5.0/cipher/dsa.c 2011-07-20 16:44:51.000000000 +0200
|
|
@@ -479,22 +479,21 @@ generate_fips186 (DSA_secret_key *sk, un
|
|
initial_seed.seed = gcry_sexp_nth_data (initial_seed.sexp, 1,
|
|
&initial_seed.seedlen);
|
|
}
|
|
-
|
|
- /* Fixme: Enable 186-3 after it has been approved and after fixing
|
|
- the generation function. */
|
|
- /* if (use_fips186_2) */
|
|
- (void)use_fips186_2;
|
|
- ec = _gcry_generate_fips186_2_prime (nbits, qbits,
|
|
- initial_seed.seed,
|
|
+
|
|
+ if (use_fips186_2)
|
|
+ ec = _gcry_generate_fips186_2_prime (nbits, qbits,
|
|
+ initial_seed.seed,
|
|
initial_seed.seedlen,
|
|
&prime_q, &prime_p,
|
|
r_counter,
|
|
r_seed, r_seedlen);
|
|
- /* else */
|
|
- /* ec = _gcry_generate_fips186_3_prime (nbits, qbits, NULL, 0, */
|
|
- /* &prime_q, &prime_p, */
|
|
- /* r_counter, */
|
|
- /* r_seed, r_seedlen, NULL); */
|
|
+ else
|
|
+ ec = _gcry_generate_fips186_3_prime (nbits, qbits,
|
|
+ initial_seed.seed,
|
|
+ initial_seed.seedlen,
|
|
+ &prime_q, &prime_p,
|
|
+ r_counter,
|
|
+ r_seed, r_seedlen, NULL);
|
|
gcry_sexp_release (initial_seed.sexp);
|
|
if (ec)
|
|
goto leave;
|
|
diff -up libgcrypt-1.5.0/cipher/primegen.c.tests libgcrypt-1.5.0/cipher/primegen.c
|
|
--- libgcrypt-1.5.0/cipher/primegen.c.tests 2011-03-28 14:19:52.000000000 +0200
|
|
+++ libgcrypt-1.5.0/cipher/primegen.c 2011-07-21 14:36:03.000000000 +0200
|
|
@@ -1647,7 +1647,7 @@ _gcry_generate_fips186_3_prime (unsigned
|
|
gpg_err_code_t ec;
|
|
unsigned char seed_help_buffer[256/8]; /* Used to hold a generated SEED. */
|
|
unsigned char *seed_plus; /* Malloced buffer to hold SEED+x. */
|
|
- unsigned char digest[256/8]; /* Helper buffer for SHA-1 digest. */
|
|
+ unsigned char digest[256/8]; /* Helper buffer for SHA-x digest. */
|
|
gcry_mpi_t val_2 = NULL; /* Helper for the prime test. */
|
|
gcry_mpi_t tmpval = NULL; /* Helper variable. */
|
|
int hashalgo; /* The id of the Approved Hash Function. */
|
|
@@ -1737,7 +1737,7 @@ _gcry_generate_fips186_3_prime (unsigned
|
|
}
|
|
gcry_mpi_release (prime_q); prime_q = NULL;
|
|
ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG,
|
|
- value_u, sizeof value_u, NULL));
|
|
+ value_u, qbits/8, NULL));
|
|
if (ec)
|
|
goto leave;
|
|
mpi_set_highbit (prime_q, qbits-1 );
|
|
@@ -1782,11 +1782,11 @@ _gcry_generate_fips186_3_prime (unsigned
|
|
if (seed_plus[i])
|
|
break;
|
|
}
|
|
- gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen);
|
|
+ gcry_md_hash_buffer (hashalgo, digest, seed_plus, seedlen);
|
|
|
|
gcry_mpi_release (tmpval); tmpval = NULL;
|
|
ec = gpg_err_code (gcry_mpi_scan (&tmpval, GCRYMPI_FMT_USG,
|
|
- digest, sizeof digest, NULL));
|
|
+ digest, qbits/8, NULL));
|
|
if (ec)
|
|
goto leave;
|
|
if (value_j == value_n)
|
|
@@ -1822,11 +1822,11 @@ _gcry_generate_fips186_3_prime (unsigned
|
|
}
|
|
|
|
/* Step 12: Save p, q, counter and seed. */
|
|
- log_debug ("fips186-3 pbits p=%u q=%u counter=%d\n",
|
|
+/* log_debug ("fips186-3 pbits p=%u q=%u counter=%d\n",
|
|
mpi_get_nbits (prime_p), mpi_get_nbits (prime_q), counter);
|
|
log_printhex("fips186-3 seed:", seed, seedlen);
|
|
log_mpidump ("fips186-3 prime p", prime_p);
|
|
- log_mpidump ("fips186-3 prime q", prime_q);
|
|
+ log_mpidump ("fips186-3 prime q", prime_q); */
|
|
if (r_q)
|
|
{
|
|
*r_q = prime_q;
|
|
diff -up libgcrypt-1.5.0/cipher/rsa.c.tests libgcrypt-1.5.0/cipher/rsa.c
|
|
--- libgcrypt-1.5.0/cipher/rsa.c.tests 2011-06-10 10:53:41.000000000 +0200
|
|
+++ libgcrypt-1.5.0/cipher/rsa.c 2011-07-21 14:36:59.000000000 +0200
|
|
@@ -388,7 +388,7 @@ generate_x931 (RSA_secret_key *sk, unsig
|
|
|
|
*swapped = 0;
|
|
|
|
- if (e_value == 1) /* Alias for a secure value. */
|
|
+ if (e_value == 1 || e_value == 0) /* Alias for a secure value. */
|
|
e_value = 65537;
|
|
|
|
/* Point 1 of section 4.1: k = 1024 + 256s with S >= 0 */
|
|
diff -up libgcrypt-1.5.0/random/random-fips.c.tests libgcrypt-1.5.0/random/random-fips.c
|
|
--- libgcrypt-1.5.0/random/random-fips.c.tests 2011-07-20 16:40:59.000000000 +0200
|
|
+++ libgcrypt-1.5.0/random/random-fips.c 2011-07-20 16:40:59.000000000 +0200
|
|
@@ -691,6 +691,7 @@ get_random (void *buffer, size_t length,
|
|
|
|
check_guards (rng_ctx);
|
|
|
|
+ reinitialize:
|
|
/* Initialize the cipher handle and thus setup the key if needed. */
|
|
if (!rng_ctx->cipher_hd)
|
|
{
|
|
@@ -710,13 +711,11 @@ get_random (void *buffer, size_t length,
|
|
if (rng_ctx->key_init_pid != getpid ()
|
|
|| rng_ctx->seed_init_pid != getpid ())
|
|
{
|
|
- /* We are in a child of us. Because we have no way yet to do
|
|
- proper re-initialization (including self-checks etc), the
|
|
- only chance we have is to bail out. Obviusly a fork/exec
|
|
- won't harm because the exec overwrites the old image. */
|
|
- fips_signal_error ("fork without proper re-initialization "
|
|
- "detected in RNG");
|
|
- goto bailout;
|
|
+ /* Just reinitialize the key & seed. */
|
|
+ gcry_cipher_close(rng_ctx->cipher_hd);
|
|
+ rng_ctx->cipher_hd = NULL;
|
|
+ rng_ctx->is_seeded = 0;
|
|
+ goto reinitialize;
|
|
}
|
|
|
|
if (x931_aes_driver (buffer, length, rng_ctx))
|
|
diff -up libgcrypt-1.5.0/tests/ac.c.tests libgcrypt-1.5.0/tests/ac.c
|
|
--- libgcrypt-1.5.0/tests/ac.c.tests 2011-02-04 20:18:20.000000000 +0100
|
|
+++ libgcrypt-1.5.0/tests/ac.c 2011-07-20 16:40:59.000000000 +0200
|
|
@@ -150,6 +150,9 @@ main (int argc, char **argv)
|
|
if (!gcry_check_version (GCRYPT_VERSION))
|
|
die ("version mismatch\n");
|
|
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
|
+ if (gcry_fips_mode_active())
|
|
+ /* ac not functional in the fips mode, skip it */
|
|
+ return 77;
|
|
if (debug)
|
|
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
|
|
/* No valuable keys are create, so we can speed up our RNG. */
|
|
diff -up libgcrypt-1.5.0/tests/ac-data.c.tests libgcrypt-1.5.0/tests/ac-data.c
|
|
--- libgcrypt-1.5.0/tests/ac-data.c.tests 2011-02-04 20:18:20.000000000 +0100
|
|
+++ libgcrypt-1.5.0/tests/ac-data.c 2011-07-20 16:40:59.000000000 +0200
|
|
@@ -198,6 +198,9 @@ main (int argc, char **argv)
|
|
if (!gcry_check_version (GCRYPT_VERSION))
|
|
die ("version mismatch\n");
|
|
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
|
+ if (gcry_fips_mode_active())
|
|
+ /* ac not functional in the fips mode, skip it */
|
|
+ return 77;
|
|
if (debug)
|
|
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
|
|
|
|
diff -up libgcrypt-1.5.0/tests/ac-schemes.c.tests libgcrypt-1.5.0/tests/ac-schemes.c
|
|
--- libgcrypt-1.5.0/tests/ac-schemes.c.tests 2011-02-04 20:18:20.000000000 +0100
|
|
+++ libgcrypt-1.5.0/tests/ac-schemes.c 2011-07-20 16:40:59.000000000 +0200
|
|
@@ -338,6 +338,9 @@ main (int argc, char **argv)
|
|
if (! gcry_check_version (GCRYPT_VERSION))
|
|
die ("version mismatch\n");
|
|
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
|
+ if (gcry_fips_mode_active())
|
|
+ /* ac not functional in the fips mode, skip it */
|
|
+ return 77;
|
|
if (debug)
|
|
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
|
|
|
|
diff -up libgcrypt-1.5.0/tests/keygen.c.tests libgcrypt-1.5.0/tests/keygen.c
|
|
--- libgcrypt-1.5.0/tests/keygen.c.tests 2011-02-04 20:18:20.000000000 +0100
|
|
+++ libgcrypt-1.5.0/tests/keygen.c 2011-07-21 14:39:03.000000000 +0200
|
|
@@ -148,12 +148,12 @@ check_rsa_keys (void)
|
|
}
|
|
|
|
if (verbose)
|
|
- fprintf (stderr, "creating 1536 bit DSA key\n");
|
|
+ fprintf (stderr, "creating 2048 bit DSA key\n");
|
|
rc = gcry_sexp_new (&keyparm,
|
|
"(genkey\n"
|
|
" (dsa\n"
|
|
- " (nbits 4:1536)\n"
|
|
- " (qbits 3:224)\n"
|
|
+ " (nbits 4:2048)\n"
|
|
+ " (qbits 3:256)\n"
|
|
" ))", 0, 1);
|
|
if (rc)
|
|
die ("error creating S-expression: %s\n", gpg_strerror (rc));
|
|
@@ -190,11 +190,11 @@ check_rsa_keys (void)
|
|
|
|
|
|
if (verbose)
|
|
- fprintf (stderr, "creating 512 bit RSA key with e=257\n");
|
|
+ fprintf (stderr, "creating 1024 bit RSA key with e=257\n");
|
|
rc = gcry_sexp_new (&keyparm,
|
|
"(genkey\n"
|
|
" (rsa\n"
|
|
- " (nbits 3:512)\n"
|
|
+ " (nbits 4:1024)\n"
|
|
" (rsa-use-e 3:257)\n"
|
|
" ))", 0, 1);
|
|
if (rc)
|
|
@@ -208,11 +208,11 @@ check_rsa_keys (void)
|
|
gcry_sexp_release (key);
|
|
|
|
if (verbose)
|
|
- fprintf (stderr, "creating 512 bit RSA key with default e\n");
|
|
+ fprintf (stderr, "creating 1024 bit RSA key with default secure e\n");
|
|
rc = gcry_sexp_new (&keyparm,
|
|
"(genkey\n"
|
|
" (rsa\n"
|
|
- " (nbits 3:512)\n"
|
|
+ " (nbits 4:1024)\n"
|
|
" (rsa-use-e 1:0)\n"
|
|
" ))", 0, 1);
|
|
if (rc)
|