When searching for a prime, the number of Miller-Rabin tests to be

performed will be done in accordance with a table published in the
Handbook of Applied Cryptography.  See Bug 65151.  Also, changes to
test program for this function.
This commit is contained in:
nelsonb%netscape.com 2001-01-18 01:39:17 +00:00
parent 8bb00b9309
commit fe9fa27179
3 changed files with 29 additions and 11 deletions

View File

@ -36,7 +36,7 @@
## GPL.
##
##
## $Id: Makefile.win,v 1.1 2000/09/02 05:38:51 nelsonb%netscape.com Exp $
## $Id: Makefile.win,v 1.2 2001/01/18 01:39:13 nelsonb%netscape.com Exp $
##
## Define CC to be the C compiler you wish to use. The GNU cc
@ -181,6 +181,8 @@ mpi.lib: $(LIBOBJS)
ar -cvr mpi.lib $(LIBOBJS)
$(RANLIB) mpi.lib
lib libs: mpi.lib
#---------------------------------------
MPTESTOBJS = mptest1.obj mptest2.obj mptest3.obj mptest3a.obj mptest4.obj \
@ -252,8 +254,8 @@ doc:
(cd doc; ./build)
clean:
rm -f *.obj *.lib *.pdb
rm -f utils/*.obj
rm -f *.obj *.lib *.pdb *.ilk
cd utils; rm -f *.obj *.lib *.pdb *.ilk
distclean: clean
rm -f mptest? mpi-test metime mulsqr karatsuba

View File

@ -443,14 +443,31 @@ mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong,
MP_DIGITS(&q) = 0;
MP_CHECKOK( mp_init(&trial) );
MP_CHECKOK( mp_init(&q) );
if (nBits >= 1024) {
/* values taken from table 4.4, HandBook of Applied Cryptography */
if (nBits >= 1300) {
num_tests = 2;
} else if (nBits >= 850) {
num_tests = 3;
} else if (nBits >= 650) {
num_tests = 4;
} else if (nBits >= 550) {
num_tests = 5;
} else if (nBits >= 512) {
} else if (nBits >= 450) {
num_tests = 6;
} else if (nBits >= 400) {
num_tests = 7;
} else if (nBits >= 384) {
} else if (nBits >= 350) {
num_tests = 8;
} else if (nBits >= 300) {
num_tests = 9;
} else if (nBits >= 256) {
num_tests = 13;
} else if (nBits >= 250) {
num_tests = 12;
} else if (nBits >= 200) {
num_tests = 15;
} else if (nBits >= 150) {
num_tests = 18;
} else if (nBits >= 100) {
num_tests = 27;
} else
num_tests = 50;

View File

@ -42,7 +42,7 @@
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the GPL.
*
* $Id: primegen.c,v 1.4 2000/07/26 05:41:59 nelsonb%netscape.com Exp $
* $Id: primegen.c,v 1.5 2001/01/18 01:39:17 nelsonb%netscape.com Exp $
*/
#include <stdio.h>
@ -172,8 +172,7 @@ int main(int argc, char *argv[])
break;
}
FPUTC('\n', stderr);
printf("After %d tests, the following value is still probably prime:\n",
NUM_TESTS);
puts("The following value is probably prime:");
outlen = mp_radix_size(&testval, 10);
out = calloc(outlen, sizeof(unsigned char));
mp_toradix(&testval, (char *)out, 10);