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 @@ -34,10 +36,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; @@ -46,6 +54,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); @@ -59,10 +69,15 @@ static void _permute_state(uint8_t TK[TWEAKEY_BYTES]) TKj[h[k]] = TKj_old[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"); + /* Each byte in lane 0 is multiplied by alpha_0 = 1, i.e. it * remains unchanged. * @@ -73,6 +88,8 @@ static void _multiply_state(uint8_t TK[TWEAKEY_BYTES]) * P_j = P[j-1]. */ + debug_dump_buffer("TKi-1", TWEAKEY_BYTES, TK, 12); + for (size_t j=1; j