lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

commit 825deaadada2e2e615fdc3dd0bcb728249d16c0f
parent 715ca44396acc009ed57f904d523fcc72031b4d3
Author: Kévin Le Gouguec <kevin.legouguec@airbus.com>
Date:   Tue, 20 Nov 2018 15:53:29 +0100

Implémentation de la permutation du tweakey

… Et bien sûr, les résultats divergent. E.g. pour le vecteur random :

           Post permutation Tweakey :
-               b4     16     73     a9     ae     56     44     ca
-               f3     d1     19     a2     f1     00     13     28
-               25     0e     90     39     33     c5     28     33
-               d2     ff     52     a5     12     73     5b     19
-               26     04     0b     cf     2d     5e     d4     4c
+               b4     73     ae     44     16     ca     a9     56
+               f3     19     f1     13     d1     28     a2     00
+               25     90     33     28     0e     33     39     c5
+               d2     52     12     5b     ff     19     a5     73
+               26     0b     2d     d4     04     4c     cf     5e

Diffstat:
Mcrypto_aead/lilliputaei128v1/ref/Makefile | 5+++--
Acrypto_aead/lilliputaei128v1/ref/constants.c | 6++++++
Acrypto_aead/lilliputaei128v1/ref/constants.h | 4++++
Mcrypto_aead/lilliputaei128v1/ref/tweakey.c | 27+++++++++++++++++++++++++++
4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/crypto_aead/lilliputaei128v1/ref/Makefile b/crypto_aead/lilliputaei128v1/ref/Makefile @@ -17,7 +17,7 @@ results/%.o: %.c results/test-%: results/test/%.o -results/test-tweakey: results/test/tweakey.o results/tweakey.o | results +results/test-tweakey: results/test/tweakey.o results/tweakey.o results/constants.o | results gcc $^ $(nist_flags) -Werror -o $@ test-tweakey: results/test-tweakey @@ -27,6 +27,7 @@ test-tweakey: results/test-tweakey results/test-tweakey.o: tweakey.h -results/tweakey.o: tweakey.h +results/tweakey.o: tweakey.h constants.h +results/constants.o: constants.h # TODO: add valgrind diff --git a/crypto_aead/lilliputaei128v1/ref/constants.c b/crypto_aead/lilliputaei128v1/ref/constants.c @@ -0,0 +1,6 @@ +#include "constants.h" + + +const uint8_t h[8] = { + 4, 0, 1, 5, 2, 6, 3, 7 +}; diff --git a/crypto_aead/lilliputaei128v1/ref/constants.h b/crypto_aead/lilliputaei128v1/ref/constants.h @@ -0,0 +1,4 @@ +#include <stdint.h> + + +extern const uint8_t h[8]; diff --git 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); }