From 949fb3df2f18173b579ef3417d82581d48cf495f Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Fri, 3 May 2019 15:05:32 +0200 Subject: Ajustement de la gestion du nonce pour ΘCB3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout du nonce dans le tweak une bonne fois pour toute à l'initialisation de l'algorithme, au lieu de le rajouter à chaque tour de boucle. Similaire à notre implémentation de SCT-2, et à l'implémentation de référence de Deoxys-I. --- src/ref/lilliput-i.c | 67 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 21 deletions(-) (limited to 'src/ref') diff --git a/src/ref/lilliput-i.c b/src/ref/lilliput-i.c index 404abea..6f869c3 100644 --- a/src/ref/lilliput-i.c +++ b/src/ref/lilliput-i.c @@ -32,12 +32,7 @@ static const uint8_t _0n[BLOCK_BYTES] = { }; -static void _fill_msg_tweak( - uint8_t prefix, - const uint8_t N[NONCE_BYTES], - size_t block_index, - uint8_t tweak[TWEAK_BYTES] -) +static void _init_msg_tweak(const uint8_t N[NONCE_BYTES], uint8_t tweak[TWEAK_BYTES]) { /* With an s-bit block index, the t-bit tweak is filled as follows: * @@ -46,11 +41,17 @@ static void _fill_msg_tweak( * [ s+1, t-|N|-4]: 0-padding * - bits [t-|N|-3, t-4]: nonce * - bits [ t-3, t]: 4-bit prefix + * + * This function sets bits s+1 to t-4 once and for all. */ - copy_block_index(block_index, tweak); - size_t N_start = TWEAK_BYTES - NONCE_BYTES - 1; + + for (size_t i=sizeof(size_t); i