From dded798f1a038c8482fcc5d41824a9161d0a60c2 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 4 Dec 2018 08:15:59 +0100 Subject: [WIP] screw with folders organization --- test/i-128/test-tbc-decrypt.c | 84 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 test/i-128/test-tbc-decrypt.c (limited to 'test/i-128/test-tbc-decrypt.c') diff --git a/test/i-128/test-tbc-decrypt.c b/test/i-128/test-tbc-decrypt.c new file mode 100644 index 0000000..9bd6996 --- /dev/null +++ b/test/i-128/test-tbc-decrypt.c @@ -0,0 +1,84 @@ +#include +#include +#include + +#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; vkey, v->tweak, v->ciphertext, message); + + if (memcmp(message, v->message, sizeof(message)) != 0) + { + REPORT_DIFFERENCE(v->name, "decrypted message"); + diff++; + } + } + + return diff; +} -- cgit v1.2.3