summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto_aead/lilliputaei128v1/ref/Makefile4
-rw-r--r--crypto_aead/lilliputaei128v1/ref/test/traces-ae-128-i.c125
-rw-r--r--src/common.mk10
-rw-r--r--src/debug.h6
4 files changed, 142 insertions, 3 deletions
diff --git a/crypto_aead/lilliputaei128v1/ref/Makefile b/crypto_aead/lilliputaei128v1/ref/Makefile
index ca9e1db..11d1038 100644
--- a/crypto_aead/lilliputaei128v1/ref/Makefile
+++ b/crypto_aead/lilliputaei128v1/ref/Makefile
@@ -1,6 +1,8 @@
tests = test-tweakey test-tbc-encrypt test-tbc-decrypt \
test-ae-roundtrip test-ae-encrypt test-ae-decrypt
+traces = traces-ae-128-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
@@ -10,6 +12,8 @@ results/test-tbc-decrypt: results/src/cipher.o results/src/tweakey.o results/src
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/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
diff --git a/crypto_aead/lilliputaei128v1/ref/test/traces-ae-128-i.c b/crypto_aead/lilliputaei128v1/ref/test/traces-ae-128-i.c
new file mode 100644
index 0000000..2467084
--- /dev/null
+++ b/crypto_aead/lilliputaei128v1/ref/test/traces-ae-128-i.c
@@ -0,0 +1,125 @@
+#include <stdio.h>
+#include <stdint.h>
+
+#include "lilliput-ae.h"
+
+#include "debug.h"
+#include "helpers.h"
+
+
+FILE *DUMP;
+
+
+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;
+
+
+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
+ }
+ },
+ {
+ .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
+ }
+ }
+};
+
+
+int main()
+{
+ for (const vector *v=VECTORS; v<ARRAY_END(VECTORS); v++)
+ {
+ debug_open_dump("ae-128-i", v->name);
+ debug_dump_buffer("message", v->message_len, v->message, 0);
+ debug_dump_buffer("associated data", v->auth_len, v->auth, 0);
+ debug_dump_buffer("key", KEY_BYTES, v->key, 0);
+ debug_dump_buffer("nonce", NONCE_BYTES, v->nonce, 0);
+
+ 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
+ );
+
+ debug_dump_buffer("ciphertext", v->message_len, ciphertext, 0);
+ debug_dump_buffer("tag", TAG_BYTES, tag, 0);
+
+ fclose(DUMP);
+ }
+}
diff --git a/src/common.mk b/src/common.mk
index b854933..22bd3ca 100644
--- a/src/common.mk
+++ b/src/common.mk
@@ -29,18 +29,28 @@ results/test-%: results/test/test-%.o
@ echo "LD $@"
$(Q) gcc $^ $(LDFLAGS) -o $@
+results/traces-%: results/test/traces-%.o
+ @ echo "LD $@"
+ $(Q) gcc $^ $(LDFLAGS) -o $@
+
test: $(tests)
$(tests): %: results/%
@ echo "TEST $@"
$(Q) ./results/$@
+traces: $(traces)
+traces-%: results/traces-%
+ @ echo "TRACES $@"
+ $(Q) ./results/$@
+
results/src/cipher.o: src/cipher.h src/tweakey.h src/constants.h src/parameters.h _parameters.h
results/src/constants.o: src/constants.h
results/src/lilliput-ae-i.o: src/lilliput-ae.h src/cipher.h src/constants.h src/parameters.h _parameters.h
results/src/tweakey.o: src/tweakey.h src/constants.h src/parameters.h _parameters.h
results/test-*.o: test/helpers.h src/parameters.h _parameters.h
+results/traces-%.o: test/helpers.h src/parameters.h _parameters.h
# TODO: should add order-only prerequisites to remove mkdirs inside recipes
# TODO: add valgrind, although it does not seem to play well with ASAN
diff --git a/src/debug.h b/src/debug.h
index c7fa343..c25aeb1 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -60,11 +60,11 @@ static inline void debug_dump_buffer(const char *header, size_t len, const uint8
fprintf(DUMP, "\n");
}
-static inline void debug_open_dump(const char *vector_name)
+static inline void debug_open_dump(const char *suite, const char *vector_name)
{
- size_t namelen = snprintf(NULL, 0, "/tmp/test-%s.txt", vector_name);
+ size_t namelen = snprintf(NULL, 0, "results/traces-%s-%s.txt", suite, vector_name);
char name[namelen+1];
- snprintf(name, sizeof(name), "/tmp/test-%s.txt", vector_name);
+ snprintf(name, sizeof(name), "results/traces-%s-%s.txt", suite, vector_name);
DUMP = fopen(name, "w");
}