diff options
author | Matt Johnston <matt@ucc.asn.au> | 2018-02-09 21:44:05 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2018-02-09 21:44:05 +0800 |
commit | 4f2eb1914bdac3ed3ee504ad86061281dbe0d074 (patch) | |
tree | 078293375c3f3ee2d485cf9559a08d65d460786a /libtomcrypt/src/math/rand_prime.c | |
parent | d72f50ff3284e15124a0f233c26339229fe305ac (diff) |
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Diffstat (limited to 'libtomcrypt/src/math/rand_prime.c')
-rw-r--r-- | libtomcrypt/src/math/rand_prime.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libtomcrypt/src/math/rand_prime.c b/libtomcrypt/src/math/rand_prime.c index f228429..4dd5764 100644 --- a/libtomcrypt/src/math/rand_prime.c +++ b/libtomcrypt/src/math/rand_prime.c @@ -5,15 +5,15 @@ * * The library is free for all purposes without any express * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" +#if defined(LTC_MRSA) || (!defined(LTC_NO_MATH) && !defined(LTC_NO_PRNGS)) + /** @file rand_prime.c Generate a random prime, Tom St Denis -*/ +*/ #define USE_BBS 1 @@ -33,13 +33,13 @@ int rand_prime(void *N, long len, prng_state *prng, int wprng) } /* allow sizes between 2 and 512 bytes for a prime size */ - if (len < 2 || len > 512) { + if (len < 2 || len > 512) { return CRYPT_INVALID_PRIME_SIZE; } - + /* valid PRNG? Better be! */ if ((err = prng_is_valid(wprng)) != CRYPT_OK) { - return err; + return err; } /* allocate buffer to work with */ @@ -58,7 +58,7 @@ int rand_prime(void *N, long len, prng_state *prng, int wprng) /* munge bits */ buf[0] |= 0x80 | 0x40; buf[len-1] |= 0x01 | ((type & USE_BBS) ? 0x02 : 0x00); - + /* load value */ if ((err = mp_read_unsigned_bin(N, buf, len)) != CRYPT_OK) { XFREE(buf); @@ -66,7 +66,7 @@ int rand_prime(void *N, long len, prng_state *prng, int wprng) } /* test */ - if ((err = mp_prime_is_prime(N, 8, &res)) != CRYPT_OK) { + if ((err = mp_prime_is_prime(N, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) { XFREE(buf); return err; } @@ -79,9 +79,10 @@ int rand_prime(void *N, long len, prng_state *prng, int wprng) XFREE(buf); return CRYPT_OK; } - + +#endif /* LTC_NO_MATH */ -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ |