diff options
Diffstat (limited to 'test/monniaux/bitsliced-aes/bs.c')
-rw-r--r-- | test/monniaux/bitsliced-aes/bs.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/monniaux/bitsliced-aes/bs.c b/test/monniaux/bitsliced-aes/bs.c index df5c1f6b..4a9df4aa 100644 --- a/test/monniaux/bitsliced-aes/bs.c +++ b/test/monniaux/bitsliced-aes/bs.c @@ -14,6 +14,11 @@ #error "endianness not supported" #endif +#if 1 +#define TERNARY_XY0(t, x) ((-((t) != 0)) & (x)) +#else +#define TERNARY_XY0(t, x) (((t) != 0) ? (x) : (0)) +#endif void bs_addroundkey(word_t * B, word_t * rk) { @@ -388,11 +393,14 @@ void bs_transpose_dst(word_t * transpose, word_t * blocks) int offset = i << MUL_SHIFT; #ifndef UNROLL_TRANSPOSE + /* DM experiments */ + /* The normal ternary operator costs us a lot! + from 10145951 to 7995063 */ int j; for(j=0; j < WORD_SIZE; j++) { // TODO make const time - transpose[offset + j] |= (w & (ONE << j)) ? bitpos : 0; + transpose[offset + j] |= TERNARY_XY0(w & (ONE << j), bitpos); } #else @@ -488,7 +496,7 @@ void bs_transpose_rev(word_t * blocks) int j; for(j=0; j < WORD_SIZE; j++) { - word_t bit = (w & (ONE << j)) ? (ONE << (k % WORD_SIZE)) : 0; + word_t bit = TERNARY_XY0((w & (ONE << j)), (ONE << (k % WORD_SIZE))); transpose[j * WORDS_PER_BLOCK + (offset)] |= bit; } #else |