summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/add_threshold/tweakey.c17
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);
}
}