diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-07-01 17:40:36 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-07-01 17:40:36 +0200 |
| commit | e52d2c96531789fee70c1f1c5995c356ccbf9474 (patch) | |
| tree | 3b8bd44d277d05f8c36e9f1d976ace7a80ed65f2 /src/add_threshold | |
| parent | 962920c474261599f4bc13039b2d21d99b6b537a (diff) | |
| download | lilliput-ae-implem-e52d2c96531789fee70c1f1c5995c356ccbf9474.tar.xz | |
Factorisation de code dans l'implémentation à seuil
Plus facile à lire, je trouve (pas besoin de se demander "c'est quoi
cette division ?" à chaque fois).
Diffstat (limited to 'src/add_threshold')
| -rw-r--r-- | src/add_threshold/tweakey.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/add_threshold/tweakey.c b/src/add_threshold/tweakey.c index 888e893..8f531d9 100644 --- a/src/add_threshold/tweakey.c +++ b/src/add_threshold/tweakey.c @@ -29,7 +29,9 @@ tweakey schedule, where the tweak and the key are split into two shares. #include "tweakey.h" -#define LANES_NB (TWEAKEY_BYTES/LANE_BYTES) +#define LANES_NB (TWEAKEY_BYTES/LANE_BYTES) +#define TWEAK_LANES_NB (TWEAK_BYTES/LANE_BYTES) +#define KEY_LANES_NB (KEY_BYTES/LANE_BYTES) void tweakey_state_init( @@ -72,8 +74,7 @@ void tweakey_state_extract( } } - - for (size_t j=0; j<(KEY_BYTES / LANE_BYTES); j++) + for (size_t j=0; j<KEY_LANES_NB; j++) { const uint8_t *TKj_Y = TK_Y + j*LANE_BYTES; @@ -103,7 +104,7 @@ void tweakey_state_update(uint8_t TK_X[TWEAKEY_BYTES], uint8_t TK_Y[KEY_BYTES]) { /* Skip lane 0, as it is multiplied by the identity matrix. */ - for (size_t j=1; j<(TWEAK_BYTES/LANE_BYTES); j++) + for (size_t j=1; j<TWEAK_LANES_NB; j++) { uint8_t *TKj_X = TK_X + j*LANE_BYTES; @@ -113,9 +114,9 @@ void tweakey_state_update(uint8_t TK_X[TWEAKEY_BYTES], uint8_t TK_Y[KEY_BYTES]) ALPHAS[j-1](TKj_old_X, TKj_X); } - for (size_t j=0; j<(KEY_BYTES/LANE_BYTES); j++) + for (size_t j=0; j<KEY_LANES_NB; j++) { - uint8_t *TKj_X = TK_X + (j + (TWEAK_BYTES/LANE_BYTES))*LANE_BYTES; + uint8_t *TKj_X = TK_X + (j + TWEAK_LANES_NB)*LANE_BYTES; uint8_t *TKj_Y = TK_Y + j*LANE_BYTES; uint8_t TKj_X_old[LANE_BYTES]; @@ -123,7 +124,7 @@ void tweakey_state_update(uint8_t TK_X[TWEAKEY_BYTES], uint8_t TK_Y[KEY_BYTES]) memcpy(TKj_X_old, TKj_X, LANE_BYTES); memcpy(TKj_Y_old, TKj_Y, LANE_BYTES); - ALPHAS[j-1 + (TWEAK_BYTES/LANE_BYTES)](TKj_X_old, TKj_X); - ALPHAS[j-1 + (TWEAK_BYTES/LANE_BYTES)](TKj_Y_old, TKj_Y); + ALPHAS[j-1 + TWEAK_LANES_NB](TKj_X_old, TKj_X); + ALPHAS[j-1 + TWEAK_LANES_NB](TKj_Y_old, TKj_Y); } } |
