summaryrefslogtreecommitdiff
path: root/crypto_aead/lilliputaei128v1/ref/tweakey.c
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-21 14:58:36 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2018-11-21 14:58:36 +0100
commit8e50f73f7d597d5de84db82d82c829223d59ae1f (patch)
treed1b57b44ac4eff67f32b760d811787b6aea02306 /crypto_aead/lilliputaei128v1/ref/tweakey.c
parent2c90f8474502559c4314c2e02a4ea76b21ff9509 (diff)
downloadlilliput-ae-implem-8e50f73f7d597d5de84db82d82c829223d59ae1f.tar.xz
Extraction du code de debug de tweakey.c dans un entête
Pour que cipher.c puisse s'en servir.
Diffstat (limited to 'crypto_aead/lilliputaei128v1/ref/tweakey.c')
-rw-r--r--crypto_aead/lilliputaei128v1/ref/tweakey.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/tweakey.c b/crypto_aead/lilliputaei128v1/ref/tweakey.c
index dc8064a..4310dc5 100644
--- a/crypto_aead/lilliputaei128v1/ref/tweakey.c
+++ b/crypto_aead/lilliputaei128v1/ref/tweakey.c
@@ -6,37 +6,14 @@
#include "parameters.h"
#include "tweakey.h"
+#include "debug.h"
+
#define LANE_BITS 64
#define LANE_BYTES (LANE_BITS/8)
#define LANES_NB (TWEAKEY_BYTES/LANE_BYTES)
-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, "");
- for (size_t b=0; b<8; b++)
- {
- /* start with MSB */
- size_t byte_index = len-(1+line*8+b);
- fprintf(output, "%*s", 5, "");
- fprintf(output, "%02x", buf[byte_index]);
- }
- fprintf(output, "\n");
- }
- fprintf(output, "\n");
-}
-
-
void tweakey_state_init(
tweakey_state *TK,
const uint8_t key[KEY_BYTES],
@@ -48,9 +25,9 @@ void tweakey_state_init(
memcpy(TK->TK+TWEAK_BYTES, key, KEY_BYTES);
TK->debug = debug;
- _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);
+ debug_dump_buffer(debug, " Tweak is :", TWEAK_BYTES, tweak, 5);
+ debug_dump_buffer(debug, " Key is :", KEY_BYTES, key, 5);
+ debug_dump_buffer(debug, " Tweakey is :", sizeof(TK->TK), TK->TK, 5);
}
@@ -74,8 +51,8 @@ void tweakey_state_extract(
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);
+ debug_dump_buffer(TK->debug, debug, sizeof(TK->TK), TK->TK, 5);
+ debug_dump_buffer(TK->debug, " Subtweakey :", ROUND_TWEAKEY_BYTES, round_tweakey, 5);
}
@@ -115,13 +92,13 @@ static void _multiply_state(tweakey_state *TK)
void tweakey_state_update(tweakey_state *TK)
{
- _dump_buffer(TK->debug, " Input Tweakey :", sizeof(TK->TK), TK->TK, 10);
+ debug_dump_buffer(TK->debug, " Input Tweakey :", sizeof(TK->TK), TK->TK, 10);
_permute_state(TK);
- _dump_buffer(TK->debug, " Post permutation Tweakey :", sizeof(TK->TK), TK->TK, 10);
+ debug_dump_buffer(TK->debug, " Post permutation Tweakey :", sizeof(TK->TK), TK->TK, 10);
_multiply_state(TK);
- _dump_buffer(TK->debug, " Post multiplication Tweakey :", sizeof(TK->TK), TK->TK, 10);
+ debug_dump_buffer(TK->debug, " Post multiplication Tweakey :", sizeof(TK->TK), TK->TK, 10);
}