all computation on unsigned
diff --git a/bn_mp_ubin_size.c b/bn_mp_ubin_size.c
index f32e190..21230b4 100644
--- a/bn_mp_ubin_size.c
+++ b/bn_mp_ubin_size.c
@@ -6,8 +6,7 @@
/* get the size for an unsigned equivalent */
size_t mp_ubin_size(const mp_int *a)
{
- int size = mp_count_bits(a);
- size = (size / 8) + ((((unsigned)size & 7u) != 0u) ? 1 : 0);
- return (size_t)size;
+ size_t size = (size_t)mp_count_bits(a);
+ return (size / 8u) + (((size & 7u) != 0u) ? 1u : 0u);
}
#endif