Base64: Cache attack resistant decode

This commit is contained in:
Sean Parkinson
2020-12-14 12:30:17 +10:00
parent 65d0cc62fd
commit 972d6cfefc
4 changed files with 133 additions and 17 deletions

View File

@@ -435,12 +435,24 @@ WC_STATIC WC_INLINE word16 ctMask16GT(int a, int b)
return (word16)((((word32)a - b - 1) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a >= b */
WC_STATIC WC_INLINE word16 ctMask16GTE(int a, int b)
{
return (word16)((((word32)a - b ) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a < b. */
WC_STATIC WC_INLINE word16 ctMask16LT(int a, int b)
{
return (word16)((((word32)b - a - 1) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a <= b. */
WC_STATIC WC_INLINE word16 ctMask16LTE(int a, int b)
{
return (word16)((((word32)b - a ) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a == b. */
WC_STATIC WC_INLINE word16 ctMask16Eq(int a, int b)
{