commit
9cd6a992c5
@ -350,6 +350,11 @@ WC_STATIC WC_INLINE byte ctMaskEq(int a, int b)
|
|||||||
return 0 - (a == 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. */
|
/* Constant time - mask set when a != b. */
|
||||||
WC_STATIC WC_INLINE byte ctMaskNotEq(int a, int b)
|
WC_STATIC WC_INLINE byte ctMaskNotEq(int a, int b)
|
||||||
{
|
{
|
||||||
|
@ -1369,7 +1369,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
|
|||||||
byte **output, byte padValue)
|
byte **output, byte padValue)
|
||||||
{
|
{
|
||||||
int ret = BAD_FUNC_ARG;
|
int ret = BAD_FUNC_ARG;
|
||||||
word32 i;
|
word16 i;
|
||||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||||
byte invalid = 0;
|
byte invalid = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -1399,14 +1399,14 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
|
|||||||
}
|
}
|
||||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||||
else {
|
else {
|
||||||
word32 j;
|
word16 j;
|
||||||
byte pastSep = 0;
|
word16 pastSep = 0;
|
||||||
|
|
||||||
/* Decrypted with private key - unpad must be constant time. */
|
/* Decrypted with private key - unpad must be constant time. */
|
||||||
for (i = 0, j = 2; j < pkcsBlockLen; j++) {
|
for (i = 0, 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. */
|
||||||
i |= (~pastSep) & ctMaskEq(pkcsBlock[j], 0x00) & (j + 1);
|
i |= (~pastSep) & ctMask16Eq(pkcsBlock[j], 0x00) & (j + 1);
|
||||||
pastSep |= ctMaskEq(pkcsBlock[j], 0x00);
|
pastSep |= ctMask16Eq(pkcsBlock[j], 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Minimum of 11 bytes of pre-message data - including leading 0x00. */
|
/* Minimum of 11 bytes of pre-message data - including leading 0x00. */
|
||||||
|
@ -97,6 +97,7 @@ WOLFSSL_LOCAL byte ctMaskGTE(int a, int b);
|
|||||||
WOLFSSL_LOCAL byte ctMaskLT(int a, int b);
|
WOLFSSL_LOCAL byte ctMaskLT(int a, int b);
|
||||||
WOLFSSL_LOCAL byte ctMaskLTE(int a, int b);
|
WOLFSSL_LOCAL byte ctMaskLTE(int a, int b);
|
||||||
WOLFSSL_LOCAL byte ctMaskEq(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 ctMaskNotEq(int a, int b);
|
||||||
WOLFSSL_LOCAL byte ctMaskSel(byte m, byte a, byte b);
|
WOLFSSL_LOCAL byte ctMaskSel(byte m, byte a, byte b);
|
||||||
WOLFSSL_LOCAL int ctMaskSelInt(byte m, int a, int b);
|
WOLFSSL_LOCAL int ctMaskSelInt(byte m, int a, int b);
|
||||||
|
Loading…
Reference in New Issue
Block a user