From c1a5a0614b78a30405626847dd32e442f34b48ac Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 21 Nov 2018 13:57:26 +0100 Subject: Nettoyage divers Notamment de la partie debug du tweakey, pour permettre de ne pas polluer la sortie des autres tests. --- crypto_aead/lilliputaei128v1/ref/tweakey.c | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'crypto_aead/lilliputaei128v1/ref/tweakey.c') diff --git a/crypto_aead/lilliputaei128v1/ref/tweakey.c b/crypto_aead/lilliputaei128v1/ref/tweakey.c index 6f5c6d3..dc8064a 100644 --- a/crypto_aead/lilliputaei128v1/ref/tweakey.c +++ b/crypto_aead/lilliputaei128v1/ref/tweakey.c @@ -12,8 +12,15 @@ #define LANES_NB (TWEAKEY_BYTES/LANE_BYTES) -static void _dump_buffer(FILE *output, size_t len, const uint8_t buf[len], int indent) +static void _dump_buffer(FILE *output, const char *header, size_t len, const uint8_t buf[len], int indent) { + if (!output) + { + return; + } + + fprintf(output, "%s\n", header); + for (size_t line=0; lineTK+TWEAK_BYTES, key, KEY_BYTES); TK->debug = debug; - - fprintf(debug, " Tweak is :\n"); - _dump_buffer(debug, TWEAK_BYTES, tweak, 5); - fprintf(debug, " Key is :\n"); - _dump_buffer(debug, KEY_BYTES, key, 5); - fprintf(debug, " Tweakey is :\n"); - _dump_buffer(debug, sizeof(TK->TK), TK->TK, 5); + _dump_buffer(debug, " Tweak is :", TWEAK_BYTES, tweak, 5); + _dump_buffer(debug, " Key is :", KEY_BYTES, key, 5); + _dump_buffer(debug, " Tweakey is :", sizeof(TK->TK), TK->TK, 5); } @@ -69,10 +72,10 @@ void tweakey_state_extract( round_tweakey[0] ^= i; - fprintf(TK->debug, " Extracting Subtweakey round %"PRIu8"\n", i); - _dump_buffer(TK->debug, sizeof(TK->TK), TK->TK, 5); - fprintf(TK->debug, " Subtweakey :\n"); - _dump_buffer(TK->debug, ROUND_TWEAKEY_BYTES, round_tweakey, 5); + char debug[512]; + snprintf(debug, sizeof(debug), " Extracting Subtweakey round %"PRIu8, i); + _dump_buffer(TK->debug, debug, sizeof(TK->TK), TK->TK, 5); + _dump_buffer(TK->debug, " Subtweakey :", ROUND_TWEAKEY_BYTES, round_tweakey, 5); } @@ -112,16 +115,13 @@ static void _multiply_state(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); + _dump_buffer(TK->debug, " Input Tweakey :", 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); + _dump_buffer(TK->debug, " Post permutation Tweakey :", 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); + _dump_buffer(TK->debug, " Post multiplication Tweakey :", sizeof(TK->TK), TK->TK, 10); } -- cgit v1.2.3