Coverage Report

Created: 2026-03-07 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dropbear/libtommath/bn_mp_cmp_mag.c
Line
Count
Source
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
8.86M
{
9
8.86M
   int     n;
10
8.86M
   const mp_digit *tmpa, *tmpb;
11
12
   /* compare based on # of non-zero digits */
13
8.86M
   if (a->used > b->used) {
14
22.8k
      return MP_GT;
15
22.8k
   }
16
17
8.84M
   if (a->used < b->used) {
18
40.3k
      return MP_LT;
19
40.3k
   }
20
21
   /* alias for a */
22
8.80M
   tmpa = a->dp + (a->used - 1);
23
24
   /* alias for b */
25
8.80M
   tmpb = b->dp + (a->used - 1);
26
27
   /* compare based on digits  */
28
8.85M
   for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
29
8.85M
      if (*tmpa > *tmpb) {
30
2.61M
         return MP_GT;
31
2.61M
      }
32
33
6.23M
      if (*tmpa < *tmpb) {
34
6.18M
         return MP_LT;
35
6.18M
      }
36
6.23M
   }
37
1.21k
   return MP_EQ;
38
8.80M
}
39
#endif