[tor-commits] [tor/master] Add a quick test for get_thread_fast_rng()

asn at torproject.org asn at torproject.org
Fri Feb 22 14:12:41 UTC 2019


commit 208f04e9b8241569fe314f6d5cb65521c9b55d8b
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Feb 19 15:36:11 2019 -0500

    Add a quick test for get_thread_fast_rng()
---
 src/test/test_crypto_rng.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/test/test_crypto_rng.c b/src/test/test_crypto_rng.c
index 23b0c6651..6b7749a88 100644
--- a/src/test/test_crypto_rng.c
+++ b/src/test/test_crypto_rng.c
@@ -218,6 +218,14 @@ test_crypto_rng_fast(void *arg)
     tt_int_op(counts[i], OP_GT, 0);
   }
 
+  /* per-thread rand_fast shouldn't crash or leak. */
+  crypto_fast_rng_t *t_rng = get_thread_fast_rng();
+  for (int i = 0; i < N; ++i) {
+    uint64_t u64 = crypto_fast_rng_get_uint64(t_rng, UINT64_C(1)<<40);
+    tt_u64_op(u64, OP_GE, 0);
+    tt_u64_op(u64, OP_LT, UINT64_C(1)<<40);
+  }
+
  done:
   crypto_fast_rng_free(rng);
 }





More information about the tor-commits mailing list