mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 12:44:45 +02:00
misc.c: introduce ctMaskCopy()
This commit is contained in:
@@ -544,6 +544,17 @@ WC_STATIC WC_INLINE byte ctSetLTE(int a, int b)
|
|||||||
{
|
{
|
||||||
return (byte)(((word32)a - b - 1) >> 31);
|
return (byte)(((word32)a - b - 1) >> 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Constant time - copy size bytes from left to dst if mask is set, size bytes
|
||||||
|
* from right to dst if mask is not set */
|
||||||
|
WC_STATIC WC_INLINE void ctMaskCopy(byte m, byte* dst, byte* left, byte* right,
|
||||||
|
word16 size)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < size; ++i)
|
||||||
|
dst[i] = ctMaskSel(m, left[i], right[i]);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_W64_WRAPPER)
|
#if defined(WOLFSSL_W64_WRAPPER)
|
||||||
|
@@ -126,6 +126,8 @@ 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);
|
||||||
WOLFSSL_LOCAL byte ctSetLTE(int a, int b);
|
WOLFSSL_LOCAL byte ctSetLTE(int a, int b);
|
||||||
|
WOLFSSL_LOCAL void ctMaskCopy(byte m, byte* dst, byte* left, byte* right,
|
||||||
|
word16 size);
|
||||||
|
|
||||||
#endif /* NO_INLINE */
|
#endif /* NO_INLINE */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user