Coverage Report

Created: 2025-07-11 06:08

/src/dropbear/libtommath/bn_mp_cmp_mag.c
Line
Count
Source (jump to first uncovered line)
1
#include "tommath_private.h"
2
#ifdef BN_MP_CMP_MAG_C
3
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
4
/* SPDX-License-Identifier: Unlicense */
5
6
/* compare maginitude of two ints (unsigned) */
7
mp_ord mp_cmp_mag(const mp_int *a, const mp_int *b)
8
0
{
9
0
   int     n;
10
0
   const mp_digit *tmpa, *tmpb;
11
12
   /* compare based on # of non-zero digits */
13
0
   if (a->used > b->used) {
14
0
      return MP_GT;
15
0
   }
16
17
0
   if (a->used < b->used) {
18
0
      return MP_LT;
19
0
   }
20
21
   /* alias for a */
22
0
   tmpa = a->dp + (a->used - 1);
23
24
   /* alias for b */
25
0
   tmpb = b->dp + (a->used - 1);
26
27
   /* compare based on digits  */
28
0
   for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
29
0
      if (*tmpa > *tmpb) {
30
0
         return MP_GT;
31
0
      }
32
33
0
      if (*tmpa < *tmpb) {
34
0
         return MP_LT;
35
0
      }
36
0
   }
37
0
   return MP_EQ;
38
0
}
39
#endif