1 /* $NetBSD: 2kprime.c,v 1.1.1.2 2014/04/24 12:45:39 pettai Exp $ */
3 /* Makes safe primes of a 2k nature */
7 int sizes
[] = {256, 512, 768, 1024, 1536, 2048, 3072, 4096};
18 mp_init_multi(&q
, &p
, NULL
);
20 out
= fopen("2kprime.1", "w");
21 for (x
= 0; x
< (int)(sizeof(sizes
) / sizeof(sizes
[0])); x
++) {
23 mp_2expt(&q
, sizes
[x
]);
33 printf("No primes of size %d found\n", sizes
[x
]);
37 if (clock() - t1
> CLOCKS_PER_SEC
) {
38 printf("."); fflush(stdout
);
39 // sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC);
44 mp_prime_is_prime(&q
, 1, &y
);
52 mp_prime_is_prime(&p
, 3, &y
);
58 mp_prime_is_prime(&q
, 3, &y
);
71 mp_toradix(&q
, buf
, 10);
72 printf("\n\n%d-bits (k = %lu) = %s\n", sizes
[x
], z
, buf
);
73 fprintf(out
, "%d-bits (k = %lu) = %s\n", sizes
[x
], z
, buf
); fflush(out
);
84 /* Source: /cvs/libtom/libtommath/etc/2kprime.c,v */
86 /* Date: 2005/05/05 14:38:47 */