Modify the DEVRANDOM source so that the files are kept open persistently.
[openssl.git] / crypto / rand / rand_lib.c
index 050c9d23cc8d62c5bcbdec6f68bc8d20f53de776..d31735c5c45a1b01ca266072995edf3a78f30c8e 100644 (file)
@@ -303,7 +303,7 @@ void rand_drbg_cleanup_additional_data(unsigned char *out, size_t outlen)
     OPENSSL_secure_clear_free(out, outlen);
 }
 
-void rand_fork()
+void rand_fork(void)
 {
     rand_fork_count++;
 }
@@ -324,8 +324,13 @@ DEFINE_RUN_ONCE_STATIC(do_rand_init)
     if (rand_nonce_lock == NULL)
         goto err2;
 
+    if (!rand_pool_init())
+        goto err3;
+
     return 1;
 
+err3:
+    rand_pool_cleanup();
 err2:
     CRYPTO_THREAD_lock_free(rand_meth_lock);
     rand_meth_lock = NULL;
@@ -343,6 +348,7 @@ void rand_cleanup_int(void)
 
     if (meth != NULL && meth->cleanup != NULL)
         meth->cleanup();
+    rand_pool_cleanup();
     RAND_set_rand_method(NULL);
 #ifndef OPENSSL_NO_ENGINE
     CRYPTO_THREAD_lock_free(rand_engine_lock);
@@ -354,6 +360,15 @@ void rand_cleanup_int(void)
     rand_nonce_lock = NULL;
 }
 
+/*
+ * RAND_close_seed_files() ensures that any seed file decriptors are
+ * closed after use.
+ */
+void RAND_keep_random_devices_open(int keep)
+{
+    rand_pool_keep_random_devices_open(keep);
+}
+
 /*
  * RAND_poll() reseeds the default RNG using random input
  *