From 8d46de55be9fce55b297915e7086f77ceaab6f19 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 21 Nov 2018 16:34:25 +0100 Subject: Ajout de traces pour cipher.c (début) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémentation de test-cipher.c en passant. --- crypto_aead/lilliputaei128v1/ref/cipher.c | 10 ++++++ crypto_aead/lilliputaei128v1/ref/debug.h | 19 +++++++++++ crypto_aead/lilliputaei128v1/ref/test/helpers.h | 10 ------ .../ref/test/test-cipher-ref/cipher_order.txt | 12 +++---- .../ref/test/test-cipher-ref/cipher_random.txt | 12 +++---- .../lilliputaei128v1/ref/test/test-cipher.c | 37 ++++++++++++++++++++-- .../lilliputaei128v1/ref/test/test-tweakey.c | 10 +++++- 7 files changed, 85 insertions(+), 25 deletions(-) (limited to 'crypto_aead/lilliputaei128v1') diff --git a/crypto_aead/lilliputaei128v1/ref/cipher.c b/crypto_aead/lilliputaei128v1/ref/cipher.c index dba7e90..31f7f02 100644 --- a/crypto_aead/lilliputaei128v1/ref/cipher.c +++ b/crypto_aead/lilliputaei128v1/ref/cipher.c @@ -7,6 +7,8 @@ #include "parameters.h" #include "tweakey.h" +#include "debug.h" + enum permutation { @@ -96,6 +98,11 @@ void lilliput_tbc_encrypt( FILE *debug ) { + 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); @@ -110,6 +117,9 @@ void lilliput_tbc_encrypt( _one_round_egfn(&X, RTK[ROUNDS-1], PERMUTATION_NONE); memcpy(ciphertext, X.X, BLOCK_BYTES); + + debug_dump_buffer(debug, "Ciphertext :", BLOCK_BYTES, ciphertext, 0); + } void lilliput_tbc_decrypt( diff --git a/crypto_aead/lilliputaei128v1/ref/debug.h b/crypto_aead/lilliputaei128v1/ref/debug.h index e107019..934a287 100644 --- a/crypto_aead/lilliputaei128v1/ref/debug.h +++ b/crypto_aead/lilliputaei128v1/ref/debug.h @@ -26,3 +26,22 @@ static inline void debug_dump_lanes(FILE *output, const char *header, size_t len } fprintf(output, "\n"); } + +static inline void debug_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); + + fprintf(output, "%*s", indent, ""); + for (size_t b=0; bname); + FILE* dump = open_dump_file(argv[1], "cipher", input->name); + + uint8_t ciphertext[BLOCK_BYTES]; + lilliput_tbc_encrypt(input->key, input->tweak, input->message, ciphertext, dump); + + fclose(dump); + } } diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c b/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c index 8449ea4..2d3ef0d 100644 --- a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c +++ b/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c @@ -6,9 +6,17 @@ #include "helpers.h" -/* [0]: LSB */ +struct vector_input +{ + char * name; + uint8_t key[KEY_BYTES]; + uint8_t tweak[TWEAK_BYTES]; +}; +typedef struct vector_input vector_input; + +/* [0]: LSB */ vector_input VECTORS[] = { { .name = "full", -- cgit v1.2.3