diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-11-21 17:00:53 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-11-21 17:01:08 +0100 |
| commit | fe1e17321f5304b32d4f9423ff22749294e5db9a (patch) | |
| tree | f57664d374af2f8e95bdd02d9887eae90f3e2026 /crypto_aead/lilliputaei128v1/ref | |
| parent | 274dd55a024b8f06ca6cd53247a044ebc1239be4 (diff) | |
| download | lilliput-ae-implem-fe1e17321f5304b32d4f9423ff22749294e5db9a.tar.xz | |
Ajout de traces pour cipher.c (fin)
Plus qu'à implémenter maintenant.
Diffstat (limited to 'crypto_aead/lilliputaei128v1/ref')
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/cipher.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/cipher.c b/crypto_aead/lilliputaei128v1/ref/cipher.c index 31f7f02..aa51bf8 100644 --- a/crypto_aead/lilliputaei128v1/ref/cipher.c +++ b/crypto_aead/lilliputaei128v1/ref/cipher.c @@ -1,5 +1,5 @@ +#include <inttypes.h> /* debug */ #include <stdbool.h> -#include <stdint.h> #include <stdio.h> /* debug */ #include <string.h> @@ -10,6 +10,16 @@ #include "debug.h" +static void _debug_announce_round(FILE* debug, uint8_t i) +{ + if (!debug) + return; + fprintf(debug, "\n"); + fprintf(debug, "One round EGFN round : %"PRIu8"\n", i); + fprintf(debug, " State :\n"); +} + + enum permutation { PERMUTATION_ENCRYPTION = 0, @@ -64,22 +74,29 @@ static void _compute_round_tweakeys( } -static void _nonlinear_layer(__attribute__((unused)) cipher_state *X, __attribute__((unused)) const uint8_t RTK[ROUND_TWEAKEY_BYTES]) +static void _nonlinear_layer(cipher_state *X, const uint8_t RTK[ROUND_TWEAKEY_BYTES]) { - + 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); + debug_dump_buffer(X->debug, " State non linearized :", sizeof(X->X), X->X, 10); } -static void _linear_layer(__attribute__((unused)) cipher_state *X) +static void _linear_layer(cipher_state *X) { - + debug_dump_buffer(X->debug, " Linear Layer :", sizeof(X->X), X->X, 10); + debug_dump_buffer(X->debug, " State linearized :", sizeof(X->X), X->X, 10); } -static void _permutation_layer(__attribute__((unused)) cipher_state *X, permutation p) +static void _permutation_layer(cipher_state *X, permutation p) { if (p == PERMUTATION_NONE) { return; } + debug_dump_buffer(X->debug, " Permutation Layer :", sizeof(X->X), X->X, 10); + debug_dump_buffer(X->debug, " State permuted :", sizeof(X->X), X->X, 10); } static void _one_round_egfn(cipher_state *X, const uint8_t RTK[ROUND_TWEAKEY_BYTES], permutation p) @@ -101,7 +118,6 @@ void lilliput_tbc_encrypt( debug_dump_lanes(debug, "Tweak :", TWEAK_BYTES, tweak, 0); debug_dump_lanes(debug, "Key :", KEY_BYTES, key, 0); debug_dump_buffer(debug, "Message :", BLOCK_BYTES, message, 0); - fprintf(debug, "\n"); cipher_state X; _state_init(&X, message, debug); @@ -111,15 +127,16 @@ void lilliput_tbc_encrypt( for (uint8_t i=0; i<ROUNDS-1; i++) { + _debug_announce_round(debug, i); _one_round_egfn(&X, RTK[i], PERMUTATION_ENCRYPTION); } + _debug_announce_round(debug, ROUNDS-1); _one_round_egfn(&X, RTK[ROUNDS-1], PERMUTATION_NONE); memcpy(ciphertext, X.X, BLOCK_BYTES); - debug_dump_buffer(debug, "Ciphertext :", BLOCK_BYTES, ciphertext, 0); - + debug_dump_buffer(debug, "\nCiphertext :", BLOCK_BYTES, ciphertext, 0); } void lilliput_tbc_decrypt( |
