From 3bb63d96b61e9e17108320efd89088d1f08b495a Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 30 Apr 2019 15:41:59 +0200 Subject: Homogénéisation de la gestion de l'index de bloc dans les tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - "block number" → "block index" - "192" → "t" - boucle de copie de l'index - utilisation de size_t : - par définition, aucune implémentation ne pourra traiter plus d'octets que SIZE_MAX (donc pas plus de blocs), - pas de raison de forcer un index de 64 bits sur ces pauvres ATmega et MSP430. --- src/ref/lilliput-i.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/ref/lilliput-i.c') diff --git a/src/ref/lilliput-i.c b/src/ref/lilliput-i.c index 97c2117..3ba7ea2 100644 --- a/src/ref/lilliput-i.c +++ b/src/ref/lilliput-i.c @@ -35,32 +35,26 @@ static const uint8_t _0n[BLOCK_BYTES] = { static void _fill_msg_tweak( uint8_t prefix, const uint8_t N[NONCE_BYTES], - uint64_t block_nb, + size_t block_index, uint8_t tweak[TWEAK_BYTES] ) { - /* The 192-bit tweak is filled as follows: + /* With an s-bit block index, the t-bit tweak is filled as follows: * - * - bits 1- 68: block number - * 1- 64: actual 64-bit block number - * 64- 68: 0-padding - * - bits 67-188: nonce - * - bits 189-192: constant 4-bit prefix + * - bits [ 1, t-|N|-4]: block index + * [ 1, s]: actual 64-bit block index + * [ s+1, t-|N|-4]: 0-padding + * - bits [t-|N|-4, t-4]: nonce + * - bits [ t-3, t]: 4-bit prefix */ - for (size_t i=0; i> 8*i; - - tweak[i] = b; - } + copy_block_index(block_index, tweak); - tweak[sizeof(block_nb)] = lower_nibble(N[0]) << 4; + tweak[sizeof(block_index)] = lower_nibble(N[0]) << 4; for (size_t i=1; i