diff --git a/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/cipher.c b/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/cipher.c index 4190359..822f374 100644 --- a/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/cipher.c +++ b/SOUMISSION_NIST/REFERENCE_IMPLEMENTATION/src/cipher.c @@ -1,3 +1,5 @@ +#include "debug.h" + #include #include @@ -38,40 +40,61 @@ 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 (uint8_t i=1; i #include @@ -32,10 +34,16 @@ void tweakey_state_extract( for (const uint8_t *lane=TK; lane RTK", ROUND_TWEAKEY_BYTES, round_tweakey, 12); } round_tweakey[0] ^= round_constant; @@ -44,6 +52,8 @@ void tweakey_state_extract( static void _permute_state(uint8_t TK[TWEAKEY_BYTES]) { + fprintf(DUMP, " permuting TK\n"); + uint8_t TK_old[TWEAKEY_BYTES]; memcpy(TK_old, TK, TWEAKEY_BYTES); @@ -54,12 +64,19 @@ static void _permute_state(uint8_t TK[TWEAKEY_BYTES]) TK[j+h[k]] = TK_old[j+k]; } } + + debug_dump_buffer("TKi-1", TWEAKEY_BYTES, TK_old, 12); + debug_dump_buffer("TKi", TWEAKEY_BYTES, TK, 12); } static void _multiply_state(uint8_t TK[TWEAKEY_BYTES]) { + fprintf(DUMP, " multiplying TK\n"); + /* Lane 0 is multiplied by Id; lane 1 by P_0, lane 2 by P_1... */ + debug_dump_buffer("TKi-1", TWEAKEY_BYTES, TK, 12); + for (size_t j=1; j