From de606c034fee5b170adeade07ac59a29315f46b2 Mon Sep 17 00:00:00 2001 From: czurnieden Date: Tue, 15 Oct 2019 20:48:37 +0200 Subject: [PATCH] adaption of mp_radeix_size to new mp_log_u32 --- bn_mp_radix_size.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/bn_mp_radix_size.c b/bn_mp_radix_size.c index 33ef7d3..5ed9ab1 100644 --- a/bn_mp_radix_size.c +++ b/bn_mp_radix_size.c @@ -7,7 +7,8 @@ mp_err mp_radix_size(const mp_int *a, int radix, int *size) { mp_err err; - mp_int a_, b; + mp_int a_; + uint32_t b; /* make sure the radix is in range */ if ((radix < 2) || (radix > 64)) { @@ -19,25 +20,18 @@ mp_err mp_radix_size(const mp_int *a, int radix, int *size) return MP_OKAY; } - if ((err = mp_init(&b)) != MP_OKAY) { - goto LBL_ERR; - } - a_ = *a; a_.sign = MP_ZPOS; - if ((err = mp_ilogb(&a_, (uint32_t)radix, &b)) != MP_OKAY) { + if ((err = mp_log_u32(&a_, (uint32_t)radix, &b)) != MP_OKAY) { goto LBL_ERR; } - *size = (int)mp_get_l(&b); + *size = (int)b; /* mp_ilogb truncates to zero, hence we need one extra put on top and one for `\0`. */ *size += 2 + (a->sign == MP_NEG); LBL_ERR: - mp_clear(&b); return err; } - - #endif