// common.c --- shared between client and server // // Copyright (c) 2026 Martin Michalec // // SPDX-License-Identifier: MIT // // Commentary: // // Code: #include "common.h" #include "utils.h" bool load_aes_256_key (aes_256_key key, const char *filename) { FILE *stream = fopen (filename, "r"); if (stream == NULL) return false; // TODO(cmmm): handle wrong format better... int assignments = 0; for (int i = 0; i < AES_256_KEY_SIZE; ++i) assignments += fscanf (stream, "%02hhx", &key[i]); fclose (stream); return assignments == AES_256_KEY_SIZE; } void print_hex (uint8_t *data, size_t size) { for (size_t i = 0; i < size; ++i) { if (i && i % 2 == 0) printf (" "); printf ("%02x", data[i]); } printf ("\n"); } // common.c ends here