From dedea28c2ef59eb86f5d9704e5609ae13fa8b3c2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 25 Nov 2015 10:30:58 -0500 Subject: Make crypto_seed_rng() and crypto_rand() less scary. These functions must really never fail; so have crypto_rand() assert that it's working okay, and have crypto_seed_rng() demand that callers check its return value. Also have crypto_seed_rng() check RAND_status() before returning. --- src/test/bench.c | 5 ++++- src/test/test_workqueue.c | 5 ++++- src/test/testing_common.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/bench.c b/src/test/bench.c index 2a27377c80..70ec025b7b 100644 --- a/src/test/bench.c +++ b/src/test/bench.c @@ -643,7 +643,10 @@ main(int argc, const char **argv) reset_perftime(); - crypto_seed_rng(); + if (crypto_seed_rng() < 0) { + printf("Couldn't seed RNG; exiting.\n"); + return 1; + } crypto_init_siphash_key(); options = options_new(); init_logging(1); diff --git a/src/test/test_workqueue.c b/src/test/test_workqueue.c index 0d79733cf0..6edfd313cb 100644 --- a/src/test/test_workqueue.c +++ b/src/test/test_workqueue.c @@ -391,7 +391,10 @@ main(int argc, char **argv) init_logging(1); network_init(); crypto_global_init(1, NULL, NULL); - crypto_seed_rng(); + if (crypto_seed_rng() < 0) { + printf("Couldn't seed RNG; exiting.\n"); + return 1; + } rq = replyqueue_new(as_flags); tor_assert(rq); diff --git a/src/test/testing_common.c b/src/test/testing_common.c index 441024bd7d..2ea158fddd 100644 --- a/src/test/testing_common.c +++ b/src/test/testing_common.c @@ -272,7 +272,10 @@ main(int c, const char **v) return 1; } crypto_set_tls_dh_prime(); - crypto_seed_rng(); + if (crypto_seed_rng() < 0) { + printf("Couldn't seed RNG; exiting.\n"); + return 1; + } rep_hist_init(); network_init(); setup_directory(); -- cgit v1.2.3-54-g00ecf