summaryrefslogtreecommitdiffstats
path: root/cipher
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-04-02 12:30:03 +0200
committerWerner Koch <wk@gnupg.org>1998-04-02 12:30:03 +0200
commit303b1084d51dd1f9d3e614497f180a66744f5185 (patch)
tree3e482ba03967ff3f324184e19ecc91016ce4b939 /cipher
parentsome cleanups (diff)
downloadgnupg2-303b1084d51dd1f9d3e614497f180a66744f5185.tar.xz
gnupg2-303b1084d51dd1f9d3e614497f180a66744f5185.zip
release 0.2.14
Diffstat (limited to 'cipher')
-rw-r--r--cipher/ChangeLog4
-rw-r--r--cipher/Makefile.am2
-rw-r--r--cipher/Makefile.in2
-rw-r--r--cipher/elgamal.c24
4 files changed, 24 insertions, 8 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index fbd7bed8c..3d2bf7cad 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,7 @@
+Wed Apr 1 16:38:27 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamla.c (elg_generate): Faster generation of x in some cases.
+
Thu Mar 19 13:54:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* blowfish.c (blowfish_decode_cfb): changed XOR operation
diff --git a/cipher/Makefile.am b/cipher/Makefile.am
index c0b3c8a5b..926d084bd 100644
--- a/cipher/Makefile.am
+++ b/cipher/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-INCLUDES = -I$(top_srcdir)/include
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl
EXTRA_DIST = @CIPHER_EXTRA_DIST@
noinst_LIBRARIES = libcipher.a
diff --git a/cipher/Makefile.in b/cipher/Makefile.in
index 579d4a355..981fd9957 100644
--- a/cipher/Makefile.in
+++ b/cipher/Makefile.in
@@ -92,7 +92,7 @@ VERSION = @VERSION@
ZLIBS = @ZLIBS@
l = @l@
-INCLUDES = -I$(top_srcdir)/include
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl
EXTRA_DIST = @CIPHER_EXTRA_DIST@
noinst_LIBRARIES = libcipher.a
diff --git a/cipher/elgamal.c b/cipher/elgamal.c
index b211d7f6c..c13181d90 100644
--- a/cipher/elgamal.c
+++ b/cipher/elgamal.c
@@ -126,6 +126,7 @@ elg_generate( ELG_public_key *pk, ELG_secret_key *sk,
MPI y;
MPI temp;
unsigned qbits;
+ byte *rndbuf;
p_min1 = mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1)/BITS_PER_MPI_LIMB );
temp = mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1)/BITS_PER_MPI_LIMB );
@@ -145,22 +146,33 @@ elg_generate( ELG_public_key *pk, ELG_secret_key *sk,
/* select a random number which has these properties:
* 0 < x < p-1
* This must be a very good random number because this is the
- * secret part. The prime is public and may be shared anyware,
- * so a random generator level of 1 has been used for the prime
+ * secret part. The prime is public and may be shared anyway,
+ * so a random generator level of 1 is used for the prime.
*/
x = mpi_alloc_secure( nbits/BITS_PER_MPI_LIMB );
if( DBG_CIPHER )
log_debug("choosing a random x ");
+ rndbuf = NULL;
do {
- byte *rndbuf;
if( DBG_CIPHER )
fputc('.', stderr);
- rndbuf = get_random_bits( nbits, 2, 1 );
+ if( rndbuf ) { /* change only some of the higher bits */
+ if( nbits < 16 ) {/* should never happen ... */
+ m_free(rndbuf);
+ rndbuf = get_random_bits( nbits, 2, 1 );
+ }
+ else {
+ char *r = get_random_bits( 16, 2, 1 );
+ memcpy(rndbuf, r, 16 );
+ m_free(r);
+ }
+ }
+ else
+ 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 ) );
+ m_free(rndbuf);
y = mpi_alloc(nbits/BITS_PER_MPI_LIMB);
mpi_powm( y, g, x, p );