#include #include #include #include #include #include "logerr.h" #include "random.h" #include "hash.h" static bool SEED_INITIALIZED = false; static u8 HASH_KEY[SIPHASH_KEY_LENGTH]; int hash_setup(void) { int rc = -1; if (random_bytes(SIPHASH_KEY_LENGTH, &HASH_KEY)) { logerr("urandom_bytes()"); goto out; } SEED_INITIALIZED = true; rc = 0; out: return rc; } void hash( const size_t inlen, const void *const restrict in, u8 out[HASH_OUTPUT_LENGTH] ) { assert(SEED_INITIALIZED == true); siphash(HASH_KEY, inlen, in, out); }