From fe1e17321f5304b32d4f9423ff22749294e5db9a Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 21 Nov 2018 17:00:53 +0100 Subject: Ajout de traces pour cipher.c (fin) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus qu'à implémenter maintenant. --- crypto_aead/lilliputaei128v1/ref/cipher.c | 35 +++++++++++++++++++++++-------- 1 file 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 /* debug */ #include -#include #include /* debug */ #include @@ -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