From dbae7afbbc13c39f167bad9c2d72d5d670c06c83 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 13 Feb 2019 14:02:28 +0100 Subject: Renommage des fichiers implémentant les modes AE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour qu'ils soient plus proches du nom donné dans la spécification. --- src/ref/lilliput-i.c | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 src/ref/lilliput-i.c (limited to 'src/ref/lilliput-i.c') diff --git a/src/ref/lilliput-i.c b/src/ref/lilliput-i.c new file mode 100644 index 0000000..5e91e4e --- /dev/null +++ b/src/ref/lilliput-i.c @@ -0,0 +1,212 @@ +/* +Implementation of the Lilliput-AE tweakable block cipher. + +Author: Kévin Le Gouguec, 2019. + +For more information, feedback or questions, refer to our website: +https://paclido.fr/lilliput-ae + +To the extent possible under law, the implementer has waived all copyright +and related or neighboring rights to the source code in this file. +http://creativecommons.org/publicdomain/zero/1.0/ + +--- + +This file implements Lilliput-AE's nonce-respecting mode based on ΘCB3. +*/ + +#include +#include +#include + +#include "cipher.h" +#include "lilliput-ae.h" +#include "lilliput-ae-utils.h" + + +static const uint8_t _0n[BLOCK_BYTES] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + + +static void _fill_msg_tweak( + uint8_t prefix, + const uint8_t N[NONCE_BYTES], + uint64_t block_nb, + uint8_t tweak[TWEAK_BYTES] +) +{ + /* The 192-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 + */ + + for (size_t i=0; i> 8*i; + + tweak[i] = b; + } + + tweak[sizeof(block_nb)] = lower_nibble(N[0]) << 4; + + for (size_t i=1; i