Merge pull request #2295 from kojo1/RSA4096

Static RSA4096
This commit is contained in:
Chris Conlon 2019-07-10 09:40:41 -06:00 committed by GitHub
commit 9cd6a992c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -350,6 +350,11 @@ WC_STATIC WC_INLINE byte ctMaskEq(int a, int b)
return 0 - (a == b);
}
WC_STATIC WC_INLINE word16 ctMask16Eq(int a, int b)
{
return 0 - (a == b);
}
/* Constant time - mask set when a != b. */
WC_STATIC WC_INLINE byte ctMaskNotEq(int a, int b)
{

View File

@ -1369,7 +1369,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
byte **output, byte padValue)
{
int ret = BAD_FUNC_ARG;
word32 i;
word16 i;
#ifndef WOLFSSL_RSA_VERIFY_ONLY
byte invalid = 0;
#endif
@ -1399,14 +1399,14 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
}
#ifndef WOLFSSL_RSA_VERIFY_ONLY
else {
word32 j;
byte pastSep = 0;
word16 j;
word16 pastSep = 0;
/* 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. */
i |= (~pastSep) & ctMaskEq(pkcsBlock[j], 0x00) & (j + 1);
pastSep |= ctMaskEq(pkcsBlock[j], 0x00);
i |= (~pastSep) & ctMask16Eq(pkcsBlock[j], 0x00) & (j + 1);
pastSep |= ctMask16Eq(pkcsBlock[j], 0x00);
}
/* Minimum of 11 bytes of pre-message data - including leading 0x00. */

View File

@ -97,6 +97,7 @@ WOLFSSL_LOCAL byte ctMaskGTE(int a, int b);
WOLFSSL_LOCAL byte ctMaskLT(int a, int b);
WOLFSSL_LOCAL byte ctMaskLTE(int a, int b);
WOLFSSL_LOCAL byte ctMaskEq(int a, int b);
WOLFSSL_LOCAL word16 ctMask16Eq(int a, int b);
WOLFSSL_LOCAL byte ctMaskNotEq(int a, int b);
WOLFSSL_LOCAL byte ctMaskSel(byte m, byte a, byte b);
WOLFSSL_LOCAL int ctMaskSelInt(byte m, int a, int b);