diff --git a/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/ref/cipher.c b/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/ref/cipher.c index b6b309e..011bc70 100644 --- a/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/ref/cipher.c +++ b/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/ref/cipher.c @@ -17,6 +17,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ This file provides the implementation for Lilliput-TBC. */ +#include "debug.h" + #include #include @@ -71,33 +73,53 @@ static void _compute_round_tweakeys( uint8_t RTK[ROUNDS][ROUND_TWEAKEY_BYTES] ) { + fprintf(DUMP, "computing %zu round sub-tweakeys\n", (size_t)ROUNDS); + uint8_t TK[TWEAKEY_BYTES]; tweakey_state_init(TK, key, tweak); tweakey_state_extract(TK, 0, RTK[0]); + fprintf(DUMP, " 0\n"); + debug_dump_buffer("RTK", ROUND_TWEAKEY_BYTES, RTK[0], 8); + for (size_t i=1; i #include @@ -51,10 +53,16 @@ void tweakey_state_extract( { const uint8_t *TKj = TK + j*LANE_BYTES; + fprintf(DUMP, " XORing lane %zu/%zu\n", 1+j, (size_t)LANES_NB); + debug_dump_buffer("RTK", ROUND_TWEAKEY_BYTES, round_tweakey, 12); + debug_dump_buffer("lane[j]", LANE_BYTES, TKj, 12); + for (size_t k=0; k RTK", ROUND_TWEAKEY_BYTES, round_tweakey, 12); } round_tweakey[0] ^= round_constant; @@ -73,6 +81,10 @@ static const matrix_multiplication ALPHAS[7] = { _multiply_MR3 }; +static char const * const ALPHAS_STR[7] = { + "M", "M²", "M³", "M⁴", "MR", "MR²", "MR³" +}; + void tweakey_state_update(uint8_t TK[TWEAKEY_BYTES]) { @@ -84,5 +96,9 @@ void tweakey_state_update(uint8_t TK[TWEAKEY_BYTES]) memcpy(TKj_old, TKj, LANE_BYTES); ALPHAS[j](TKj_old, TKj); + + fprintf(DUMP, " multiplying lane %zu/%zu by %s\n", 1+j, (size_t)LANES_NB, ALPHAS_STR[j]); + debug_dump_buffer("TK_j^i-1", LANE_BYTES, TKj_old, 12); + debug_dump_buffer("TK_j^i", LANE_BYTES, TKj, 12); } }