@@ -595,18 +595,18 @@ static word64 Load64BitLittleEndian(const byte* a)
595595
596596 return n ;
597597}
598- #elif defined(WC_SHA3_HARDEN )
598+ #elif defined(WC_SHA3_FAULT_HARDEN )
599599static WC_INLINE word64 Load64Unaligned (const unsigned char * a )
600600{
601601#ifdef WC_64BIT_CPU
602602 return * (word64 * )a ;
603603#elif defined(WC_32BIT_CPU )
604- return (((word64 )((word32 * )a )[1 ]) << 32 ) ||
604+ return (((word64 )((word32 * )a )[1 ]) << 32 ) |
605605 ((word32 * )a )[0 ];
606606#else
607- return (((word64 )((word16 * )a )[3 ]) << 48 ) ||
608- (((word64 )((word16 * )a )[2 ]) << 32 ) ||
609- (((word64 )((word16 * )a )[1 ]) << 16 ) ||
607+ return (((word64 )((word16 * )a )[3 ]) << 48 ) |
608+ (((word64 )((word16 * )a )[2 ]) << 32 ) |
609+ (((word64 )((word16 * )a )[1 ]) << 16 ) |
610610 ((word16 * )a )[0 ];
611611#endif
612612}
@@ -712,9 +712,9 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
712712{
713713 word32 i ;
714714 word32 blocks ;
715- #ifdef WC_SHA3_HARDEN
716- byte check = 0 ;
717- byte total_check = 0 ;
715+ #ifdef WC_SHA3_FAULT_HARDEN
716+ word32 check = 0 ;
717+ word32 total_check = 0 ;
718718#endif
719719
720720#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS ) && defined(USE_INTEL_SPEEDUP )
@@ -732,11 +732,11 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
732732 t = & sha3 -> t [sha3 -> i ];
733733 for (i = 0 ; i < l ; i ++ ) {
734734 t [i ] = data [i ];
735- #ifdef WC_SHA3_HARDEN
735+ #ifdef WC_SHA3_FAULT_HARDEN
736736 check ++ ;
737737 #endif
738738 }
739- #ifdef WC_SHA3_HARDEN
739+ #ifdef WC_SHA3_FAULT_HARDEN
740740 if (check != l ) {
741741 return BAD_COND_E ;
742742 }
@@ -747,16 +747,16 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
747747 sha3 -> i = (byte )(sha3 -> i + i );
748748
749749 if (sha3 -> i == p * 8 ) {
750- #if !defined(BIG_ENDIAN_ORDER ) && !defined(WC_SHA3_HARDEN )
750+ #if !defined(BIG_ENDIAN_ORDER ) && !defined(WC_SHA3_FAULT_HARDEN )
751751 xorbuf (sha3 -> s , sha3 -> t , (word32 )(p * 8 ));
752752 #else
753753 for (i = 0 ; i < p ; i ++ ) {
754754 sha3 -> s [i ] ^= Load64BitLittleEndian (sha3 -> t + 8 * i );
755- #ifdef WC_SHA3_HARDEN
755+ #ifdef WC_SHA3_FAULT_HARDEN
756756 check ++ ;
757757 #endif
758758 }
759- #ifdef WC_SHA3_HARDEN
759+ #ifdef WC_SHA3_FAULT_HARDEN
760760 if (check != p + l ) {
761761 return BAD_COND_E ;
762762 }
@@ -780,20 +780,20 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
780780 blocks = 0 ;
781781 }
782782 #endif
783- #ifdef WC_SHA3_HARDEN
783+ #ifdef WC_SHA3_FAULT_HARDEN
784784 total_check += blocks * p ;
785785#endif
786786 for (; blocks > 0 ; blocks -- ) {
787- #if !defined(BIG_ENDIAN_ORDER ) && !defined(WC_SHA3_HARDEN )
787+ #if !defined(BIG_ENDIAN_ORDER ) && !defined(WC_SHA3_FAULT_HARDEN )
788788 xorbuf (sha3 -> s , data , (word32 )(p * 8 ));
789789#else
790790 for (i = 0 ; i < p ; i ++ ) {
791791 sha3 -> s [i ] ^= Load64Unaligned (data + 8 * i );
792- #ifdef WC_SHA3_HARDEN
792+ #ifdef WC_SHA3_FAULT_HARDEN
793793 check ++ ;
794794 #endif
795795 }
796- #ifdef WC_SHA3_HARDEN
796+ #ifdef WC_SHA3_FAULT_HARDEN
797797 if (check != total_check - ((blocks - 1 ) * p )) {
798798 return BAD_COND_E ;
799799 }
@@ -807,7 +807,7 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
807807 len -= p * 8U ;
808808 data += p * 8U ;
809809 }
810- #ifdef WC_SHA3_HARDEN
810+ #ifdef WC_SHA3_FAULT_HARDEN
811811 if (check != total_check ) {
812812 return BAD_COND_E ;
813813 }
@@ -837,14 +837,14 @@ static int Sha3Final(wc_Sha3* sha3, byte padChar, byte* hash, byte p, word32 l)
837837{
838838 word32 rate = p * 8U ;
839839 word32 j ;
840- #if defined(BIG_ENDIAN_ORDER ) || defined(WC_SHA3_HARDEN )
840+ #if defined(BIG_ENDIAN_ORDER ) || defined(WC_SHA3_FAULT_HARDEN )
841841 word32 i ;
842842#endif
843- #ifdef WC_SHA3_HARDEN
843+ #ifdef WC_SHA3_FAULT_HARDEN
844844 int check = 0 ;
845845#endif
846846
847- #if !defined(BIG_ENDIAN_ORDER ) && !defined(WC_SHA3_HARDEN )
847+ #if !defined(BIG_ENDIAN_ORDER ) && !defined(WC_SHA3_FAULT_HARDEN )
848848 xorbuf (sha3 -> s , sha3 -> t , sha3 -> i );
849849#ifdef WOLFSSL_HASH_FLAGS
850850 if ((p == WC_SHA3_256_COUNT ) && (sha3 -> flags & WC_HASH_SHA3_KECCAK256 )) {
@@ -867,11 +867,11 @@ static int Sha3Final(wc_Sha3* sha3, byte padChar, byte* hash, byte p, word32 l)
867867 }
868868 for (i = 0 ; i < p ; i ++ ) {
869869 sha3 -> s [i ] ^= Load64BitLittleEndian (sha3 -> t + 8 * i );
870- #ifdef WC_SHA3_HARDEN
870+ #ifdef WC_SHA3_FAULT_HARDEN
871871 check ++ ;
872872 #endif
873873 }
874- #ifdef WC_SHA3_HARDEN
874+ #ifdef WC_SHA3_FAULT_HARDEN
875875 if (check != p ) {
876876 return BAD_COND_E ;
877877 }
0 commit comments