mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Move neg check
This commit is contained in:
@ -5244,11 +5244,6 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
/* digs is the digit count */
|
/* digs is the digit count */
|
||||||
digs = 0;
|
digs = 0;
|
||||||
|
|
||||||
/* if it's negative add one for the sign */
|
|
||||||
if (a->sign == MP_NEG) {
|
|
||||||
++digs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* init a copy of the input */
|
/* init a copy of the input */
|
||||||
if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
|
if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
|
||||||
return res;
|
return res;
|
||||||
@ -5274,6 +5269,11 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* if it's negative add one for the sign */
|
||||||
|
if (a->sign == MP_NEG) {
|
||||||
|
++digs;
|
||||||
|
}
|
||||||
|
|
||||||
/* return digs + 1, the 1 is for the NULL byte that would be required. */
|
/* return digs + 1, the 1 is for the NULL byte that would be required. */
|
||||||
*size = digs + 1;
|
*size = digs + 1;
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
|
@ -5453,11 +5453,6 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
/* digs is the digit count */
|
/* digs is the digit count */
|
||||||
digs = 0;
|
digs = 0;
|
||||||
|
|
||||||
/* if it's negative add one for the sign */
|
|
||||||
if (a->sign == FP_NEG) {
|
|
||||||
++digs;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
t = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT);
|
t = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT);
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
@ -5485,11 +5480,16 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
|
|
||||||
#ifndef WC_DISABLE_RADIX_ZERO_PAD
|
#ifndef WC_DISABLE_RADIX_ZERO_PAD
|
||||||
/* For hexadecimal output, add zero padding when number of digits is odd */
|
/* For hexadecimal output, add zero padding when number of digits is odd */
|
||||||
if (((a->sign == FP_NEG) ? !(digs & 1) : (digs & 1)) && (radix == 16)) {
|
if ((digs & 1) && (radix == 16)) {
|
||||||
++digs;
|
++digs;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* if it's negative add one for the sign */
|
||||||
|
if (a->sign == FP_NEG) {
|
||||||
|
++digs;
|
||||||
|
}
|
||||||
|
|
||||||
/* return digs + 1, the 1 is for the NULL byte that would be required. */
|
/* return digs + 1, the 1 is for the NULL byte that would be required. */
|
||||||
*size = digs + 1;
|
*size = digs + 1;
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
Reference in New Issue
Block a user