Moved infinite loop check to the other bad func arg check.

pull/2773/head
Stanislav Klima 2020-02-18 09:59:59 +01:00
parent 1b13178182
commit 6f3623f220
1 changed files with 1 additions and 4 deletions

View File

@ -1596,7 +1596,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
byte invalid = 0;
#endif
if (output == NULL || pkcsBlockLen == 0) {
if (output == NULL || pkcsBlockLen == 0 || pkcsBlockLen > 0xFFFF) {
return BAD_FUNC_ARG;
}
@ -1624,9 +1624,6 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
word16 j;
word16 pastSep = 0;
if (pkcsBlockLen > 0xFFFF)
return RSA_PAD_E;
/* Decrypted with private key - unpad must be constant time. */
for (i = 0, j = 2; j < pkcsBlockLen; j++) {
/* Update i if not passed the separator and at separator. */