forked from wolfSSL/wolfssl
Fix to "mp_init_multi" so failure ensures a later "mp_clear" won't free on un-initialized pointer. Applies to !USE_FAST_MATH only. No measurable benchmark difference.
This commit is contained in:
@ -100,6 +100,13 @@ int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
|
|||||||
{
|
{
|
||||||
int res = MP_OKAY;
|
int res = MP_OKAY;
|
||||||
|
|
||||||
|
if (a) XMEMSET(a, 0, sizeof(mp_int));
|
||||||
|
if (b) XMEMSET(b, 0, sizeof(mp_int));
|
||||||
|
if (c) XMEMSET(c, 0, sizeof(mp_int));
|
||||||
|
if (d) XMEMSET(d, 0, sizeof(mp_int));
|
||||||
|
if (e) XMEMSET(e, 0, sizeof(mp_int));
|
||||||
|
if (f) XMEMSET(f, 0, sizeof(mp_int));
|
||||||
|
|
||||||
if (a && ((res = mp_init(a)) != MP_OKAY))
|
if (a && ((res = mp_init(a)) != MP_OKAY))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@ -454,7 +461,7 @@ void mp_zero (mp_int * a)
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
mp_digit *tmp;
|
mp_digit *tmp;
|
||||||
|
|
||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -4418,7 +4425,7 @@ int mp_rand_prime(mp_int* N, int len, WC_RNG* rng, void* heap)
|
|||||||
|
|
||||||
XMEMSET(buf, 0, len);
|
XMEMSET(buf, 0, len);
|
||||||
XFREE(buf, heap, DYNAMIC_TYPE_RSA);
|
XFREE(buf, heap, DYNAMIC_TYPE_RSA);
|
||||||
|
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user