mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
integer.c: fast mod reduce fix
When using small stack, not enough memory uas being allocated in fast_mp_montgomery_reduce(). Allocate the required space and memset all used memory.
This commit is contained in:
@ -2512,13 +2512,13 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
W = (mp_word*)XMALLOC(sizeof(mp_word) * (n->used * 2 + 1), NULL,
|
W = (mp_word*)XMALLOC(sizeof(mp_word) * (n->used * 2 + 2), NULL,
|
||||||
DYNAMIC_TYPE_BIGINT);
|
DYNAMIC_TYPE_BIGINT);
|
||||||
if (W == NULL)
|
if (W == NULL)
|
||||||
return MP_MEM;
|
return MP_MEM;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XMEMSET(W, 0, sizeof(mp_word) * (n->used * 2 + 1));
|
XMEMSET(W, 0, sizeof(mp_word) * (n->used * 2 + 2));
|
||||||
|
|
||||||
/* first we have to get the digits of the input into
|
/* first we have to get the digits of the input into
|
||||||
* an array of double precision words W[...]
|
* an array of double precision words W[...]
|
||||||
|
Reference in New Issue
Block a user