From 8d46de55be9fce55b297915e7086f77ceaab6f19 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 21 Nov 2018 16:34:25 +0100 Subject: Ajout de traces pour cipher.c (début) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implémentation de test-cipher.c en passant. --- crypto_aead/lilliputaei128v1/ref/test/helpers.h | 10 ------ .../ref/test/test-cipher-ref/cipher_order.txt | 12 +++---- .../ref/test/test-cipher-ref/cipher_random.txt | 12 +++---- .../lilliputaei128v1/ref/test/test-cipher.c | 37 ++++++++++++++++++++-- .../lilliputaei128v1/ref/test/test-tweakey.c | 10 +++++- 5 files changed, 56 insertions(+), 25 deletions(-) (limited to 'crypto_aead/lilliputaei128v1/ref/test') diff --git a/crypto_aead/lilliputaei128v1/ref/test/helpers.h b/crypto_aead/lilliputaei128v1/ref/test/helpers.h index 876cbcd..96e5184 100644 --- a/crypto_aead/lilliputaei128v1/ref/test/helpers.h +++ b/crypto_aead/lilliputaei128v1/ref/test/helpers.h @@ -10,16 +10,6 @@ #define ARRAY_END(A) (A+ARRAY_NB(A)) -struct vector_input -{ - char * name; - uint8_t key[KEY_BYTES]; - uint8_t tweak[TWEAK_BYTES]; -}; - -typedef struct vector_input vector_input; - - static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) { char filename[128]; diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_order.txt b/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_order.txt index 586078f..7dc7178 100644 --- a/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_order.txt +++ b/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_order.txt @@ -1,14 +1,14 @@ Tweak : -17 16 15 14 13 12 11 10 -0f 0e 0d 0c 0b 0a 09 08 -07 06 05 04 03 02 01 00 + 17 16 15 14 13 12 11 10 + 0f 0e 0d 0c 0b 0a 09 08 + 07 06 05 04 03 02 01 00 Key : -0f 0e 0d 0c 0b 0a 09 08 -07 06 05 04 03 02 01 00 + 0f 0e 0d 0c 0b 0a 09 08 + 07 06 05 04 03 02 01 00 Message : -0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00 + 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00 One round EGFN round : 0 State : diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_random.txt b/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_random.txt index ab77e18..2762d7b 100644 --- a/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_random.txt +++ b/crypto_aead/lilliputaei128v1/ref/test/test-cipher-ref/cipher_random.txt @@ -1,14 +1,14 @@ Tweak : -4d d2 b3 2a 12 43 8d 7d -21 26 90 90 fa 2e f8 df -84 1c 11 81 10 f3 43 a8 + 4d d2 b3 2a 12 43 8d 7d + 21 26 90 90 fa 2e f8 df + 84 1c 11 81 10 f3 43 a8 Key : -9b f9 d5 3d 4d 23 f4 7f -68 91 73 02 0a c6 96 c1 + 9b f9 d5 3d 4d 23 f4 7f + 68 91 73 02 0a c6 96 c1 Message : -0b 94 30 0d bd 1d 9d 9c f9 c8 b6 84 29 f0 d7 bc + 0b 94 30 0d bd 1d 9d 9c f9 c8 b6 84 29 f0 d7 bc One round EGFN round : 0 State : diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-cipher.c b/crypto_aead/lilliputaei128v1/ref/test/test-cipher.c index 6bc807f..c56e5fb 100644 --- a/crypto_aead/lilliputaei128v1/ref/test/test-cipher.c +++ b/crypto_aead/lilliputaei128v1/ref/test/test-cipher.c @@ -6,9 +6,18 @@ #include "helpers.h" -/* [0]: LSB */ +struct vector_input +{ + char * name; + uint8_t key[KEY_BYTES]; + uint8_t tweak[TWEAK_BYTES]; + uint8_t message[BLOCK_BYTES]; +}; + +typedef struct vector_input vector_input; +/* [0]: LSB */ vector_input VECTORS[] = { { .name = "order", @@ -20,6 +29,10 @@ vector_input VECTORS[] = { .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f + }, + .message = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, } }, { @@ -32,11 +45,31 @@ vector_input VECTORS[] = { .key = { 0xc1, 0x96, 0xc6, 0x0a, 0x02, 0x73, 0x91, 0x68, 0x7f, 0xf4, 0x23, 0x4d, 0x3d, 0xd5, 0xf9, 0x9b + }, + .message = { + 0xbc, 0xd7, 0xf0, 0x29, 0x84, 0xb6, 0xc8, 0xf9, + 0x9c, 0x9d, 0x1d, 0xbd, 0x0d, 0x30, 0x94, 0x0b } } }; -int main() +int main(int argc, char const * const *argv) { + if (argc < 2) + { + fprintf(stderr, "usage: %s OUTPUT-FOLDER\n", argv[0]); + return 1; + } + + for (vector_input* input=VECTORS; inputname); + FILE* dump = open_dump_file(argv[1], "cipher", input->name); + + uint8_t ciphertext[BLOCK_BYTES]; + lilliput_tbc_encrypt(input->key, input->tweak, input->message, ciphertext, dump); + + fclose(dump); + } } diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c b/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c index 8449ea4..2d3ef0d 100644 --- a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c +++ b/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c @@ -6,9 +6,17 @@ #include "helpers.h" -/* [0]: LSB */ +struct vector_input +{ + char * name; + uint8_t key[KEY_BYTES]; + uint8_t tweak[TWEAK_BYTES]; +}; +typedef struct vector_input vector_input; + +/* [0]: LSB */ vector_input VECTORS[] = { { .name = "full", -- cgit v1.2.3