diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-12-03 10:47:49 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-12-03 10:54:22 +0100 |
| commit | e13590a378d947527da943c3f7876af5b1bd81b1 (patch) | |
| tree | 2ebddd6cd4e47de527f9d75ab77802da90298195 /src/tweakey.c | |
| parent | 8a8950699eb8bb9cd29311d32d003431a4472ae4 (diff) | |
| download | lilliput-ae-implem-e13590a378d947527da943c3f7876af5b1bd81b1.tar.xz | |
Suppression des structures (tweakey|cipher)_state
Pas l'impression que l'utilisation de structures dans les codes de
référence soit très idiomatique.
Diffstat (limited to 'src/tweakey.c')
| -rw-r--r-- | src/tweakey.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/tweakey.c b/src/tweakey.c index 7c66ee9..761ec53 100644 --- a/src/tweakey.c +++ b/src/tweakey.c @@ -12,25 +12,25 @@ void tweakey_state_init( - tweakey_state *TK, + uint8_t TK[TWEAKEY_BYTES], const uint8_t key[KEY_BYTES], const uint8_t tweak[TWEAK_BYTES] ) { - memcpy(TK->TK, tweak, TWEAK_BYTES); - memcpy(TK->TK+TWEAK_BYTES, key, KEY_BYTES); + memcpy(TK, tweak, TWEAK_BYTES); + memcpy(TK+TWEAK_BYTES, key, KEY_BYTES); } void tweakey_state_extract( - const tweakey_state *TK, - uint8_t round_tweakey[ROUND_TWEAKEY_BYTES], /* output */ - uint8_t i /* round constant */ + const uint8_t TK[TWEAKEY_BYTES], + uint8_t round_constant, + uint8_t round_tweakey[ROUND_TWEAKEY_BYTES] ) { memset(round_tweakey, 0, ROUND_TWEAKEY_BYTES); - for (const uint8_t *lane=TK->TK; lane<TK->TK+TWEAKEY_BYTES; lane+=LANE_BYTES) + for (const uint8_t *lane=TK; lane<TK+TWEAKEY_BYTES; lane+=LANE_BYTES) { for (size_t j=0; j<LANE_BYTES; j++) { @@ -38,25 +38,25 @@ void tweakey_state_extract( } } - round_tweakey[0] ^= i; + round_tweakey[0] ^= round_constant; } -static void _permute_state(tweakey_state *TK) +static void _permute_state(uint8_t TK[TWEAKEY_BYTES]) { uint8_t TK_old[TWEAKEY_BYTES]; - memcpy(TK_old, TK->TK, sizeof(TK_old)); + memcpy(TK_old, TK, TWEAKEY_BYTES); for (size_t j=0; j<TWEAKEY_BYTES; j+=LANE_BYTES) { for (size_t k=0; k<LANE_BYTES; k++) { - TK->TK[j+h[k]] = TK_old[j+k]; + TK[j+h[k]] = TK_old[j+k]; } } } -static void _multiply_state(tweakey_state *TK) +static void _multiply_state(uint8_t TK[TWEAKEY_BYTES]) { /* Lane 0 is multiplied by Id; lane 1 by P_0, lane 2 by P_1... */ @@ -67,12 +67,12 @@ static void _multiply_state(tweakey_state *TK) for (size_t k=0; k<LANE_BYTES; k++) { size_t offset = j*LANE_BYTES + k; - TK->TK[offset] = P_lane[TK->TK[offset]]; + TK[offset] = P_lane[TK[offset]]; } } } -void tweakey_state_update(tweakey_state *TK) +void tweakey_state_update(uint8_t TK[TWEAKEY_BYTES]) { _permute_state(TK); _multiply_state(TK); |
