random-prime-test.c 459 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "testutils.h"

#include "knuth-lfib.h"

int
test_main(void)
{
  struct knuth_lfib_ctx lfib;
  mpz_t p;
  unsigned bits;

  knuth_lfib_init(&lfib, 17);

  mpz_init(p);
  for (bits = 6; bits < 1000; bits = bits + 1 + bits/20)
    {
      if (verbose)
	fprintf(stderr, "bits = %d\n", bits);
      
      nettle_random_prime(p, bits,
			  &lfib, (nettle_random_func *) knuth_lfib_random );
      ASSERT (mpz_probab_prime_p(p, 25));
    }

  SUCCESS();
}