Coverage Report

Created: 2023-03-20 06:28

/src/dropbear/libtommath/bn_mp_invmod.c
Line
Count
Source (jump to first uncovered line)
1
#include "tommath_private.h"
2
#ifdef BN_MP_INVMOD_C
3
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
4
/* SPDX-License-Identifier: Unlicense */
5
6
/* hac 14.61, pp608 */
7
mp_err mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
8
0
{
9
   /* b cannot be negative and has to be >1 */
10
0
   if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1uL) != MP_GT)) {
11
0
      return MP_VAL;
12
0
   }
13
14
   /* if the modulus is odd we can use a faster routine instead */
15
0
   if (MP_HAS(S_MP_INVMOD_FAST) && MP_IS_ODD(b)) {
16
0
      return s_mp_invmod_fast(a, b, c);
17
0
   }
18
19
0
   return MP_HAS(S_MP_INVMOD_SLOW)
20
0
          ? s_mp_invmod_slow(a, b, c)
21
0
          : MP_VAL;
22
0
}
23
#endif