diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-04-30 15:41:59 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-05-02 10:38:20 +0200 |
| commit | 3bb63d96b61e9e17108320efd89088d1f08b495a (patch) | |
| tree | f6b4fe8c4a4a1f7380122ba049f7a02caf564ade /src/ref/lilliput-ii.c | |
| parent | 8733b59d62ef144d1e1f2a9251217d38b71adaf0 (diff) | |
| download | lilliput-ae-implem-3bb63d96b61e9e17108320efd89088d1f08b495a.tar.xz | |
Homogénéisation de la gestion de l'index de bloc dans les tweaks
- "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.
Diffstat (limited to 'src/ref/lilliput-ii.c')
| -rw-r--r-- | src/ref/lilliput-ii.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ref/lilliput-ii.c b/src/ref/lilliput-ii.c index a371521..6811d49 100644 --- a/src/ref/lilliput-ii.c +++ b/src/ref/lilliput-ii.c @@ -28,37 +28,38 @@ This file implements Lilliput-AE's nonce-misuse-resistant mode based on SCT-2. static void _init_msg_tweak(const uint8_t tag[TAG_BYTES], uint8_t tweak[TWEAK_BYTES]) { - /* The t-bit tweak is filled as follows: + /* With an s-bit block index, the t-bit tweak is filled as follows: * * - bits [ 1, t-1]: tag + block index - * [ 1, 64]: tag[ 1.. 64] XOR block index - * [ 65, t-1]: tag[65..t-1] + * [ 1, s]: tag[1..s] XOR block index + * [s+1, t-1]: tag[s+1..t-1] * - bit t: 1 * - * This function sets bits 65 to t once and for all. + * This function sets bits s+1 to t once and for all. */ - memcpy(tweak+sizeof(uint64_t), tag+sizeof(uint64_t), TAG_BYTES-sizeof(uint64_t)); + memcpy(tweak+sizeof(size_t), tag+sizeof(size_t), TAG_BYTES-sizeof(size_t)); tweak[TWEAK_BYTES-1] |= 0x80; } -static void _fill_msg_tweak(const uint8_t tag[TAG_BYTES], uint64_t block_index, uint8_t tweak[TWEAK_BYTES]) +static void _fill_msg_tweak(const uint8_t tag[TAG_BYTES], size_t block_index, uint8_t tweak[TWEAK_BYTES]) { - /* The t-bit tweak is filled as follows: + /* With an s-bit block index, the t-bit tweak is filled as follows: * * - bits [ 1, t-1]: tag + block index - * [ 1, 64]: tag[ 1.. 64] XOR block index - * [ 65, t-1]: tag[65..t-1] + * [ 1, s]: tag[1..s] XOR block index + * [s+1, t-1]: tag[s+1..t-1] * - bit t: 1 * - * This function assumes bits 65 to t have already been set, and - * only sets bits 1 to 64. + * This function assumes bits s+1 to t have already been set, and + * only sets bits 1 to s. */ + copy_block_index(block_index, tweak); + for (size_t i=0; i<sizeof(block_index); i++) { - uint8_t index_i = block_index >> i*8 & 0xff; - tweak[i] = tag[i] ^ index_i; + tweak[i] ^= tag[i]; } } |
