RSA: cast bitwise negate value to byte before converting to int

This commit is contained in:
Sean Parkinson
2021-09-24 09:18:49 +10:00
parent 33cb823148
commit d5a803d81d

View File

@ -1720,7 +1720,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
word16 j; word16 j;
word16 pastSep = 0; word16 pastSep = 0;
i = 0; i = 0;
/* Decrypted with private key - unpad must be constant time. */ /* Decrypted with private key - unpad must be constant time. */
for (j = 2; j < pkcsBlockLen; j++) { for (j = 2; j < pkcsBlockLen; j++) {
/* Update i if not passed the separator and at separator. */ /* Update i if not passed the separator and at separator. */
@ -1738,7 +1738,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
invalid |= ctMaskNotEq(pkcsBlock[1], padValue); invalid |= ctMaskNotEq(pkcsBlock[1], padValue);
*output = (byte *)(pkcsBlock + i); *output = (byte *)(pkcsBlock + i);
ret = ((int)~invalid) & (pkcsBlockLen - i); ret = ((int)(byte)~invalid) & (pkcsBlockLen - i);
} }
#endif #endif