summaryrefslogtreecommitdiff
path: root/src/add_felicsref/cipher.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/add_felicsref/cipher.c')
-rw-r--r--src/add_felicsref/cipher.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/add_felicsref/cipher.c b/src/add_felicsref/cipher.c
index 59bc5d8..916f0ab 100644
--- a/src/add_felicsref/cipher.c
+++ b/src/add_felicsref/cipher.c
@@ -77,7 +77,7 @@ static void _compute_round_tweakeys(
tweakey_state_init(TK, key, tweak);
tweakey_state_extract(TK, 0, RTK[0]);
- for (uint8_t i=1; i<ROUNDS; i++)
+ for (size_t i=1; i<ROUNDS; i++)
{
tweakey_state_update(TK);
tweakey_state_extract(TK, i, RTK[i]);
@@ -168,18 +168,15 @@ void lilliput_tbc_decrypt(
uint8_t message[BLOCK_BYTES]
)
{
- uint8_t X[BLOCK_BYTES];
- _state_init(X, ciphertext);
+ _state_init(message, ciphertext);
uint8_t RTK[ROUNDS][ROUND_TWEAKEY_BYTES];
_compute_round_tweakeys(key, tweak, RTK);
for (size_t i=0; i<ROUNDS-1; i++)
{
- _one_round_egfn(X, RTK[ROUNDS-1-i], PERMUTATION_DECRYPTION);
+ _one_round_egfn(message, RTK[ROUNDS-1-i], PERMUTATION_DECRYPTION);
}
- _one_round_egfn(X, RTK[0], PERMUTATION_NONE);
-
- memcpy(message, X, BLOCK_BYTES);
+ _one_round_egfn(message, RTK[0], PERMUTATION_NONE);
}