From 0ba0dda345c2280ebebe67ecaaa6179330b5cb01 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 27 Nov 2018 08:07:38 +0100 Subject: Suppression du code de debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avec debug.h, il devrait être facile d'ajouter des traces en cas de besoin. --- crypto_aead/lilliputaei128v1/ref/cipher.c | 63 ++++--------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) (limited to 'crypto_aead/lilliputaei128v1/ref/cipher.c') diff --git a/crypto_aead/lilliputaei128v1/ref/cipher.c b/crypto_aead/lilliputaei128v1/ref/cipher.c index 6c9302b..7f1152a 100644 --- a/crypto_aead/lilliputaei128v1/ref/cipher.c +++ b/crypto_aead/lilliputaei128v1/ref/cipher.c @@ -1,6 +1,4 @@ -#include /* debug */ -#include -#include /* debug */ +#include #include #include "cipher.h" @@ -8,18 +6,6 @@ #include "parameters.h" #include "tweakey.h" -#include "debug.h" - - -static void _debug_announce_round(FILE* debug, uint8_t i) -{ - if (!debug) - return; - fprintf(debug, "\n"); - fprintf(debug, "One round EGFN round : %"PRIu8"\n", i); - fprintf(debug, " State :\n"); -} - enum permutation { @@ -43,17 +29,15 @@ const uint8_t PERMUTATIONS[2][BLOCK_BYTES] = { struct cipher_state { uint8_t X[BLOCK_BYTES]; - FILE* debug; }; typedef struct cipher_state cipher_state; -static void _state_init(cipher_state *X, const uint8_t message[BLOCK_BYTES], FILE* debug) +static void _state_init(cipher_state *X, const uint8_t message[BLOCK_BYTES]) { memcpy(X->X, message, sizeof(X->X)); - X->debug = debug; } @@ -64,7 +48,7 @@ static void _compute_round_tweakeys( ) { tweakey_state TK; - tweakey_state_init(&TK, key, tweak, NULL); + tweakey_state_init(&TK, key, tweak); tweakey_state_extract(&TK, RTK[0], 0); for (uint8_t i=1; idebug, " Non Linear Layer :", sizeof(X->X), X->X, 10); - debug_dump_buffer(X->debug, " Subtweakey :", ROUND_TWEAKEY_BYTES, RTK, 66); - uint8_t F[ROUND_TWEAKEY_BYTES]; for (size_t j=0; jX[j] ^ RTK[j]; } - debug_dump_buffer(X->debug, " Variables xored :", sizeof(F), F, 66); for (size_t j=0; jdebug, " Variables sboxed :", sizeof(F), F, 66); for (size_t j=0; j<8; j++) { size_t dest_j = 15-j; X->X[dest_j] ^= F[j]; } - - debug_dump_buffer(X->debug, " State non linearized :", sizeof(X->X), X->X, 10); } static void _linear_layer(cipher_state *X) { - debug_dump_buffer(X->debug, " Linear Layer :", sizeof(X->X), X->X, 10); - X->X[15] ^= X->X[1]; X->X[15] ^= X->X[2]; X->X[15] ^= X->X[3]; @@ -120,8 +95,6 @@ static void _linear_layer(cipher_state *X) X->X[11] ^= X->X[7]; X->X[10] ^= X->X[7]; X->X[9] ^= X->X[7]; - - debug_dump_buffer(X->debug, " State linearized :", sizeof(X->X), X->X, 10); } static void _permutation_layer(cipher_state *X, permutation p) @@ -131,8 +104,6 @@ static void _permutation_layer(cipher_state *X, permutation p) return; } - debug_dump_buffer(X->debug, " Permutation Layer :", sizeof(X->X), X->X, 10); - uint8_t X_old[BLOCK_BYTES]; memcpy(X_old, X, sizeof(X_old)); @@ -142,8 +113,6 @@ static void _permutation_layer(cipher_state *X, permutation p) { X->X[pi[j]] = X_old[j]; } - - debug_dump_buffer(X->debug, " State permuted :", sizeof(X->X), X->X, 10); } static void _one_round_egfn(cipher_state *X, const uint8_t RTK[ROUND_TWEAKEY_BYTES], permutation p) @@ -158,62 +127,44 @@ void lilliput_tbc_encrypt( const uint8_t key[KEY_BYTES], const uint8_t tweak[TWEAK_BYTES], const uint8_t message[BLOCK_BYTES], - uint8_t ciphertext[BLOCK_BYTES], - FILE *debug + uint8_t ciphertext[BLOCK_BYTES] ) { - 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); - cipher_state X; - _state_init(&X, message, debug); + _state_init(&X, message); uint8_t RTK[ROUNDS][ROUND_TWEAKEY_BYTES]; _compute_round_tweakeys(key, tweak, RTK); for (uint8_t i=0; i