commit c1a5a0614b78a30405626847dd32e442f34b48ac parent 0a03ddd9b31a6eef5419e20d11d50bdc99443307 Author: Kévin Le Gouguec <kevin.legouguec@airbus.com> Date: Wed, 21 Nov 2018 13:57:26 +0100 Nettoyage divers Notamment de la partie debug du tweakey, pour permettre de ne pas polluer la sortie des autres tests. Diffstat:
4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/lilliputTBCEnc_order.txt b/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_order.txt diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/lilliputTBCEnc_random.txt b/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_random.txt diff --git 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; line<len/8; line++) { fprintf(output, "%*s", indent, ""); @@ -41,13 +48,9 @@ void tweakey_state_init( memcpy(TK->TK+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); } diff --git a/crypto_aead/lilliputaei128v1/ref/tweakey.h b/crypto_aead/lilliputaei128v1/ref/tweakey.h @@ -1,6 +1,5 @@ #pragma once -#include <stddef.h> #include <stdio.h> /* debug */ #include <stdint.h>