/src/dropbear/libtommath/bn_mp_cmp.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include "tommath_private.h" |
2 | | #ifdef BN_MP_CMP_C |
3 | | /* LibTomMath, multiple-precision integer library -- Tom St Denis */ |
4 | | /* SPDX-License-Identifier: Unlicense */ |
5 | | |
6 | | /* compare two ints (signed)*/ |
7 | | mp_ord mp_cmp(const mp_int *a, const mp_int *b) |
8 | 5 | { |
9 | | /* compare based on sign */ |
10 | 5 | if (a->sign != b->sign) { |
11 | 0 | if (a->sign == MP_NEG) { |
12 | 0 | return MP_LT; |
13 | 0 | } else { |
14 | 0 | return MP_GT; |
15 | 0 | } |
16 | 0 | } |
17 | | |
18 | | /* compare digits */ |
19 | 5 | if (a->sign == MP_NEG) { |
20 | | /* if negative compare opposite direction */ |
21 | 0 | return mp_cmp_mag(b, a); |
22 | 5 | } else { |
23 | 5 | return mp_cmp_mag(a, b); |
24 | 5 | } |
25 | 5 | } |
26 | | #endif |