lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

commit 7b5ab3aa0c5e8c62b4fc9dcb4fc579efb527a4f0
parent e71424ebdd2a3f8a4d8439beb8a5cb2a64b12149
Author: Kévin Le Gouguec <kevin.legouguec@airbus.com>
Date:   Tue, 21 May 2019 14:22:34 +0200

Dé-duplication de code dans l'implémentation FELICS

Apparemment les différents gcc de  FELICS arrivent encore à comprendre
qu'ils peuvent inligner les multiplications ; c'est quand on passe par
un tableau de pointeurs de fonction qu'ils baissent les bras.

Diffstat:
Msrc/add_felicsref/tweakey.c | 43++++++++++++++-----------------------------
1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/src/add_felicsref/tweakey.c b/src/add_felicsref/tweakey.c @@ -70,46 +70,31 @@ void tweakey_state_extract( } -void tweakey_state_update(uint8_t TK[TWEAKEY_BYTES]) -{ - /* Skip lane 0, as it is multiplied by the identity matrix. */ +typedef void (*matrix_multiplication)(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]); - size_t j; - uint8_t *TKj; +static void _multiply(uint8_t TKj[LANE_BYTES], matrix_multiplication alpha) +{ uint8_t TKj_old[LANE_BYTES]; - - j = 1; - TKj = TK + j*LANE_BYTES; memcpy(TKj_old, TKj, LANE_BYTES); - _multiply_M(TKj_old, TKj); + alpha(TKj_old, TKj); +} - j = 2; - TKj = TK + j*LANE_BYTES; - memcpy(TKj_old, TKj, LANE_BYTES); - _multiply_M2(TKj_old, TKj); +void tweakey_state_update(uint8_t TK[TWEAKEY_BYTES]) +{ + /* Skip lane 0, as it is multiplied by the identity matrix. */ - j = 3; - TKj = TK + j*LANE_BYTES; - memcpy(TKj_old, TKj, LANE_BYTES); - _multiply_M3(TKj_old, TKj); + _multiply(TK + 1*LANE_BYTES, _multiply_M); + _multiply(TK + 2*LANE_BYTES, _multiply_M2); + _multiply(TK + 3*LANE_BYTES, _multiply_M3); #if LANES_NB >= 5 - j = 4; - TKj = TK + j*LANE_BYTES; - memcpy(TKj_old, TKj, LANE_BYTES); - _multiply_MR(TKj_old, TKj); + _multiply(TK + 4*LANE_BYTES, _multiply_MR); #if LANES_NB >= 6 - j = 5; - TKj = TK + j*LANE_BYTES; - memcpy(TKj_old, TKj, LANE_BYTES); - _multiply_MR2(TKj_old, TKj); + _multiply(TK + 5*LANE_BYTES, _multiply_MR2); #if LANES_NB >= 7 - j = 6; - TKj = TK + j*LANE_BYTES; - memcpy(TKj_old, TKj, LANE_BYTES); - _multiply_MR3(TKj_old, TKj); + _multiply(TK + 6*LANE_BYTES, _multiply_MR3); #endif #endif #endif