summaryrefslogtreecommitdiff
path: root/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c')
-rw-r--r--crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c
index 21b7cfd..69ddf10 100644
--- a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c
+++ b/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c
@@ -1,24 +1,26 @@
#include <inttypes.h>
#include <stdio.h>
+#include <string.h>
#include "cipher.h"
#include "helpers.h"
-struct vector_input
+struct vector
{
- char * name;
+ 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_input vector_input;
+typedef struct vector vector;
/* [0]: LSB */
-vector_input VECTORS[] = {
+const vector VECTORS[] = {
{
.name = "order",
.tweak = {
@@ -33,6 +35,10 @@ vector_input VECTORS[] = {
.message = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ },
+ .ciphertext = {
+ 0x68, 0x4f, 0x71, 0x4a, 0xff, 0xa6, 0xa0, 0x4e,
+ 0xc3, 0x4a, 0x5d, 0x69, 0x49, 0x9d, 0x71, 0xe4
}
},
{
@@ -49,6 +55,10 @@ vector_input VECTORS[] = {
.message = {
0xbc, 0xd7, 0xf0, 0x29, 0x84, 0xb6, 0xc8, 0xf9,
0x9c, 0x9d, 0x1d, 0xbd, 0x0d, 0x30, 0x94, 0x0b
+ },
+ .ciphertext = {
+ 0xf5, 0xc3, 0xae, 0xae, 0x23, 0x01, 0x1f, 0xb0,
+ 0xc9, 0x5d, 0x53, 0x26, 0x67, 0xd3, 0xd8, 0xdf
}
}
};
@@ -62,14 +72,23 @@ int main(int argc, char const * const *argv)
return 1;
}
- for (vector_input* input=VECTORS; input<ARRAY_END(VECTORS); input++)
+ int diff = 0;
+
+ for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++)
{
- printf("%s\n", input->name);
- FILE* dump = open_dump_file(argv[1], "tbc-encrypt", input->name);
+ FILE *dump = open_dump_file(argv[1], "tbc-encrypt", v->name);
uint8_t ciphertext[BLOCK_BYTES];
- lilliput_tbc_encrypt(input->key, input->tweak, input->message, ciphertext, dump);
+ lilliput_tbc_encrypt(v->key, v->tweak, v->message, ciphertext, dump);
+
+ if (memcmp(ciphertext, v->ciphertext, sizeof(ciphertext)) != 0)
+ {
+ REPORT_DIFFERENCE(v->name, "ciphertext");
+ diff++;
+ }
fclose(dump);
}
+
+ return diff;
}