Mailing List Archive

[PATCH 02/12] const-time: always avoid comparison operator for byte comparison
* configure.ac: Remove POSSIBLE_CONDITIONAL_BRANCH_IN_BYTE_COMPARISON
macro.
* src/const-time.h (ct_not_equal_byte): Remove
POSSIBLE_CONDITIONAL_BRANCH_IN_BYTE_COMPARISON ifdef.
--

Performance impact of avoiding comparison is negligible, so
remove the option for using comparison to make this easier
maintain (tested on every arch).

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
---
configure.ac | 5 -----
src/const-time.h | 4 ----
2 files changed, 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index aead8347..4f7c3a52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,11 +121,6 @@ AH_BOTTOM([.
properly prefixed. */
#define CAMELLIA_EXT_SYM_PREFIX _gcry_

-/* For some architectures or a specific compiler vendor, we need
- to care about possible conditional branch in byte comparison. */
-#if defined(__vax__) || defined(AVR) || defined(_MSC_VER)
-# define POSSIBLE_CONDITIONAL_BRANCH_IN_BYTE_COMPARISON 1
-#endif
#endif /*_GCRYPT_CONFIG_H_INCLUDED*/
])

diff --git a/src/const-time.h b/src/const-time.h
index defe5ff4..4f14f86b 100644
--- a/src/const-time.h
+++ b/src/const-time.h
@@ -29,16 +29,12 @@
static inline unsigned int
ct_not_equal_byte (unsigned char b0, unsigned char b1)
{
-#ifdef POSSIBLE_CONDITIONAL_BRANCH_IN_BYTE_COMPARISON
unsigned int diff;

diff = b0;
diff ^= b1;

return (0U - diff) >> (sizeof (unsigned int)*8 - 1);
-#else
- return b0 != b1;
-#endif
}

/* Compare byte-arrays of length LEN, return 1 if it's not same, 0
--
2.40.1


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gcrypt-devel