Coverage Report

Created: 2025-08-26 06:44

/src/dropbear/libtommath/bn_mp_dr_is_modulus.c
Line
Count
Source (jump to first uncovered line)
1
#include "tommath_private.h"
2
#ifdef BN_MP_DR_IS_MODULUS_C
3
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
4
/* SPDX-License-Identifier: Unlicense */
5
6
/* determines if a number is a valid DR modulus */
7
mp_bool mp_dr_is_modulus(const mp_int *a)
8
40.2k
{
9
40.2k
   int ix;
10
11
   /* must be at least two digits */
12
40.2k
   if (a->used < 2) {
13
0
      return MP_NO;
14
0
   }
15
16
   /* must be of the form b**k - a [a <= b] so all
17
    * but the first digit must be equal to -1 (mod b).
18
    */
19
40.6k
   for (ix = 1; ix < a->used; ix++) {
20
40.6k
      if (a->dp[ix] != MP_MASK) {
21
40.2k
         return MP_NO;
22
40.2k
      }
23
40.6k
   }
24
0
   return MP_YES;
25
40.2k
}
26
27
#endif