1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
6
* The library is free for all purposes without any express
9
* Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org
20
static int rand_prime_helper(unsigned char *dst, int len, void *dat)
22
return (int)prng_descriptor[((struct rng_data *)dat)->wprng].read(dst, len, ((struct rng_data *)dat)->prng);
25
int rand_prime(mp_int *N, long len, prng_state *prng, int wprng)
32
/* allow sizes between 2 and 256 bytes for a prime size */
33
if (len < 16 || len > 4096) {
34
return CRYPT_INVALID_PRIME_SIZE;
37
/* valid PRNG? Better be! */
38
if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
42
/* setup our callback data, then world domination! */
54
/* New prime generation makes the code even more cryptoish-insane. Do you know what this means!!!
55
-- Gir: Yeah, oh wait, er, no.
57
return mpi_to_ltc_error(mp_prime_random_ex(N, mp_prime_rabin_miller_trials(len), len, type, rand_prime_helper, &rng));