From bfba83ed168a2625cbff05cfa91db39c3c9cd970 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 3 Aug 2015 15:13:00 +0200 Subject: [PATCH] galois_mul2 conditional-free implementation --- core/lib/aes-128.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/lib/aes-128.c b/core/lib/aes-128.c index 59b16421e..23e4356b7 100644 --- a/core/lib/aes-128.c +++ b/core/lib/aes-128.c @@ -71,12 +71,8 @@ static uint8_t round_keys[11][AES_128_KEY_LENGTH]; static uint8_t galois_mul2(uint8_t value) { - if(value >> 7) { - value = value << 1; - return value ^ 0x1b; - } else { - return value << 1; - } + uint8_t xor_val = (value >> 7) * 0x1b; + return ((value << 1) ^ xor_val); } /*---------------------------------------------------------------------------*/ static void