diff options
Diffstat (limited to '')
-rw-r--r-- | cipher/ChangeLog | 5 | ||||
-rw-r--r-- | cipher/primegen.c | 18 |
2 files changed, 15 insertions, 8 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 082c2581c..9965eed4b 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,8 @@ +2005-03-07 Werner Koch <[email protected]> + + * primegen.c (is_prime): Free A2. Noted by [email protected]. + Fixes #423. + 2004-11-30 David Shaw <[email protected]> * md.c (string_to_digest_algo): Allow read/write SHA384 and diff --git a/cipher/primegen.c b/cipher/primegen.c index 22b9bc455..dda9012b5 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -462,15 +462,16 @@ is_prime( MPI n, int steps, int *count ) mpi_set_ui( x, 2 ); } else { - /*mpi_set_bytes( x, nbits-1, get_random_byte, 0 );*/ - { char *p = get_random_bits( nbits, 0, 0 ); - mpi_set_buffer( x, p, (nbits+7)/8, 0 ); - m_free(p); - } - /* make sure that the number is smaller than the prime - * and keep the randomness of the high bit */ + char *p; + + p = get_random_bits( nbits, 0, 0 ); + mpi_set_buffer( x, p, (nbits+7)/8, 0 ); + m_free(p); + + /* Make sure that the number is smaller than the prime + * and keep the randomness of the high bit. */ if( mpi_test_bit( x, nbits-2 ) ) { - mpi_set_highbit( x, nbits-2 ); /* clear all higher bits */ + mpi_set_highbit( x, nbits-2 ); /* Clear all higher bits */ } else { mpi_set_highbit( x, nbits-2 ); @@ -498,6 +499,7 @@ is_prime( MPI n, int steps, int *count ) mpi_free( z ); mpi_free( nminus1 ); mpi_free( q ); + mpi_free (a2); return rc; } |