From c91e30fda49244ee89edc74acd1a9897f35e6539 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 7 Mar 2005 13:59:59 +0000 Subject: * primegen.c (is_prime): Free A2. Noted by pmike2001@mail.ru. Fixes #423. * DETAILS: Document new status codes. * cardglue.c (agent_scd_pkdecrypt, agent_scd_pksign) (agent_scd_genkey, agent_scd_setattr, agent_scd_change_pin) (agent_scd_checkpin, agent_openpgp_storekey): Make sure to send a SC_OP_FAILURE after card operations which might change data. * card-util.c (change_pin): Send a SC_OP_SUCCESS after a PIN has been changed. (change_name): Removed a debug output. * status.h, status.c: New codes BAD_PASSPHRASE_PIN, SC_OP_FAILURE and SC_OP_SUCCESS. * de.po: Updated. Translation is still in the works, though. --- cipher/primegen.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'cipher/primegen.c') 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; } -- cgit v1.2.3