--- pgp/src/genprime.c 2018/04/24 16:39:41 1.1.1.3 +++ pgp/src/genprime.c 2018/04/24 16:40:31 1.1.1.4 @@ -2,8 +2,9 @@ used by public-key key generation routines. First version 17 Mar 87 Last revised 2 Jun 91 by PRZ + 24 Apr 93 by CP - (c) Copyright 1987 by Philip Zimmermann. All rights reserved. + (c) Copyright 1987,1993 by Philip Zimmermann. All rights reserved. The author assumes no liability for damages resulting from the use of this software, even if the damage results from defects in this software. No warranty is expressed or implied. @@ -45,8 +46,8 @@ #include "mpilib.h" #include "genprime.h" -#ifdef MSDOS -#include "conio.h" +#if defined(MSDOS) && !defined(__GO32__) +#include #endif /* if PSEUDORANDOM is defined, it disables truly random numbers in random.h */ @@ -62,6 +63,14 @@ This justifies disabling the lengthy search for strong primes. */ +#define BLUM +/* If BLUM is defined, this looks for prines congruent to 3 modulo 4. + The product of two of these is a Blum integer. You can uniquely define + a square root Cmodulo a Blum integer, which leads to some extra + possibilities for encryption algorithms. This shrinks the key space by + 2 bits, which is not considered significant. +*/ + #ifdef STRONGPRIMES static boolean primetest(unitptr p); @@ -452,7 +461,11 @@ static int nextprime(unitptr p) return(0); /* normal completion status */ } +#ifndef BLUM lsunit(p) |= 1; /* set candidate's lsb - make it odd */ +#else + lsunit(p) |= 3; /* Make candidate ==3 mod 4 */ +#endif /* Adjust the global_precision downward to the optimum size for p...*/ oldprecision = global_precision; /* save global_precision */ @@ -477,7 +490,12 @@ static int nextprime(unitptr p) /* slowtest will not be called unless fastsieve is true */ /* range is how far to search before giving up. */ +#ifndef BLUM range = 4 * units2bits(global_precision); +#else + /* Twice as many because step size is twice as large, */ + range = 8 * units2bits(global_precision); +#endif suspects = 0; /* number of suspected primes and slowtest trials */ while (TRUE) { @@ -491,7 +509,12 @@ static int nextprime(unitptr p) if (slowtest(p)) break; /* found a prime */ } +#ifndef BLUM pdelta += 2; /* try next odd number */ +#else + pdelta += 4; + mp_inc(p); mp_inc(p); +#endif mp_inc(p); mp_inc(p); if (pdelta > range) /* searched too many candidates? */