forked from wolfSSL/wolfssl
Fix for mp_radix_size
with radix 2 and mp_int equal to zero. Fix applies to normal and fast math only. ZD11419.
This commit is contained in:
@ -5256,7 +5256,10 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
||||
|
||||
/* special case for binary */
|
||||
if (radix == MP_RADIX_BIN) {
|
||||
*size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1;
|
||||
*size = mp_count_bits(a);
|
||||
if (*size == 0)
|
||||
*size = 1;
|
||||
*size += (a->sign == MP_NEG ? 1 : 0) + 1; /* "-" sign + null term */
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
|
@ -5550,8 +5550,11 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
||||
|
||||
/* special case for binary */
|
||||
if (radix == 2) {
|
||||
*size = fp_count_bits (a) + (a->sign == FP_NEG ? 1 : 0) + 1;
|
||||
return FP_YES;
|
||||
*size = fp_count_bits(a);
|
||||
if (*size == 0)
|
||||
*size = 1;
|
||||
*size += (a->sign == FP_NEG ? 1 : 0) + 1; /* "-" sign + null term */
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
/* make sure the radix is in range */
|
||||
|
Reference in New Issue
Block a user