diff options
Diffstat (limited to 'crypto_aead/lilliputaei128v1')
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/Makefile | 23 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/_parameters.h | 9 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/test/test-ae-decrypt.c | 156 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/test/test-ae-encrypt.c | 158 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/test/test-ae-roundtrip.c | 118 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/test/test-tbc-decrypt.c | 84 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c | 84 | ||||
| -rw-r--r-- | crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c | 113 |
8 files changed, 0 insertions, 745 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/Makefile b/crypto_aead/lilliputaei128v1/ref/Makefile deleted file mode 100644 index e126a75..0000000 --- a/crypto_aead/lilliputaei128v1/ref/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -tests = test-tweakey test-tbc-encrypt test-tbc-decrypt \ -test-ae-roundtrip test-ae-encrypt test-ae-decrypt - -traces = traces-ae-128-i traces-tbc-256-i - -include src/common.mk - -results/test-ae-decrypt: results/src/lilliput-ae-i.o results/src/cipher.o results/src/tweakey.o results/src/constants.o | results -results/test-ae-encrypt: results/src/lilliput-ae-i.o results/src/cipher.o results/src/tweakey.o results/src/constants.o | results -results/test-ae-roundtrip: results/src/lilliput-ae-i.o results/src/cipher.o results/src/tweakey.o results/src/constants.o | results -results/test-tbc-decrypt: results/src/cipher.o results/src/tweakey.o results/src/constants.o | results -results/test-tbc-encrypt: results/src/cipher.o results/src/tweakey.o results/src/constants.o | results -results/test-tweakey: results/src/tweakey.o results/src/constants.o | results - -results/traces-ae-128-i: results/src/lilliput-ae-i.o results/src/cipher.o results/src/tweakey.o results/src/constants.o | results/src -results/traces-tbc-128-i: results/src/cipher.o results/src/tweakey.o results/src/constants.o | results/src - -results/test-ae-decrypt.o: src/lilliput-ae.h -results/test-ae-encrypt.o: src/lilliput-ae.h -results/test-ae-roundtrip.o: src/lilliput-ae.h -results/test-tbc-decrypt.o: src/cipher.h -results/test-tbc-encrypt.o: src/cipher.h -results/test-tweakey.o: src/tweakey.h diff --git a/crypto_aead/lilliputaei128v1/ref/_parameters.h b/crypto_aead/lilliputaei128v1/ref/_parameters.h deleted file mode 100644 index 08ce8c1..0000000 --- a/crypto_aead/lilliputaei128v1/ref/_parameters.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _PARAMETERS_H -#define _PARAMETERS_H - -#define KEY_LENGTH_BITS 128 -#define ROUNDS 32 - -#define TWEAK_LENGTH_BITS 192 - -#endif /* _PARAMETERS_H */ diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-ae-decrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-ae-decrypt.c deleted file mode 100644 index 8ae6308..0000000 --- a/crypto_aead/lilliputaei128v1/ref/test/test-ae-decrypt.c +++ /dev/null @@ -1,156 +0,0 @@ -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#include "lilliput-ae.h" - -#include "test-helpers.h" - - -struct vector -{ - char *name; - uint8_t key[KEY_BYTES]; - uint8_t nonce[NONCE_BYTES]; - size_t auth_len; - uint8_t *auth; - uint8_t *ciphertext; - size_t ciphertext_len; - uint8_t tag[TAG_BYTES]; - uint8_t *message; -}; - -typedef struct vector vector; - - -const vector VECTORS[] = { - { - .name = "order", - .key = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }, - .nonce = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e - }, - .auth_len = 64, - .auth = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - }, - .ciphertext_len = 64, - .ciphertext = (uint8_t[]) { - 0x92, 0xf0, 0xd5, 0x7c, 0x31, 0x0f, 0x73, 0x38, - 0xbb, 0xc6, 0x11, 0xfb, 0xe7, 0x49, 0xd2, 0xcd, - 0xae, 0x29, 0x67, 0xeb, 0xcd, 0xca, 0xd1, 0x07, - 0xf0, 0x2d, 0x2a, 0x14, 0x8e, 0xec, 0x4d, 0xae, - 0x92, 0xe3, 0x96, 0x65, 0x96, 0x84, 0xe3, 0x8d, - 0x48, 0x36, 0x0e, 0x11, 0xec, 0xe2, 0x0a, 0x4e, - 0xe4, 0x3c, 0xc0, 0xb5, 0xf8, 0xe7, 0xb9, 0x7a, - 0xc1, 0xf4, 0x3b, 0xa7, 0x8b, 0xaa, 0x89, 0xe6 - }, - .tag = { - 0xf3, 0x78, 0x87, 0xc3, 0xb0, 0x4a, 0xe7, 0x10, - 0x8c, 0x14, 0x67, 0x0b, 0x38, 0x9c, 0xc0, 0x2c - }, - .message = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - } - }, - { - .name = "order-padded", - .key = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }, - .nonce = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e - }, - .auth_len = 66, - .auth = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x01 - }, - .ciphertext_len = 66, - .ciphertext = (uint8_t[]) { - 0x92, 0xf0, 0xd5, 0x7c, 0x31, 0x0f, 0x73, 0x38, - 0xbb, 0xc6, 0x11, 0xfb, 0xe7, 0x49, 0xd2, 0xcd, - 0xae, 0x29, 0x67, 0xeb, 0xcd, 0xca, 0xd1, 0x07, - 0xf0, 0x2d, 0x2a, 0x14, 0x8e, 0xec, 0x4d, 0xae, - 0x92, 0xe3, 0x96, 0x65, 0x96, 0x84, 0xe3, 0x8d, - 0x48, 0x36, 0x0e, 0x11, 0xec, 0xe2, 0x0a, 0x4e, - 0xe4, 0x3c, 0xc0, 0xb5, 0xf8, 0xe7, 0xb9, 0x7a, - 0xc1, 0xf4, 0x3b, 0xa7, 0x8b, 0xaa, 0x89, 0xe6, - 0x2d, 0x48 - }, - .tag = { - 0x12, 0x99, 0x0c, 0x33, 0x41, 0x59, 0x34, 0xa7, - 0xd9, 0xa6, 0xcc, 0xb2, 0x90, 0xfe, 0x6d, 0x3d - }, - .message = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x01 - } - } -}; - - -int main() -{ - int diff = 0; - - for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++) - { - uint8_t message[v->ciphertext_len]; - - if (! lilliput_ae_decrypt( - v->ciphertext_len, v->ciphertext, - v->auth_len, v->auth, - v->key, v->nonce, - v->tag, - message - )) - { - REPORT_INVALID(v->name); - diff++; - continue; - } - - if (memcmp(message, v->message, v->ciphertext_len) != 0) - { - REPORT_DIFFERENCE(v->name, "ciphertext"); - diff++; - } - } - - return diff; -} diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-ae-encrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-ae-encrypt.c deleted file mode 100644 index 9a7dce0..0000000 --- a/crypto_aead/lilliputaei128v1/ref/test/test-ae-encrypt.c +++ /dev/null @@ -1,158 +0,0 @@ -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#include "lilliput-ae.h" - -#include "test-helpers.h" - - -struct vector -{ - char *name; - uint8_t key[KEY_BYTES]; - uint8_t nonce[NONCE_BYTES]; - size_t auth_len; - uint8_t *auth; - size_t message_len; - uint8_t *message; - uint8_t *ciphertext; - uint8_t tag[TAG_BYTES]; -}; - -typedef struct vector vector; - - -const vector VECTORS[] = { - { - .name = "order", - .key = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }, - .nonce = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e - }, - .auth_len = 64, - .auth = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - }, - .message_len = 64, - .message = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - }, - .ciphertext = (uint8_t[]) { - 0x92, 0xf0, 0xd5, 0x7c, 0x31, 0x0f, 0x73, 0x38, - 0xbb, 0xc6, 0x11, 0xfb, 0xe7, 0x49, 0xd2, 0xcd, - 0xae, 0x29, 0x67, 0xeb, 0xcd, 0xca, 0xd1, 0x07, - 0xf0, 0x2d, 0x2a, 0x14, 0x8e, 0xec, 0x4d, 0xae, - 0x92, 0xe3, 0x96, 0x65, 0x96, 0x84, 0xe3, 0x8d, - 0x48, 0x36, 0x0e, 0x11, 0xec, 0xe2, 0x0a, 0x4e, - 0xe4, 0x3c, 0xc0, 0xb5, 0xf8, 0xe7, 0xb9, 0x7a, - 0xc1, 0xf4, 0x3b, 0xa7, 0x8b, 0xaa, 0x89, 0xe6 - }, - .tag = { - 0xf3, 0x78, 0x87, 0xc3, 0xb0, 0x4a, 0xe7, 0x10, - 0x8c, 0x14, 0x67, 0x0b, 0x38, 0x9c, 0xc0, 0x2c - } - }, - { - .name = "order-padded", - .key = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }, - .nonce = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e - }, - .auth_len = 66, - .auth = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x01 - }, - .message_len = 66, - .message = (uint8_t[]) { - 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, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x01 - }, - .ciphertext = (uint8_t[]) { - 0x92, 0xf0, 0xd5, 0x7c, 0x31, 0x0f, 0x73, 0x38, - 0xbb, 0xc6, 0x11, 0xfb, 0xe7, 0x49, 0xd2, 0xcd, - 0xae, 0x29, 0x67, 0xeb, 0xcd, 0xca, 0xd1, 0x07, - 0xf0, 0x2d, 0x2a, 0x14, 0x8e, 0xec, 0x4d, 0xae, - 0x92, 0xe3, 0x96, 0x65, 0x96, 0x84, 0xe3, 0x8d, - 0x48, 0x36, 0x0e, 0x11, 0xec, 0xe2, 0x0a, 0x4e, - 0xe4, 0x3c, 0xc0, 0xb5, 0xf8, 0xe7, 0xb9, 0x7a, - 0xc1, 0xf4, 0x3b, 0xa7, 0x8b, 0xaa, 0x89, 0xe6, - 0x2d, 0x48 - }, - .tag = { - 0x12, 0x99, 0x0c, 0x33, 0x41, 0x59, 0x34, 0xa7, - 0xd9, 0xa6, 0xcc, 0xb2, 0x90, 0xfe, 0x6d, 0x3d - } - } -}; - - -int main() -{ - int diff = 0; - - for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++) - { - uint8_t ciphertext[v->message_len]; - uint8_t tag[TAG_BYTES]; - - lilliput_ae_encrypt( - v->message_len, v->message, - v->auth_len, v->auth, - v->key, v->nonce, - ciphertext, - tag - ); - - if (memcmp(ciphertext, v->ciphertext, v->message_len) != 0) - { - REPORT_DIFFERENCE(v->name, "ciphertext"); - diff++; - } - - if (memcmp(tag, v->tag, TAG_BYTES) != 0) - { - REPORT_DIFFERENCE(v->name, "tag"); - diff++; - } - } - - return diff; -} diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-ae-roundtrip.c b/crypto_aead/lilliputaei128v1/ref/test/test-ae-roundtrip.c deleted file mode 100644 index 80ac737..0000000 --- a/crypto_aead/lilliputaei128v1/ref/test/test-ae-roundtrip.c +++ /dev/null @@ -1,118 +0,0 @@ -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#include "lilliput-ae.h" - -#include "test-helpers.h" - - -struct vector -{ - char *name; - uint8_t key[KEY_BYTES]; - uint8_t nonce[NONCE_BYTES]; - size_t auth_len; - uint8_t *auth; - size_t message_len; - uint8_t *message; -}; - -typedef struct vector vector; - - -/* Keys and nonces generated with /dev/urandom. */ - -const vector VECTORS[] = { - { - .name = "short", - .key = { - 0xdc, 0xd8, 0xcb, 0x6d, 0xf9, 0xda, 0xf2, 0xc9, - 0x7c, 0xc1, 0x6a, 0xff, 0x7e, 0x1d, 0x27, 0xa3 - }, - .nonce = { - 0xcd, 0x6f, 0x24, 0xe1, 0xf8, 0xcd, 0x64, 0xde, - 0x18, 0x2f, 0x92, 0xab, 0xdb, 0xfa, 0xff - }, - .auth_len = 8, - .auth = (uint8_t*)"deadbeef", - .message_len = 4, - .message = (uint8_t[]){ - 0xde, 0xad, 0xbe, 0xef - } - }, - { - .name = "block-sized", - .key = { - 0x3f, 0x75, 0x05, 0x0a, 0xc1, 0xc6, 0xb5, 0xe0, - 0x57, 0x2e, 0x60, 0x9e, 0x32, 0xab, 0xbe, 0xd0 - }, - .nonce = { - 0xcd, 0x7d, 0xb0, 0xa0, 0x62, 0xdf, 0xda, 0x0a, - 0x23, 0x7a, 0x17, 0x32, 0x60, 0x42, 0xef - }, - .auth_len = 13, - .auth = (uint8_t*)"some metadata", - .message_len = 2*BLOCK_BYTES, - .message = (uint8_t*)"32-byte long, i.e. 2*BLOCK_BYTES" - }, - { - .name = "arbitrarily long", - .key = { - 0x13, 0x6a, 0x99, 0xfd, 0xbf, 0x88, 0xac, 0xf8, - 0x92, 0x7b, 0x27, 0xb1, 0x10, 0xa5, 0xe8, 0x73 - }, - .nonce = { - 0x59, 0x41, 0xa7, 0x53, 0x0f, 0xde, 0xf1, 0xb1, - 0xca, 0xd5, 0x80, 0xc4, 0x1c, 0x16, 0x2b - }, - .auth_len = 30, - .auth = (uint8_t*)"a bunch of associated metadata", - .message_len = 59, - .message = (uint8_t*)"here comes the placeholder: foobar ipsum dolor sit baz quux" - } -}; - - -int main() -{ - int diff = 0; - - for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++) - { - uint8_t ciphertext[v->message_len]; - uint8_t tag[TAG_BYTES]; - - lilliput_ae_encrypt( - v->message_len, v->message, - v->auth_len, v->auth, - v->key, v->nonce, - ciphertext, - tag - ); - - uint8_t deciphered[v->message_len]; - bool valid = lilliput_ae_decrypt( - v->message_len, ciphertext, - v->auth_len, v->auth, - v->key, v->nonce, tag, - deciphered - ); - - if (!valid) - { - REPORT_INVALID(v->name); - diff++; - continue; - } - - if (memcmp(deciphered, v->message, v->message_len) != 0) - { - REPORT_DIFFERENCE(v->name, "deciphered plaintext"); - diff++; - continue; - } - } - - return diff; -} diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-decrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-tbc-decrypt.c deleted file mode 100644 index 9bd6996..0000000 --- a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-decrypt.c +++ /dev/null @@ -1,84 +0,0 @@ -#include <stdint.h> -#include <stdio.h> -#include <string.h> - -#include "cipher.h" - -#include "test-helpers.h" - - -struct vector -{ - char *name; - uint8_t key[KEY_BYTES]; - uint8_t tweak[TWEAK_BYTES]; - uint8_t ciphertext[BLOCK_BYTES]; - uint8_t message[BLOCK_BYTES]; -}; - -typedef struct vector vector; - - -/* [0]: LSB */ -const vector VECTORS[] = { - { - .name = "order", - .tweak = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 - }, - .key = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }, - .ciphertext = { - 0xf9, 0xe3, 0x95, 0x3c, 0x04, 0xf6, 0x2d, 0x9c, - 0x2d, 0x54, 0x58, 0xc0, 0x1d, 0xcc, 0x8a, 0x25 - }, - .message = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - } - }, - { - .name = "random", - .tweak = { - 0xa8, 0x43, 0xf3, 0x10, 0x81, 0x11, 0x1c, 0x84, - 0xdf, 0xf8, 0x2e, 0xfa, 0x90, 0x90, 0x26, 0x21, - 0x7d, 0x8d, 0x43, 0x12, 0x2a, 0xb3, 0xd2, 0x4d - }, - .key = { - 0xc1, 0x96, 0xc6, 0x0a, 0x02, 0x73, 0x91, 0x68, - 0x7f, 0xf4, 0x23, 0x4d, 0x3d, 0xd5, 0xf9, 0x9b - }, - .ciphertext = { - 0xf4, 0x4a, 0x06, 0x30, 0x7d, 0xd2, 0xb2, 0x5a, - 0xf9, 0xd2, 0xba, 0x6c, 0x41, 0xf4, 0x45, 0x7f - }, - .message = { - 0xbc, 0xd7, 0xf0, 0x29, 0x84, 0xb6, 0xc8, 0xf9, - 0x9c, 0x9d, 0x1d, 0xbd, 0x0d, 0x30, 0x94, 0x0b - } - } -}; - - -int main() -{ - int diff = 0; - - for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++) - { - uint8_t message[BLOCK_BYTES]; - lilliput_tbc_decrypt(v->key, v->tweak, v->ciphertext, message); - - if (memcmp(message, v->message, sizeof(message)) != 0) - { - REPORT_DIFFERENCE(v->name, "decrypted message"); - diff++; - } - } - - return diff; -} diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c deleted file mode 100644 index 60cc9cf..0000000 --- a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c +++ /dev/null @@ -1,84 +0,0 @@ -#include <stdint.h> -#include <stdio.h> -#include <string.h> - -#include "cipher.h" - -#include "test-helpers.h" - - -struct vector -{ - char *name; - uint8_t key[KEY_BYTES]; - uint8_t tweak[TWEAK_BYTES]; - uint8_t message[BLOCK_BYTES]; - uint8_t ciphertext[BLOCK_BYTES]; -}; - -typedef struct vector vector; - - -/* [0]: LSB */ -const vector VECTORS[] = { - { - .name = "order", - .tweak = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 - }, - .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, - }, - .ciphertext = { - 0xf9, 0xe3, 0x95, 0x3c, 0x04, 0xf6, 0x2d, 0x9c, - 0x2d, 0x54, 0x58, 0xc0, 0x1d, 0xcc, 0x8a, 0x25 - } - }, - { - .name = "random", - .tweak = { - 0xa8, 0x43, 0xf3, 0x10, 0x81, 0x11, 0x1c, 0x84, - 0xdf, 0xf8, 0x2e, 0xfa, 0x90, 0x90, 0x26, 0x21, - 0x7d, 0x8d, 0x43, 0x12, 0x2a, 0xb3, 0xd2, 0x4d - }, - .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 - }, - .ciphertext = { - 0xf4, 0x4a, 0x06, 0x30, 0x7d, 0xd2, 0xb2, 0x5a, - 0xf9, 0xd2, 0xba, 0x6c, 0x41, 0xf4, 0x45, 0x7f - } - } -}; - - -int main() -{ - int diff = 0; - - for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++) - { - uint8_t ciphertext[BLOCK_BYTES]; - lilliput_tbc_encrypt(v->key, v->tweak, v->message, ciphertext); - - if (memcmp(ciphertext, v->ciphertext, sizeof(ciphertext)) != 0) - { - REPORT_DIFFERENCE(v->name, "ciphertext"); - diff++; - } - } - - return diff; -} diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c b/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c deleted file mode 100644 index 2b0bad5..0000000 --- a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c +++ /dev/null @@ -1,113 +0,0 @@ -#include <inttypes.h> -#include <stdio.h> -#include <string.h> - -#include "tweakey.h" - -#include "test-helpers.h" - - -struct vector -{ - char *name; - uint8_t key[KEY_BYTES]; - uint8_t tweak[TWEAK_BYTES]; - uint8_t last_rtk[TWEAKEY_BYTES]; -}; - -typedef struct vector vector; - - -/* [0]: LSB */ -const vector VECTORS[] = { - { - .name = "full", - .tweak = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }, - .key = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }, - .last_rtk = { - 0x42, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d - } - }, - { - .name = "null", - .tweak = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - .key = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - .last_rtk = { - 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - } - - }, - { - .name = "order", - .tweak = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 - }, - .key = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }, - .last_rtk = { - 0xa5, 0x92, 0x9b, 0xa7, 0x86, 0x8f, 0xb3, 0xae - } - }, - { - .name = "random", - .tweak = { - 0xa8, 0x43, 0xf3, 0x10, 0x81, 0x11, 0x1c, 0x84, - 0xdf, 0xf8, 0x2e, 0xfa, 0x90, 0x90, 0x26, 0x21, - 0x7d, 0x8d, 0x43, 0x12, 0x2a, 0xb3, 0xd2, 0x4d - }, - .key = { - 0xc1, 0x96, 0xc6, 0x0a, 0x02, 0x73, 0x91, 0x68, - 0x7f, 0xf4, 0x23, 0x4d, 0x3d, 0xd5, 0xf9, 0x9b - }, - .last_rtk = { - 0xed, 0xe3, 0x39, 0xac, 0x5e, 0xa6, 0xf9, 0xf1 - } - } -}; - - -int main() -{ - int diff = 0; - - for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++) - { - uint8_t tk[TWEAKEY_BYTES]; - tweakey_state_init(tk, v->key, v->tweak); - - uint8_t rtk[ROUND_TWEAKEY_BYTES]; - tweakey_state_extract(tk, 0, rtk); - - for (uint8_t i=1; i<ROUNDS; i++) - { - tweakey_state_update(tk); - tweakey_state_extract(tk, i, rtk); - } - - if (memcmp(rtk, v->last_rtk, sizeof(rtk)) != 0) - { - REPORT_DIFFERENCE(v->name, "last RTK"); - diff++; - } - } - - return diff; -} |
