diff options
Diffstat (limited to 'ot_udp.c')
-rw-r--r-- | ot_udp.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -29,13 +29,21 @@ static ot_time g_hour_of_the_key; | |||
29 | 29 | ||
30 | static void udp_generate_rijndael_round_key() { | 30 | static void udp_generate_rijndael_round_key() { |
31 | uint32_t key[16]; | 31 | uint32_t key[16]; |
32 | #ifdef WANT_ARC4RANDOM | ||
33 | arc4random_buf(&key[0], sizeof(key)); | ||
34 | #else | ||
32 | key[0] = random(); | 35 | key[0] = random(); |
33 | key[1] = random(); | 36 | key[1] = random(); |
34 | key[2] = random(); | 37 | key[2] = random(); |
35 | key[3] = random(); | 38 | key[3] = random(); |
39 | #endif | ||
36 | rijndaelKeySetupEnc128( g_rijndael_round_key, (uint8_t*)key ); | 40 | rijndaelKeySetupEnc128( g_rijndael_round_key, (uint8_t*)key ); |
37 | 41 | ||
42 | #ifdef WANT_ARC4RANDOM | ||
43 | g_key_of_the_hour[0] = arc4random(); | ||
44 | #else | ||
38 | g_key_of_the_hour[0] = random(); | 45 | g_key_of_the_hour[0] = random(); |
46 | #endif | ||
39 | g_hour_of_the_key = g_now_minutes; | 47 | g_hour_of_the_key = g_now_minutes; |
40 | } | 48 | } |
41 | 49 | ||
@@ -46,7 +54,11 @@ static void udp_make_connectionid( uint32_t connid[2], const ot_ip6 remoteip, in | |||
46 | if( g_now_minutes + 60 > g_hour_of_the_key ) { | 54 | if( g_now_minutes + 60 > g_hour_of_the_key ) { |
47 | g_hour_of_the_key = g_now_minutes; | 55 | g_hour_of_the_key = g_now_minutes; |
48 | g_key_of_the_hour[1] = g_key_of_the_hour[0]; | 56 | g_key_of_the_hour[1] = g_key_of_the_hour[0]; |
49 | g_key_of_the_hour[0] = random(); | 57 | #ifdef WANT_ARC4RANDOM |
58 | g_key_of_the_hour[0] = arc4random(); | ||
59 | #else | ||
60 | g_key_of_the_hour[0] = random(); | ||
61 | #endif | ||
50 | } | 62 | } |
51 | 63 | ||
52 | memcpy( plain, remoteip, sizeof( plain ) ); | 64 | memcpy( plain, remoteip, sizeof( plain ) ); |