summaryrefslogtreecommitdiff
path: root/src/add_threshold/tweakey.c
diff options
context:
space:
mode:
authorGaetan Leplus <gaetan.leplus@airbus.com>2019-07-05 16:16:19 +0200
committerGaetan Leplus <gaetan.leplus@airbus.com>2019-07-05 16:16:19 +0200
commit62433c71e25f157dd79ba10d81631ee4c67f8eb1 (patch)
tree3ac352a3598fa444d45695dbb2b4cee63698ac57 /src/add_threshold/tweakey.c
parentde5f3445b5d382237afc39869907957e65c8a91e (diff)
parent75d7f59658539c699cdf9c7a3abdbead15aac199 (diff)
downloadlilliput-ae-implem-62433c71e25f157dd79ba10d81631ee4c67f8eb1.tar.xz
Merge remote-tracking branch 'origin/master' into fix-vhdltbc
Diffstat (limited to 'src/add_threshold/tweakey.c')
-rw-r--r--src/add_threshold/tweakey.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/add_threshold/tweakey.c b/src/add_threshold/tweakey.c
index 8f531d9..7822564 100644
--- a/src/add_threshold/tweakey.c
+++ b/src/add_threshold/tweakey.c
@@ -90,10 +90,11 @@ void tweakey_state_extract(
typedef void (*matrix_multiplication)(const uint8_t x[LANE_BYTES], uint8_t y[LANE_BYTES]);
-static const matrix_multiplication ALPHAS[6] = {
+static const matrix_multiplication ALPHAS[7] = {
_multiply_M,
_multiply_M2,
_multiply_M3,
+ _multiply_M4,
_multiply_MR,
_multiply_MR2,
_multiply_MR3
@@ -102,16 +103,14 @@ static const matrix_multiplication ALPHAS[6] = {
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_LANES_NB; j++)
+ for (size_t j=0; j<TWEAK_LANES_NB; j++)
{
uint8_t *TKj_X = TK_X + j*LANE_BYTES;
uint8_t TKj_old_X[LANE_BYTES];
memcpy(TKj_old_X, TKj_X, LANE_BYTES);
- ALPHAS[j-1](TKj_old_X, TKj_X);
+ ALPHAS[j](TKj_old_X, TKj_X);
}
for (size_t j=0; j<KEY_LANES_NB; j++)
@@ -124,7 +123,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_LANES_NB](TKj_X_old, TKj_X);
- ALPHAS[j-1 + TWEAK_LANES_NB](TKj_Y_old, TKj_Y);
+ ALPHAS[j + TWEAK_LANES_NB](TKj_X_old, TKj_X);
+ ALPHAS[j + TWEAK_LANES_NB](TKj_Y_old, TKj_Y);
}
}