Commit 62a09c66cad71419337624ae8323595f647ab019

Francois Perrad 2019-10-06T16:09:48

all computation on unsigned

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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