Line data Source code
1 : #include "tommath_private.h"
2 : #ifdef BN_MP_REDUCE_SETUP_C
3 : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 : /* SPDX-License-Identifier: Unlicense */
5 :
6 : /* pre-calculate the value required for Barrett reduction
7 : * For a given modulus "b" it calulates the value required in "a"
8 : */
9 0 : mp_err mp_reduce_setup(mp_int *a, const mp_int *b)
10 : {
11 : mp_err err;
12 0 : if ((err = mp_2expt(a, b->used * 2 * MP_DIGIT_BIT)) != MP_OKAY) {
13 0 : return err;
14 : }
15 0 : return mp_div(a, b, a, NULL);
16 : }
17 : #endif
|