aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/elgamal.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1998-03-19 15:27:29 +0000
committerWerner Koch <[email protected]>1998-03-19 15:27:29 +0000
commit6b91e7762c65097a103b2b17db304a4d85b3573d (patch)
tree4303dbf887db8130c58e1025cac3c8fe291c6ceb /cipher/elgamal.c
parentNEw test keyrings (diff)
downloadgnupg-6b91e7762c65097a103b2b17db304a4d85b3573d.tar.gz
gnupg-6b91e7762c65097a103b2b17db304a4d85b3573d.zip
some cleanups
Diffstat (limited to 'cipher/elgamal.c')
-rw-r--r--cipher/elgamal.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/cipher/elgamal.c b/cipher/elgamal.c
index 2141db0cc..b211d7f6c 100644
--- a/cipher/elgamal.c
+++ b/cipher/elgamal.c
@@ -152,9 +152,14 @@ elg_generate( ELG_public_key *pk, ELG_secret_key *sk,
if( DBG_CIPHER )
log_debug("choosing a random x ");
do {
+ byte *rndbuf;
if( DBG_CIPHER )
fputc('.', stderr);
- mpi_set_bytes( x, nbits, get_random_byte, 2 );
+ rndbuf = get_random_bits( nbits, 2, 1 );
+ mpi_set_buffer( x, rndbuf, (nbits+7)/8, 0 );
+ m_free(rndbuf);
+ mpi_clear_highbit( x, nbits+1 );
+ log_mpidump(" x: ", x );
} while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, p_min1 )<0 ) );
y = mpi_alloc(nbits/BITS_PER_MPI_LIMB);