From d44f91ad7915ad08ad2b6dad3e52902edc619ef2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 13 Aug 2013 10:59:20 -0400 Subject: [PATCH 1/3] Finish a sentence --- include/event2/util.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/event2/util.h b/include/event2/util.h index 18cbd80699..dde91131da 100644 --- a/include/event2/util.h +++ b/include/event2/util.h @@ -679,7 +679,8 @@ int evutil_secure_rng_init(void); * Set a filename to use in place of /dev/urandom for seeding the secure * PRNG. Return 0 on success, -1 on failure. * - * Call this function BEFORE calling any other initialization or . + * Call this function BEFORE calling any other initialization or RNG + * functions. * * (This string will _NOT_ be copied internally. Do not free it while any * user of the secure RNG might be running. Don't pass anything other than a From 9695e9c192b866793110c885fb87143de8cebf2a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 13 Aug 2013 10:59:27 -0400 Subject: [PATCH 2/3] Avoid other RNG initialization FS reads when urandom file is specified --- arc4random.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arc4random.c b/arc4random.c index 0480570314..4b6f5f2f12 100644 --- a/arc4random.c +++ b/arc4random.c @@ -326,10 +326,13 @@ arc4_seed_urandom(void) return arc4_seed_urandom_helper_(arc4random_urandom_filename); for (i = 0; filenames[i]; ++i) { - if (arc4_seed_urandom_helper_(filenames[i]) == 0) + if (arc4_seed_urandom_helper_(filenames[i]) == 0) { + printf("okay %s\n", filenames[i]); return 0; + } } + puts("FAIL"); return -1; } #endif @@ -350,7 +353,8 @@ arc4_seed(void) ok = 1; #endif #ifdef TRY_SEED_PROC_SYS_KERNEL_RANDOM_UUID - if (0 == arc4_seed_proc_sys_kernel_random_uuid()) + if (arc4random_urandom_filename == NULL && + 0 == arc4_seed_proc_sys_kernel_random_uuid()) ok = 1; #endif #ifdef TRY_SEED_SYSCTL_LINUX From bb524712f6f3967434a197ee9f391f6cfc6a6374 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 13 Aug 2013 11:12:25 -0400 Subject: [PATCH 3/3] Oops; revert testing code --- arc4random.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arc4random.c b/arc4random.c index 4b6f5f2f12..7a6c4ff548 100644 --- a/arc4random.c +++ b/arc4random.c @@ -327,12 +327,10 @@ arc4_seed_urandom(void) for (i = 0; filenames[i]; ++i) { if (arc4_seed_urandom_helper_(filenames[i]) == 0) { - printf("okay %s\n", filenames[i]); return 0; } } - puts("FAIL"); return -1; } #endif