1 /* Makes safe primes of a DR nature */
4 int sizes
[] = { 1+256/DIGIT_BIT
, 1+512/DIGIT_BIT
, 1+768/DIGIT_BIT
, 1+1024/DIGIT_BIT
, 1+2048/DIGIT_BIT
, 1+4096/DIGIT_BIT
};
15 out
= fopen("drprimes.txt", "w");
16 for (x
= 0; x
< (int)(sizeof(sizes
)/sizeof(sizes
[0])); x
++) {
18 printf("Seeking a %d-bit safe prime\n", sizes
[x
] * DIGIT_BIT
);
19 mp_grow(&a
, sizes
[x
]);
21 for (y
= 1; y
< sizes
[x
]; y
++) {
25 /* make a DR modulus */
33 if (a
.dp
[0] >= MP_MASK
) break;
34 mp_prime_is_prime(&a
, 1, &res
);
35 if (res
== 0) continue;
36 printf("."); fflush(stdout
);
39 mp_prime_is_prime(&b
, 3, &res
);
40 if (res
== 0) continue;
41 mp_prime_is_prime(&a
, 3, &res
);
46 printf("Error not DR modulus\n"); sizes
[x
] += 1; goto top
;
48 mp_toradix(&a
, buf
, 10);
49 printf("\n\np == %s\n\n", buf
);
50 fprintf(out
, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a
), buf
); fflush(out
);
62 /* $Source: /cvs/libtom/libtommath/etc/drprime.c,v $ */
63 /* $Revision: 1.2 $ */
64 /* $Date: 2005/05/05 14:38:47 $ */