From d5a803d81d4fc0fd8f89173c7be2c1cb1b77f3f8 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 24 Sep 2021 09:18:49 +1000 Subject: [PATCH] RSA: cast bitwise negate value to byte before converting to int --- wolfcrypt/src/rsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index a85a7b8da..de7db7ee8 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -1720,7 +1720,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen, word16 j; word16 pastSep = 0; - i = 0; + i = 0; /* Decrypted with private key - unpad must be constant time. */ for (j = 2; j < pkcsBlockLen; j++) { /* 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); *output = (byte *)(pkcsBlock + i); - ret = ((int)~invalid) & (pkcsBlockLen - i); + ret = ((int)(byte)~invalid) & (pkcsBlockLen - i); } #endif