Commit 59e832499c0828aeb6df1ac0aab8df88eea6c772

nijtmans 2019-03-26T11:20:31

bug-fix in bn_mp_get_bit.c: handle overflow correctly

diff --git a/bn_mp_get_bit.c b/bn_mp_get_bit.c
index cfce3b1..f5d2450 100644
--- a/bn_mp_get_bit.c
+++ b/bn_mp_get_bit.c
@@ -27,18 +27,8 @@ int mp_get_bit(const mp_int *a, int b)
 
    limb = b / DIGIT_BIT;
 
-   /*
-    * Zero is a special value with the member "used" set to zero.
-    * Needs to be tested before the check for the upper boundary
-    * otherwise (limb >= a->used) would be true for a = 0
-    */
-
-   if (IS_ZERO(a)) {
-      return MP_NO;
-   }
-
    if (limb >= a->used) {
-      return MP_VAL;
+      return MP_NO;
    }
 
    bit = (mp_digit)(1) << (b % DIGIT_BIT);