C: How to get a 4096-bit prime?

How to get a random, really big (fe 4096 bit) prime in C? Does anyone know a good library for this?

+4
source share
2 answers

Best of all is libgmp .

It has a function that will scan the next simple number (using Miller-Rabin ), starting at some starting number.

void mpz_nextprime ( mpz_t rop, mpz_t op );

Set rop to the next prime greater than op.

This function uses a probabilistic algorithm to determine primes. For practical purposes, this is enough, the probability of a difficult passage will be extremely small.

You need this feature.

, , mpz_nextprime. - O(log(op)) ().

.

+5

, , (, Windows CryptGenRandom), , , .

, , - 1 (-/2). , . ( ), , .

, , , NIST, .

+1

All Articles