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 | |
| 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')
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/cipher.c | 23 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/constants.c | 35 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/constants.h | 2 |
3 files changed, 58 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); } diff --git a/crypto_aead/lilliputaei128v1/ref/constants.c b/crypto_aead/lilliputaei128v1/ref/constants.c index 48fc107..350021c 100644 --- a/crypto_aead/lilliputaei128v1/ref/constants.c +++ b/crypto_aead/lilliputaei128v1/ref/constants.c @@ -211,3 +211,38 @@ const uint8_t P[6][256] = { 77, 154, 232, 63, 171, 124, 14, 217 }, }; + +const uint8_t S[256] = { + 32, 0, 178, 133, 51, 53, 166, 18, + 48, 138, 106, 100, 185, 31, 84, 14, + 248, 150, 122, 6, 21, 189, 62, 177, + 232, 197, 162, 194, 218, 87, 12, 216, + 33, 1, 35, 190, 92, 36, 39, 131, + 111, 199, 43, 89, 104, 210, 119, 95, + 55, 9, 5, 135, 4, 130, 49, 250, + 57, 98, 157, 81, 145, 116, 97, 23, + 242, 78, 96, 175, 221, 71, 68, 228, + 226, 236, 168, 74, 191, 173, 182, 64, + 58, 152, 184, 192, 107, 15, 28, 251, + 42, 239, 112, 124, 208, 37, 46, 214, + 63, 67, 205, 56, 126, 10, 121, 217, + 113, 45, 85, 11, 114, 108, 41, 237, + 105, 91, 123, 109, 230, 60, 47, 156, + 103, 148, 115, 19, 215, 90, 127, 101, + 132, 164, 38, 52, 2, 129, 50, 134, + 165, 198, 174, 8, 141, 195, 229, 202, + 61, 183, 207, 146, 161, 120, 155, 16, + 204, 80, 151, 247, 59, 118, 224, 169, + 149, 181, 167, 27, 137, 128, 163, 7, + 158, 75, 255, 245, 76, 206, 66, 139, + 22, 220, 180, 3, 160, 179, 144, 79, + 13, 83, 252, 240, 20, 241, 77, 34, + 238, 82, 140, 26, 24, 203, 40, 136, + 211, 200, 196, 142, 99, 153, 147, 172, + 219, 93, 201, 44, 231, 254, 125, 94, + 102, 30, 209, 29, 69, 176, 234, 243, + 227, 159, 225, 73, 143, 70, 213, 117, + 244, 25, 249, 223, 110, 72, 88, 193, + 188, 186, 222, 65, 170, 233, 154, 253, + 235, 17, 86, 54, 246, 187, 171, 212 +}; diff --git a/crypto_aead/lilliputaei128v1/ref/constants.h b/crypto_aead/lilliputaei128v1/ref/constants.h index 123204a..ec1da94 100644 --- a/crypto_aead/lilliputaei128v1/ref/constants.h +++ b/crypto_aead/lilliputaei128v1/ref/constants.h @@ -9,3 +9,5 @@ extern const uint8_t h[8]; /* Tweakey multiplication */ extern const uint8_t P[6][256]; +/* Lilliput S-box */ +extern const uint8_t S[256]; |
