From 29e82018cde093848258f3643ee1775abe3d8985 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 26 Aug 2016 12:14:01 +0100 Subject: [PATCH] bignum: rename bn_load_uint* to bn_read_uint* --- bignum.c | 4 ++-- bignum.h | 4 ++-- tests.c | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bignum.c b/bignum.c index 7d756e84f5..7548bd1d33 100644 --- a/bignum.c +++ b/bignum.c @@ -156,7 +156,7 @@ void bn_write_le(const bignum256 *in_number, uint8_t *out_number) } } -void bn_load_uint32(uint32_t in_number, bignum256 *out_number) +void bn_read_uint32(uint32_t in_number, bignum256 *out_number) { out_number->val[0] = in_number & 0x3FFFFFFF; out_number->val[1] = in_number >> 30; @@ -169,7 +169,7 @@ void bn_load_uint32(uint32_t in_number, bignum256 *out_number) out_number->val[8] = 0; } -void bn_load_uint64(uint64_t in_number, bignum256 *out_number) +void bn_read_uint64(uint64_t in_number, bignum256 *out_number) { out_number->val[0] = in_number & 0x3FFFFFFF; out_number->val[1] = (in_number >>= 30) & 0x3FFFFFFF; diff --git a/bignum.h b/bignum.h index 8a770064a2..377bf12744 100644 --- a/bignum.h +++ b/bignum.h @@ -54,9 +54,9 @@ void bn_read_le(const uint8_t *in_number, bignum256 *out_number); void bn_write_le(const bignum256 *in_number, uint8_t *out_number); -void bn_load_uint32(uint32_t in_number, bignum256 *out_number); +void bn_read_uint32(uint32_t in_number, bignum256 *out_number); -void bn_load_uint64(uint64_t in_number, bignum256 *out_number); +void bn_read_uint64(uint64_t in_number, bignum256 *out_number); // copies number a to b static inline void bn_copy(const bignum256 *a, bignum256 *b) { diff --git a/tests.c b/tests.c index baefdbf966..804969bbfe 100644 --- a/tests.c +++ b/tests.c @@ -183,52 +183,52 @@ START_TEST(test_bignum_write_le) } END_TEST -START_TEST(test_bignum_load_uint32) +START_TEST(test_bignum_read_uint32) { bignum256 a; bignum256 b; // lowest 30 bits set bn_read_be(fromhex("000000000000000000000000000000000000000000000000000000003fffffff"), &a); - bn_load_uint32(0x3fffffff, &b); + bn_read_uint32(0x3fffffff, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); // bit 31 set bn_read_be(fromhex("0000000000000000000000000000000000000000000000000000000040000000"), &a); - bn_load_uint32(0x40000000, &b); + bn_read_uint32(0x40000000, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); } END_TEST -START_TEST(test_bignum_load_uint64) +START_TEST(test_bignum_read_uint64) { bignum256 a; bignum256 b; // lowest 30 bits set bn_read_be(fromhex("000000000000000000000000000000000000000000000000000000003fffffff"), &a); - bn_load_uint64(0x3fffffff, &b); + bn_read_uint64(0x3fffffff, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); // bit 31 set bn_read_be(fromhex("0000000000000000000000000000000000000000000000000000000040000000"), &a); - bn_load_uint64(0x40000000, &b); + bn_read_uint64(0x40000000, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); // bit 33 set bn_read_be(fromhex("0000000000000000000000000000000000000000000000000000000100000000"), &a); - bn_load_uint64(0x100000000LL, &b); + bn_read_uint64(0x100000000LL, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); // bit 61 set bn_read_be(fromhex("0000000000000000000000000000000000000000000000002000000000000000"), &a); - bn_load_uint64(0x2000000000000000LL, &b); + bn_read_uint64(0x2000000000000000LL, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); // all 64 bits set bn_read_be(fromhex("000000000000000000000000000000000000000000000000ffffffffffffffff"), &a); - bn_load_uint64(0xffffffffffffffffLL, &b); + bn_read_uint64(0xffffffffffffffffLL, &b); ck_assert_int_eq(bn_is_equal(&a, &b), 1); } END_TEST @@ -2527,8 +2527,8 @@ Suite *test_suite(void) tcase_add_test(tc, test_bignum_is_zero); tcase_add_test(tc, test_bignum_read_le); tcase_add_test(tc, test_bignum_write_le); - tcase_add_test(tc, test_bignum_load_uint32); - tcase_add_test(tc, test_bignum_load_uint64); + tcase_add_test(tc, test_bignum_read_uint32); + tcase_add_test(tc, test_bignum_read_uint64); tcase_add_test(tc, test_bignum_copy); tcase_add_test(tc, test_bignum_is_even); tcase_add_test(tc, test_bignum_is_odd);