1 /* LibTomMath, multiple-precision integer library -- Tom St Denis
3 * LibTomMath is library that provides for multiple-precision
4 * integer arithmetic as well as number theoretic functionality.
6 * The library is designed directly after the MPI library by
7 * Michael Fromberger but has been written from scratch with
8 * additional optimizations in place.
10 * The library is free for all purposes without any express
13 * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
17 /* finds the next prime after the number "a" using "t" trials
20 int mp_prime_next_prime(mp_int *a, int t)
24 if (mp_iseven(a) == 1) {
26 if ((err = mp_add_d(a, 1, a)) != MP_OKAY) {
30 /* force to next odd number */
31 if ((err = mp_add_d(a, 2, a)) != MP_OKAY) {
38 if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) {
46 /* add two, next candidate */
47 if ((err = mp_add_d(a, 2, a)) != MP_OKAY) {