diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-11-21 17:39:25 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-11-21 17:39:25 +0100 |
| commit | fa8bfd4386a86834bf527988c2a05fbf0336f8cb (patch) | |
| tree | 82660c68eb162d4ade75a27dfa46f1f4d7fd5c11 /crypto_aead/lilliputaei128v1/ref/cipher.c | |
| parent | fe1e17321f5304b32d4f9423ff22749294e5db9a (diff) | |
| download | lilliput-ae-implem-fa8bfd4386a86834bf527988c2a05fbf0336f8cb.tar.xz | |
Implémentation de la couche non-linéaire
So far so good.
Diffstat (limited to 'crypto_aead/lilliputaei128v1/ref/cipher.c')
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/cipher.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/cipher.c b/crypto_aead/lilliputaei128v1/ref/cipher.c index aa51bf8..44d22cb 100644 --- a/crypto_aead/lilliputaei128v1/ref/cipher.c +++ b/crypto_aead/lilliputaei128v1/ref/cipher.c @@ -4,6 +4,7 @@ #include <string.h> #include "cipher.h" +#include "constants.h" #include "parameters.h" #include "tweakey.h" @@ -78,8 +79,26 @@ static void _nonlinear_layer(cipher_state *X, const uint8_t RTK[ROUND_TWEAKEY_BY { debug_dump_buffer(X->debug, " Non Linear Layer :", sizeof(X->X), X->X, 10); debug_dump_buffer(X->debug, " Subtweakey :", ROUND_TWEAKEY_BYTES, RTK, 66); - debug_dump_buffer(X->debug, " Variables xored :", ROUND_TWEAKEY_BYTES, RTK, 66); - debug_dump_buffer(X->debug, " Variables sboxed :", ROUND_TWEAKEY_BYTES, RTK, 66); + + uint8_t F[ROUND_TWEAKEY_BYTES]; + for (size_t j=0; j<sizeof(F); j++) + { + F[j] = X->X[j] ^ RTK[j]; + } + debug_dump_buffer(X->debug, " Variables xored :", sizeof(F), F, 66); + + for (size_t j=0; j<sizeof(F); j++) + { + F[j] = S[F[j]]; + } + debug_dump_buffer(X->debug, " Variables sboxed :", sizeof(F), F, 66); + + for (size_t j=0; j<8; j++) + { + size_t dest_j = 15-j; + X->X[dest_j] ^= F[j]; + } + debug_dump_buffer(X->debug, " State non linearized :", sizeof(X->X), X->X, 10); } |
