From 715ca44396acc009ed57f904d523fcc72031b4d3 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 20 Nov 2018 15:18:37 +0100 Subject: Implémentation de l'extraction du tweakey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypto_aead/lilliputaei128v1/ref/tweakey.c | 40 +++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'crypto_aead/lilliputaei128v1/ref/tweakey.c') diff --git a/crypto_aead/lilliputaei128v1/ref/tweakey.c b/crypto_aead/lilliputaei128v1/ref/tweakey.c index 79fa225..173f4be 100644 --- a/crypto_aead/lilliputaei128v1/ref/tweakey.c +++ b/crypto_aead/lilliputaei128v1/ref/tweakey.c @@ -1,8 +1,14 @@ +#include #include +#include /* debug */ #include "tweakey.h" +#define LANE_BITS 64 +#define LANE_BYTES (LANE_BITS/8) + + static void _dump_buffer(FILE *output, size_t len, const uint8_t buf[len], int indent) { for (size_t line=0; lineTK, tweak, TWEAK_BYTES); 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"); @@ -41,16 +49,36 @@ void tweakey_state_init( void tweakey_state_extract( - __attribute__((unused)) const tweakey_state *TK, - __attribute__((unused)) uint8_t round_tweakey[ROUND_TWEAKEY_BYTES], /* output */ - __attribute__((unused)) uint8_t i /* round constant */ + const tweakey_state *TK, + uint8_t round_tweakey[ROUND_TWEAKEY_BYTES], /* output */ + uint8_t i /* round constant */ ) { - + memset(round_tweakey, 0, ROUND_TWEAKEY_BYTES); + + for (const uint8_t *lane=TK->TK; laneTK+TWEAKEY_BYTES; lane+=LANE_BYTES) + { + for (size_t j=0; jdebug, " 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); } -void tweakey_state_update(__attribute__((unused)) 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); + fprintf(TK->debug, " Post permutation Tweakey :\n"); + _dump_buffer(TK->debug, sizeof(TK->TK), TK->TK, 10); + fprintf(TK->debug, " Post multiplication Tweakey :\n"); + _dump_buffer(TK->debug, sizeof(TK->TK), TK->TK, 10); } -- cgit v1.2.3