1 /* LibTomMath, multiple-precision integer library -- Tom St Denis
\r
3 * LibTomMath is library that provides for multiple-precision
\r
4 * integer arithmetic as well as number theoretic functionality.
\r
6 * The library is designed directly after the MPI library by
\r
7 * Michael Fromberger but has been written from scratch with
\r
8 * additional optimizations in place.
\r
10 * The library is free for all purposes without any express
\r
11 * guarantee it works.
\r
13 * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
\r
15 #include <tommath.h>
\r
17 /* pre-calculate the value required for Barrett reduction
\r
18 * For a given modulus "b" it calulates the value required in "a"
\r
21 mp_reduce_setup (mp_int * a, mp_int * b)
\r
25 if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
\r
28 return mp_div (a, b, a, NULL);
\r