summaryrefslogtreecommitdiff
path: root/cipher/primegen.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-01-10 19:48:26 +0000
committerWerner Koch <wk@gnupg.org>2002-01-10 19:48:26 +0000
commit48ee588fd3c9c9dc0f3a04ea3ea2721e137c345d (patch)
tree479e37837740d74b2387c905cf3b433e96be634e /cipher/primegen.c
parent01cbc7529f6ced95c72ead856f3c703905586783 (diff)
downloadlibgcrypt-48ee588fd3c9c9dc0f3a04ea3ea2721e137c345d.tar.gz
* pubkey.c (gcry_pk_genkey): Do not release skey - it is static.
* primegen.c (gen_prime): Of course we should use set_bit and not set_highbit to set the second high bit.
Diffstat (limited to 'cipher/primegen.c')
-rw-r--r--cipher/primegen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/cipher/primegen.c b/cipher/primegen.c
index e131e33a..9376d30c 100644
--- a/cipher/primegen.c
+++ b/cipher/primegen.c
@@ -325,13 +325,13 @@ gen_prime( unsigned nbits, int secret, int randomlevel )
/* generate a random number */
gcry_mpi_randomize( prime, nbits, randomlevel );
- /* set high order bit to 1, set low order bit to 1. If we are
+ /* Set high order bit to 1, set low order bit to 0. If we are
generating a secret prime we are most probably doing that
for RSA, to make sure that the modulus does have the
requested keysize we set the 2 high order bits */
mpi_set_highbit (prime, nbits-1);
if (secret)
- mpi_set_highbit (prime, nbits-2);
+ mpi_set_bit (prime, nbits-2);
mpi_set_bit(prime, 0);
/* calculate all remainders */
@@ -360,7 +360,7 @@ gen_prime( unsigned nbits, int secret, int randomlevel )
if( !mpi_cmp_ui( result, 1 ) ) { /* not composite */
/* perform stronger tests */
if( is_prime(ptest, 5, &count2 ) ) {
- if( !mpi_test_bit( ptest, nbits-1 ) ) {
+ if( !mpi_test_bit( ptest, nbits-1-secret ) ) {
progress('\n');
log_debug("overflow in prime generation\n");
break; /* step loop, continue with a new prime */