From 6880468862a498d359a0a6ed4bd9dd116a478fa9 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 9 Mar 2020 22:10:46 +0100 Subject: WIP cryptographic design --- controller/fw/tools/crypto_test.c | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 controller/fw/tools/crypto_test.c (limited to 'controller/fw/tools/crypto_test.c') diff --git a/controller/fw/tools/crypto_test.c b/controller/fw/tools/crypto_test.c new file mode 100644 index 0000000..8552117 --- /dev/null +++ b/controller/fw/tools/crypto_test.c @@ -0,0 +1,46 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "crypto.h" + +void oob_trigger_activated(enum trigger_domain domain, int serial) { + printf("oob_trigger_activated(%d, %d)\n", domain, serial); + fflush(stdout); +} + +void print_usage() { + fprintf(stderr, "Usage: crypto_test [auth_key_hex]\n"); +} + +int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "Error: Invalid arguments.\n"); + print_usage(); + return 1; + } + + uint8_t auth_key[16]; + + for (size_t i=0; argv[1][i+0] != '\0' && argv[1][i+1] != '\0'; i+= 2) { + char buf[3] = { argv[1][i+0], argv[1][i+1], 0}; + char *endptr; + auth_key[i/2] = strtoul(buf, &endptr, 16); + if (!endptr || *endptr != '\0') { + fprintf(stderr, "Invalid authkey\n"); + return 1; + } + } + + printf("rc=%d\n", oob_message_received(auth_key)); + + return 0; +} -- cgit