1 /* $NetBSD: drprime.c,v 1.1.1.2 2014/04/24 12:45:39 pettai Exp $ */
3 /* Makes safe primes of a DR nature */
6 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
};
17 out
= fopen("drprimes.txt", "w");
18 for (x
= 0; x
< (int)(sizeof(sizes
)/sizeof(sizes
[0])); x
++) {
20 printf("Seeking a %d-bit safe prime\n", sizes
[x
] * DIGIT_BIT
);
21 mp_grow(&a
, sizes
[x
]);
23 for (y
= 1; y
< sizes
[x
]; y
++) {
27 /* make a DR modulus */
35 if (a
.dp
[0] >= MP_MASK
) break;
36 mp_prime_is_prime(&a
, 1, &res
);
37 if (res
== 0) continue;
38 printf("."); fflush(stdout
);
41 mp_prime_is_prime(&b
, 3, &res
);
42 if (res
== 0) continue;
43 mp_prime_is_prime(&a
, 3, &res
);
48 printf("Error not DR modulus\n"); sizes
[x
] += 1; goto top
;
50 mp_toradix(&a
, buf
, 10);
51 printf("\n\np == %s\n\n", buf
);
52 fprintf(out
, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a
), buf
); fflush(out
);
64 /* Source: /cvs/libtom/libtommath/etc/drprime.c,v */
66 /* Date: 2005/05/05 14:38:47 */