summaryrefslogtreecommitdiff
path: root/src/add_threshold/tweakey.c
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-07-04 17:13:57 +0200
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-07-04 17:13:57 +0200
commit3d1334d6a9eb091b457f068033071f97d8758941 (patch)
treece7a28187e7c407f6fa56bf4ff4ed29245f8b484 /src/add_threshold/tweakey.c
parent6589f3ef20f8f93168be49135764764cd0c02a23 (diff)
parentc670bbe78ea9bc18c9772ba5804f610937560d5f (diff)
downloadlilliput-ae-implem-3d1334d6a9eb091b457f068033071f97d8758941.tar.xz
Merge branch 'fix-tweakey-m4'
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);
}
}