[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Rename crypto_rand_uint32() -> crypto_rand_u32()



commit e0e0338dc42ed786979759d56e0b65f129a5df8c
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Thu Jan 10 12:54:55 2019 +0200

    Rename crypto_rand_uint32() -> crypto_rand_u32()
    
    See https://github.com/torproject/tor/pull/624#discussion_r246453777
---
 src/lib/crypt_ops/crypto_rand.c |  2 +-
 src/lib/crypt_ops/crypto_rand.h |  2 +-
 src/lib/math/prob_distr.c       | 16 ++++++++--------
 src/test/test_prob_distr.c      |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/lib/crypt_ops/crypto_rand.c b/src/lib/crypt_ops/crypto_rand.c
index 7a2c417e5..d148dfb3a 100644
--- a/src/lib/crypt_ops/crypto_rand.c
+++ b/src/lib/crypt_ops/crypto_rand.c
@@ -532,7 +532,7 @@ crypto_rand_unmocked(char *to, size_t n)
  * Draw an unsigned 32-bit integer uniformly at random.
  */
 uint32_t
-crypto_rand_uint32(void)
+crypto_rand_u32(void)
 {
   uint32_t rand;
   crypto_rand((void*)&rand, sizeof(rand));
diff --git a/src/lib/crypt_ops/crypto_rand.h b/src/lib/crypt_ops/crypto_rand.h
index 61fd82c80..874fcd4d0 100644
--- a/src/lib/crypt_ops/crypto_rand.h
+++ b/src/lib/crypt_ops/crypto_rand.h
@@ -27,7 +27,7 @@ int crypto_rand_int(unsigned int max);
 int crypto_rand_int_range(unsigned int min, unsigned int max);
 uint64_t crypto_rand_uint64_range(uint64_t min, uint64_t max);
 time_t crypto_rand_time_range(time_t min, time_t max);
-uint32_t crypto_rand_uint32(void);
+uint32_t crypto_rand_u32(void);
 uint64_t crypto_rand_uint64(uint64_t max);
 double crypto_rand_double(void);
 struct tor_weak_rng_t;
diff --git a/src/lib/math/prob_distr.c b/src/lib/math/prob_distr.c
index 832d3b4d9..f5e5218aa 100644
--- a/src/lib/math/prob_distr.c
+++ b/src/lib/math/prob_distr.c
@@ -458,7 +458,7 @@ random_uniform_01(void)
    * system is broken.
    */
   z = 0;
-  while ((x = crypto_rand_uint32()) == 0) {
+  while ((x = crypto_rand_u32()) == 0) {
     if (z >= 1088)
       /* Your bit sampler is broken.  Go home.  */
       return 0;
@@ -472,8 +472,8 @@ random_uniform_01(void)
    * occur only with measure zero in the uniform distribution on
    * [0, 1].
    */
-  hi = crypto_rand_uint32() | UINT32_C(0x80000000);
-  lo = crypto_rand_uint32() | UINT32_C(0x00000001);
+  hi = crypto_rand_u32() | UINT32_C(0x80000000);
+  lo = crypto_rand_u32() | UINT32_C(0x00000001);
 
   /* Round to nearest scaled significand in [2^63, 2^64].  */
   s = hi*(double)4294967296 + lo;
@@ -1402,7 +1402,7 @@ logistic_sample(const struct dist *dist)
 {
   const struct logistic *L = const_container_of(dist, struct logistic,
     base);
-  uint32_t s = crypto_rand_uint32();
+  uint32_t s = crypto_rand_u32();
   double t = random_uniform_01();
   double p0 = random_uniform_01();
 
@@ -1460,7 +1460,7 @@ log_logistic_sample(const struct dist *dist)
 {
   const struct log_logistic *LL = const_container_of(dist, struct
     log_logistic, base);
-  uint32_t s = crypto_rand_uint32();
+  uint32_t s = crypto_rand_u32();
   double p0 = random_uniform_01();
 
   return sample_log_logistic_scaleshape(s, p0, LL->alpha, LL->beta);
@@ -1517,7 +1517,7 @@ weibull_sample(const struct dist *dist)
 {
   const struct weibull *W = const_container_of(dist, struct weibull,
     base);
-  uint32_t s = crypto_rand_uint32();
+  uint32_t s = crypto_rand_u32();
   double p0 = random_uniform_01();
 
   return sample_weibull(s, p0, W->lambda, W->k);
@@ -1574,7 +1574,7 @@ genpareto_sample(const struct dist *dist)
 {
   const struct genpareto *GP = const_container_of(dist, struct genpareto,
     base);
-  uint32_t s = crypto_rand_uint32();
+  uint32_t s = crypto_rand_u32();
   double p0 = random_uniform_01();
 
   return sample_genpareto_locscale(s, p0, GP->mu, GP->sigma, GP->xi);
@@ -1621,7 +1621,7 @@ genpareto_isf(const struct dist *dist, double p)
 double
 geometric_sample(double p)
 {
-  uint32_t s = crypto_rand_uint32();
+  uint32_t s = crypto_rand_u32();
   double p0 = random_uniform_01();
   return sample_geometric(s, p0, p);
 }
diff --git a/src/test/test_prob_distr.c b/src/test/test_prob_distr.c
index bf0f9e059..75e7e360a 100644
--- a/src/test/test_prob_distr.c
+++ b/src/test/test_prob_distr.c
@@ -1107,7 +1107,7 @@ static uint32_t deterministic_rand_counter;
 static void
 init_deterministic_rand(void)
 {
-  deterministic_rand_counter = crypto_rand_uint32();
+  deterministic_rand_counter = crypto_rand_u32();
 }
 
 /** Produce deterministic randomness for the stochastic tests using the global



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits