diff options
author | Werner Koch <wk@gnupg.org> | 1997-11-24 23:24:04 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1997-11-24 23:24:04 +0100 |
commit | 46900fbd437a134bd16e5030182fb3a219cd370e (patch) | |
tree | f13063a7c4896b189c7a3d09791d5464241174c7 /cipher/primegen.c | |
parent | IDEA removed, signing works (diff) | |
download | gnupg2-46900fbd437a134bd16e5030182fb3a219cd370e.tar.xz gnupg2-46900fbd437a134bd16e5030182fb3a219cd370e.zip |
ElGamal funktioniert und ist default
Diffstat (limited to 'cipher/primegen.c')
-rw-r--r-- | cipher/primegen.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cipher/primegen.c b/cipher/primegen.c index 07d83d831..0173b3d0b 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -29,13 +29,26 @@ static int no_of_small_prime_numbers; static int rabin_miller( MPI n ); +static MPI gen_prime( unsigned nbits, int mode ); /**************** * Generate a prime number (stored in secure memory) */ MPI -generate_random_prime( unsigned nbits ) +generate_secret_prime( unsigned nbits ) +{ + return gen_prime( nbits, 1 ); +} + +MPI +generate_public_prime( unsigned nbits ) +{ + return gen_prime( nbits, 0 ); +} + +static MPI +gen_prime( unsigned nbits, int secret ) { unsigned nlimbs; @@ -61,7 +74,7 @@ generate_random_prime( unsigned nbits ) val_3 = mpi_alloc( nlimbs ); mpi_set_ui(val_3, 3); result = mpi_alloc( nlimbs ); - prime = mpi_alloc_secure( nlimbs ); + prime = secret? mpi_alloc_secure( nlimbs ): mpi_alloc( nlimbs ); count1 = count2 = 0; /* enter (endless) loop */ for(;;) { |