lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

commit f92b969dc2b4ed8de7a3170c4b84ab06357e500c
parent dc8035fc0b4d12d999a053de90071143bcd9b12d
Author: Kévin Le Gouguec <kevin.legouguec@airbus.com>
Date:   Tue, 11 Dec 2018 17:18:52 +0100

Dépliage de la séquence induite par M₄ pour MR³

Diffstat:
Msrc/tweakey.c | 50++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/src/tweakey.c b/src/tweakey.c @@ -181,7 +181,42 @@ static const uint8_t M3[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f +}; + +static const uint8_t M4[256] = { + 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, + 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, + 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, + 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, + 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, + 0x14, 0x14, 0x15, 0x15, 0x16, 0x16, 0x17, 0x17, + 0x18, 0x18, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, + 0x1c, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, + 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, + 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, + 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, + 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, + 0x14, 0x14, 0x15, 0x15, 0x16, 0x16, 0x17, 0x17, + 0x18, 0x18, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, + 0x1c, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, + 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, + 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, + 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, + 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, + 0x14, 0x14, 0x15, 0x15, 0x16, 0x16, 0x17, 0x17, + 0x18, 0x18, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, + 0x1c, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, + 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, + 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, + 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, + 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, + 0x14, 0x14, 0x15, 0x15, 0x16, 0x16, 0x17, 0x17, + 0x18, 0x18, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, + 0x1c, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f }; static void _multiply_MR(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) @@ -210,11 +245,14 @@ static void _multiply_MR2(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) static void _multiply_MR3(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]) { - uint8_t tmp[LANE_BYTES]; - memcpy(tmp, X, LANE_BYTES); - - _multiply_MR2(X, tmp); - _multiply_MR(tmp, Y); + Y[0] = X[3] ^ X[4]>>3; + Y[1] = X[4] ^ X[5]>>3 ^ M3[X[6]]; + Y[2] = M4[X[3]] ^ X[5] ^ M1[X[6]] ^ M3[X[7]]; + Y[3] = X[3]<<2 ^ X[6] ^ X[7]<<3; + Y[4] = X[0]<<3 ^ X[4]<<2 ^ X[7]; + Y[5] = X[0] ^ X[5]<<2 ^ X[6]<<5; + Y[6] = X[1]; + Y[7] = X[2]; } typedef void (*matrix_multiplication)(const uint8_t X[LANE_BYTES], uint8_t Y[LANE_BYTES]);