@@ -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. */
638644WC_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