summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-21 13:57:26 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-21 13:57:26 +0100
commitc1a5a0614b78a30405626847dd32e442f34b48ac (patch)
treea514243d8800dd9170814862386855562c8ae48c
parent0a03ddd9b31a6eef5419e20d11d50bdc99443307 (diff)
downloadlilliput-ae-implem-c1a5a0614b78a30405626847dd32e442f34b48ac.tar.xz
Nettoyage divers
Notamment de la partie debug du tweakey, pour permettre de ne pas polluer la sortie des autres tests.
-rw-r--r--[-rwxr-xr-x]crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_order.txt (renamed from crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/lilliputTBCEnc_order.txt)0
-rw-r--r--[-rwxr-xr-x]crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_random.txt (renamed from crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/lilliputTBCEnc_random.txt)0
-rw-r--r--crypto_aead/lilliputaei128v1/ref/tweakey.c36
-rw-r--r--crypto_aead/lilliputaei128v1/ref/tweakey.h1
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
index 586078f..586078f 100755..100644
--- 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
index ab77e18..ab77e18 100755..100644
--- 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
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; 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
index deff35f..76e95db 100644
--- 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>