Skip to content

Commit 80a234a

Browse files
authored
Merge pull request #8830 from JacobBarthelmeh/rx_threadx
add option to not use CT code with min/max
2 parents 1c1c556 + 1c5e531 commit 80a234a

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ WOLFSSL_NO_COPY_CERT
744744
WOLFSSL_NO_COPY_KEY
745745
WOLFSSL_NO_CRL_DATE_CHECK
746746
WOLFSSL_NO_CRL_NEXT_DATE
747+
WOLFSSL_NO_CT_MAX_MIN
747748
WOLFSSL_NO_DECODE_EXTRA
748749
WOLFSSL_NO_DER_TO_PEM
749750
WOLFSSL_NO_DH186

wolfcrypt/src/misc.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,13 @@ WC_MISC_STATIC WC_INLINE int ConstantCompare(const byte* a, const byte* b,
633633
}
634634
#endif
635635

636-
#ifndef WOLFSSL_NO_CT_OPS
636+
637+
#if defined(WOLFSSL_NO_CT_OPS) && (!defined(NO_RSA) || !defined(WOLFCRYPT_ONLY))
638+
/* constant time operations with mask are required for RSA and TLS operations */
639+
#warning constant time operations required unless using NO_RSA & WOLFCRYPT_ONLY
640+
#endif
641+
642+
#if !defined(WOLFSSL_NO_CT_OPS) || !defined(NO_RSA) || !defined(WOLFCRYPT_ONLY)
637643
/* Constant time - mask set when a > b. */
638644
WC_MISC_STATIC WC_INLINE byte ctMaskGT(int a, int b)
639645
{
@@ -761,7 +767,8 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
761767
/* returns the smaller of a and b */
762768
WC_MISC_STATIC WC_INLINE word32 min(word32 a, word32 b)
763769
{
764-
#if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
770+
#if !defined(WOLFSSL_NO_CT_OPS) && !defined(WOLFSSL_NO_CT_MAX_MIN) && \
771+
defined(WORD64_AVAILABLE)
765772
word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
766773
return (a & ~gte_mask) | (b & gte_mask);
767774
#else /* WOLFSSL_NO_CT_OPS */
@@ -777,7 +784,8 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
777784
#endif
778785
WC_MISC_STATIC WC_INLINE word32 max(word32 a, word32 b)
779786
{
780-
#if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
787+
#if !defined(WOLFSSL_NO_CT_OPS) && !defined(WOLFSSL_NO_CT_MAX_MIN) && \
788+
defined(WORD64_AVAILABLE)
781789
word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
782790
return (a & gte_mask) | (b & ~gte_mask);
783791
#else /* WOLFSSL_NO_CT_OPS */

0 commit comments

Comments
 (0)