diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2017-06-05 23:20:36 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2017-06-05 23:20:36 (GMT) |
commit | f8223fa81718da26562fff851b4a56d18b58a62a (patch) | |
tree | 2c47bdd025eab065e5f559ade49795a3acaf938e /libtommath/etc/drprime.c | |
parent | e9d31a334b4cbd18716b3c1eacf7f516cbc7286d (diff) | |
parent | 0b178367ba3b9a10d44f89025c89292a4ea49b20 (diff) | |
download | tcl-dkf_expose_ptrgetvar.zip tcl-dkf_expose_ptrgetvar.tar.gz tcl-dkf_expose_ptrgetvar.tar.bz2 |
merge trunkdkf_expose_ptrgetvar
Diffstat (limited to 'libtommath/etc/drprime.c')
-rw-r--r-- | libtommath/etc/drprime.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/libtommath/etc/drprime.c b/libtommath/etc/drprime.c deleted file mode 100644 index 0d0fdb9..0000000 --- a/libtommath/etc/drprime.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Makes safe primes of a DR nature */ -#include <tommath.h> - -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 }; -int main(void) -{ - int res, x, y; - char buf[4096]; - FILE *out; - mp_int a, b; - - mp_init(&a); - mp_init(&b); - - out = fopen("drprimes.txt", "w"); - for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) { - top: - printf("Seeking a %d-bit safe prime\n", sizes[x] * DIGIT_BIT); - mp_grow(&a, sizes[x]); - mp_zero(&a); - for (y = 1; y < sizes[x]; y++) { - a.dp[y] = MP_MASK; - } - - /* make a DR modulus */ - a.dp[0] = -1; - a.used = sizes[x]; - - /* now loop */ - res = 0; - for (;;) { - a.dp[0] += 4; - if (a.dp[0] >= MP_MASK) break; - mp_prime_is_prime(&a, 1, &res); - if (res == 0) continue; - printf("."); fflush(stdout); - mp_sub_d(&a, 1, &b); - mp_div_2(&b, &b); - mp_prime_is_prime(&b, 3, &res); - if (res == 0) continue; - mp_prime_is_prime(&a, 3, &res); - if (res == 1) break; - } - - if (res != 1) { - printf("Error not DR modulus\n"); sizes[x] += 1; goto top; - } else { - mp_toradix(&a, buf, 10); - printf("\n\np == %s\n\n", buf); - fprintf(out, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a), buf); fflush(out); - } - } - fclose(out); - - mp_clear(&a); - mp_clear(&b); - - return 0; -} |