summaryrefslogtreecommitdiff
path: root/crypto_aead/lilliputaei128v1/ref/tweakey.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto_aead/lilliputaei128v1/ref/tweakey.c')
-rw-r--r--crypto_aead/lilliputaei128v1/ref/tweakey.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/tweakey.c b/crypto_aead/lilliputaei128v1/ref/tweakey.c
index 173f4be..d7a5805 100644
--- a/crypto_aead/lilliputaei128v1/ref/tweakey.c
+++ b/crypto_aead/lilliputaei128v1/ref/tweakey.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <inttypes.h> /* debug */
+#include "constants.h"
#include "tweakey.h"
@@ -73,12 +74,38 @@ void tweakey_state_extract(
}
+static void _permute_state(tweakey_state *TK)
+{
+ uint8_t TK_old[TWEAKEY_BYTES];
+ memcpy(TK_old, TK->TK, sizeof(TK_old));
+
+ /* TODO: homogenize indices; here j=lane; k=byte */
+
+ for (size_t j=0; j<TWEAKEY_BYTES; j+=LANE_BYTES)
+ {
+ for (size_t k=0; k<LANE_BYTES; k++)
+ {
+ TK->TK[j+k] = TK_old[j+h[k]];
+ }
+ }
+}
+
+static void _multiply_state(__attribute__((unused)) tweakey_state *TK)
+{
+}
+
void tweakey_state_update(tweakey_state *TK)
{
fprintf(TK->debug, " Input Tweakey :\n");
_dump_buffer(TK->debug, sizeof(TK->TK), TK->TK, 10);
+
+ _permute_state(TK);
+
fprintf(TK->debug, " Post permutation Tweakey :\n");
_dump_buffer(TK->debug, sizeof(TK->TK), TK->TK, 10);
+
+ _multiply_state(TK);
+
fprintf(TK->debug, " Post multiplication Tweakey :\n");
_dump_buffer(TK->debug, sizeof(TK->TK), TK->TK, 10);
}