diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-01 23:37:48 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-10 14:53:27 +0000 |
commit | 463cbcb19a68bc4109285872258d494332bdeaf6 (patch) | |
tree | bca1abb46cc91d3dbe462eed773ed54a0ccba164 /toxcore/group.c | |
parent | afab28f0ff0bd71efcf39bd633770053da99e04a (diff) |
Use the crypto random functions instead of `rand()`.
Presumably the uses of `rand()` were fine because they were not used in
security-sensitive places, but having to think about whether a crappy RNG
is acceptable in each situation requires effort that could better be
spent elsewhere.
Also, this means that once we have a custom deterministic RNG for
testing, that RNG is used everywhere, so all the code is deterministic.
It also allowed us to delete a system-specific function that wasn't used
anywhere except in a call to `srand()`.
Diffstat (limited to 'toxcore/group.c')
-rw-r--r-- | toxcore/group.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/toxcore/group.c b/toxcore/group.c index 317b885f..f62684ed 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -1490,12 +1490,12 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con | |||
1490 | 1490 | ||
1491 | /* TODO(irungentoo): what if two people enter the group at the same time and | 1491 | /* TODO(irungentoo): what if two people enter the group at the same time and |
1492 | are given the same peer_number by different nodes? */ | 1492 | are given the same peer_number by different nodes? */ |
1493 | uint16_t peer_number = rand(); | 1493 | uint16_t peer_number = random_u16(); |
1494 | 1494 | ||
1495 | unsigned int tries = 0; | 1495 | unsigned int tries = 0; |
1496 | 1496 | ||
1497 | while (get_peer_index(g, peer_number) != -1) { | 1497 | while (get_peer_index(g, peer_number) != -1) { |
1498 | peer_number = rand(); | 1498 | peer_number = random_u16(); |
1499 | ++tries; | 1499 | ++tries; |
1500 | 1500 | ||
1501 | if (tries > 32) { | 1501 | if (tries > 32) { |