From ecb1f1e92ab449023d1427f9db26c5bac09c4901 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 24 Oct 2026 01:50:25 +0200 Subject: Use new entropy fascility and add tests for it --- ot_udp.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'ot_udp.c') diff --git a/ot_udp.c b/ot_udp.c index fae2c87..82aa8bd 100644 --- a/ot_udp.c +++ b/ot_udp.c @@ -16,6 +16,7 @@ #include "socket.h" /* Opentracker */ +#include "ot_random.h" #include "ot_rijndael.h" #include "ot_stats.h" #include "ot_udp.h" @@ -34,21 +35,10 @@ static int g_opentracker_started = 0; static void udp_generate_rijndael_round_key(void) { uint32_t key[16]; -#ifdef WANT_ARC4RANDOM - arc4random_buf(&key[0], sizeof(key)); -#else - key[0] = random(); - key[1] = random(); - key[2] = random(); - key[3] = random(); -#endif + random_bytes(key, sizeof(key)); rijndaelKeySetupEnc128(g_rijndael_round_key, (uint8_t *)key); -#ifdef WANT_ARC4RANDOM - g_key_of_the_hour[0] = arc4random(); -#else - g_key_of_the_hour[0] = random(); -#endif + g_key_of_the_hour[0] = random_uint32(); g_hour_of_the_key = g_now_minutes; } @@ -60,11 +50,7 @@ static void udp_make_connectionid(uint32_t connid[2], const ot_ip6 remoteip, int if (g_now_minutes - g_hour_of_the_key >= 60) { uint32_t old_key_of_the_hour = g_key_of_the_hour[0]; -#ifdef WANT_ARC4RANDOM - uint32_t new_key_of_the_hour = arc4random(); -#else - uint32_t new_key_of_the_hour = random(); -#endif + uint32_t new_key_of_the_hour = random_uint32(); /* If in the meantime another thread has performed key rotation, do not overwrite their results */ if (g_now_minutes - g_hour_of_the_key >= 60) { -- cgit v1.3