diff options
Diffstat (limited to 'ot_udp.c')
| -rw-r--r-- | ot_udp.c | 22 |
1 files changed, 4 insertions, 18 deletions
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "socket.h" | 16 | #include "socket.h" |
| 17 | 17 | ||
| 18 | /* Opentracker */ | 18 | /* Opentracker */ |
| 19 | #include "ot_random.h" | ||
| 19 | #include "ot_rijndael.h" | 20 | #include "ot_rijndael.h" |
| 20 | #include "ot_stats.h" | 21 | #include "ot_stats.h" |
| 21 | #include "ot_udp.h" | 22 | #include "ot_udp.h" |
| @@ -34,21 +35,10 @@ static int g_opentracker_started = 0; | |||
| 34 | 35 | ||
| 35 | static void udp_generate_rijndael_round_key(void) { | 36 | static void udp_generate_rijndael_round_key(void) { |
| 36 | uint32_t key[16]; | 37 | uint32_t key[16]; |
| 37 | #ifdef WANT_ARC4RANDOM | 38 | random_bytes(key, sizeof(key)); |
| 38 | arc4random_buf(&key[0], sizeof(key)); | ||
| 39 | #else | ||
| 40 | key[0] = random(); | ||
| 41 | key[1] = random(); | ||
| 42 | key[2] = random(); | ||
| 43 | key[3] = random(); | ||
| 44 | #endif | ||
| 45 | rijndaelKeySetupEnc128(g_rijndael_round_key, (uint8_t *)key); | 39 | rijndaelKeySetupEnc128(g_rijndael_round_key, (uint8_t *)key); |
| 46 | 40 | ||
| 47 | #ifdef WANT_ARC4RANDOM | 41 | g_key_of_the_hour[0] = random_uint32(); |
| 48 | g_key_of_the_hour[0] = arc4random(); | ||
| 49 | #else | ||
| 50 | g_key_of_the_hour[0] = random(); | ||
| 51 | #endif | ||
| 52 | g_hour_of_the_key = g_now_minutes; | 42 | g_hour_of_the_key = g_now_minutes; |
| 53 | } | 43 | } |
| 54 | 44 | ||
| @@ -60,11 +50,7 @@ static void udp_make_connectionid(uint32_t connid[2], const ot_ip6 remoteip, int | |||
| 60 | 50 | ||
| 61 | if (g_now_minutes - g_hour_of_the_key >= 60) { | 51 | if (g_now_minutes - g_hour_of_the_key >= 60) { |
| 62 | uint32_t old_key_of_the_hour = g_key_of_the_hour[0]; | 52 | uint32_t old_key_of_the_hour = g_key_of_the_hour[0]; |
| 63 | #ifdef WANT_ARC4RANDOM | 53 | uint32_t new_key_of_the_hour = random_uint32(); |
| 64 | uint32_t new_key_of_the_hour = arc4random(); | ||
| 65 | #else | ||
| 66 | uint32_t new_key_of_the_hour = random(); | ||
| 67 | #endif | ||
| 68 | /* If in the meantime another thread has performed | 54 | /* If in the meantime another thread has performed |
| 69 | key rotation, do not overwrite their results */ | 55 | key rotation, do not overwrite their results */ |
| 70 | if (g_now_minutes - g_hour_of_the_key >= 60) { | 56 | if (g_now_minutes - g_hour_of_the_key >= 60) { |
