forked from wolfSSL/wolfssl
sanity check for RSA key size and hash digest size
This commit is contained in:
@ -427,10 +427,19 @@ static int wc_RsaPad_OAEP(const byte* input, word32 inputLen, byte* pkcsBlock,
|
|||||||
size aproaches 0. In decryption if k is less than or equal -- then there
|
size aproaches 0. In decryption if k is less than or equal -- then there
|
||||||
is no possible room for msg.
|
is no possible room for msg.
|
||||||
k = RSA key size
|
k = RSA key size
|
||||||
hLen = hash digest size
|
hLen = hash digest size -- will always be >= 0 at this point
|
||||||
*/
|
*/
|
||||||
if ((int)inputLen > ((int)pkcsBlockLen - 2 * hLen - 2)) {
|
if ((word32)(2 * hLen + 2) > pkcsBlockLen) {
|
||||||
WOLFSSL_MSG("OAEP pad error, message too long or hash to big for RSA key size");
|
WOLFSSL_MSG("OAEP pad error hash to big for RSA key size");
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
XFREE(lHash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputLen > (pkcsBlockLen - 2 * hLen - 2)) {
|
||||||
|
WOLFSSL_MSG("OAEP pad error message too long");
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(lHash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(lHash, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
Reference in New Issue
Block a user