mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
bignum: rename bn_maxdigitcount to bn_digitcount
This reverts commit 5dbdf18b6c
.
This commit is contained in:
parent
5e1a3ad6e0
commit
43ea1392f2
2
bignum.c
2
bignum.c
@ -999,7 +999,7 @@ size_t bn_format(const bignum256 *amnt, const char *prefix, const char *suffix,
|
||||
BN_FORMAT_PUSH(0);
|
||||
}
|
||||
|
||||
unsigned int digits = bn_maxdigitcount(&val);
|
||||
unsigned int digits = bn_digitcount(&val);
|
||||
for (unsigned int i = 0; i < digits / 3; i++) {
|
||||
uint32_t limb;
|
||||
bn_divmod1000(&val, &limb);
|
||||
|
2
bignum.h
2
bignum.h
@ -83,7 +83,7 @@ static inline void bn_copy(const bignum256 *a, bignum256 *b) {
|
||||
|
||||
int bn_bitcount(const bignum256 *a);
|
||||
|
||||
static inline int bn_maxdigitcount(const bignum256 *a)
|
||||
static inline int bn_digitcount(const bignum256 *a)
|
||||
{
|
||||
int bitcount = bn_bitcount(a);
|
||||
|
||||
|
12
test_check.c
12
test_check.c
@ -391,7 +391,7 @@ START_TEST(test_bignum_digitcount)
|
||||
bignum256 a;
|
||||
|
||||
bn_zero(&a);
|
||||
ck_assert_int_eq(bn_maxdigitcount(&a), 1);
|
||||
ck_assert_int_eq(bn_digitcount(&a), 1);
|
||||
|
||||
// test for 10000 and 99999 when i=5
|
||||
for (int i = 1; i <= 19; i++) {
|
||||
@ -402,19 +402,19 @@ START_TEST(test_bignum_digitcount)
|
||||
n = n * 10 + 9;
|
||||
}
|
||||
bn_read_uint64(m, &a);
|
||||
ck_assert_int_eq(bn_maxdigitcount(&a), i);
|
||||
ck_assert_int_eq(bn_digitcount(&a), i);
|
||||
bn_read_uint64(n, &a);
|
||||
ck_assert_int_eq(bn_maxdigitcount(&a), i + 1);
|
||||
ck_assert_int_eq(bn_digitcount(&a), i);
|
||||
}
|
||||
|
||||
bn_read_uint32(0x3fffffff, &a);
|
||||
ck_assert_int_eq(bn_maxdigitcount(&a), 10);
|
||||
ck_assert_int_eq(bn_digitcount(&a), 10);
|
||||
|
||||
bn_read_uint32(0xffffffff, &a);
|
||||
ck_assert_int_eq(bn_maxdigitcount(&a), 10);
|
||||
ck_assert_int_eq(bn_digitcount(&a), 10);
|
||||
|
||||
bn_read_be(fromhex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), &a);
|
||||
ck_assert_int_eq(bn_maxdigitcount(&a), 78);
|
||||
ck_assert_int_eq(bn_digitcount(&a), 78);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user