summaryrefslogtreecommitdiff
path: root/crypto_aead/lilliputaei128v1/ref/tweakey.c
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-21 10:29:44 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-21 10:29:44 +0100
commit1b70dc0fdb7c445f526a51ced73e531ac31cf438 (patch)
tree5667abd2324b77c15e4af958eca7aeeaf5960387 /crypto_aead/lilliputaei128v1/ref/tweakey.c
parent59369b8bfe208ba5a353c0985ad7c8d421cc9988 (diff)
downloadlilliput-ae-implem-1b70dc0fdb7c445f526a51ced73e531ac31cf438.tar.xz
Implémentation de la multiplication du tweakey
Diffstat (limited to 'crypto_aead/lilliputaei128v1/ref/tweakey.c')
-rw-r--r--crypto_aead/lilliputaei128v1/ref/tweakey.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/tweakey.c b/crypto_aead/lilliputaei128v1/ref/tweakey.c
index d7a5805..71bc030 100644
--- a/crypto_aead/lilliputaei128v1/ref/tweakey.c
+++ b/crypto_aead/lilliputaei128v1/ref/tweakey.c
@@ -8,6 +8,7 @@
#define LANE_BITS 64
#define LANE_BYTES (LANE_BITS/8)
+#define LANES_NB (TWEAKEY_BYTES/LANE_BYTES)
static void _dump_buffer(FILE *output, size_t len, const uint8_t buf[len], int indent)
@@ -90,8 +91,22 @@ static void _permute_state(tweakey_state *TK)
}
}
-static void _multiply_state(__attribute__((unused)) tweakey_state *TK)
+static void _multiply_state(tweakey_state *TK)
{
+ /* Lane 0 is multiplied by Id; lane 1 by P_0, lane 2 by P_1... */
+
+ for (size_t lane=1; lane<LANES_NB; lane++)
+ {
+ const uint8_t* P_lane = P[lane-1];
+
+ /* TODO: homogenize indices; here b=byte */
+
+ for (size_t b=0; b<LANE_BYTES; b++)
+ {
+ size_t offset = lane*LANE_BYTES + b;
+ TK->TK[offset] = P_lane[TK->TK[offset]];
+ }
+ }
}
void tweakey_state_update(tweakey_state *TK)