]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rename functions for clarity
authorAlan T. DeKok <aland@freeradius.org>
Mon, 22 Jan 2024 14:08:01 +0000 (09:08 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 22 Jan 2024 18:52:05 +0000 (13:52 -0500)
in preparation for allowing forced seeds

src/lib/util/dict_tokenize.c
src/lib/util/isaac.c
src/lib/util/rand.c
src/lib/util/rand.h
src/modules/rlm_eap/rlm_eap.c

index 514838ecfe337564dc6c3b2b1aa6caf7291ff2b3..bc789175e5dd199b0e3769c9db62f54d4a9020be 100644 (file)
@@ -2177,7 +2177,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx,
        /*
         *      Seed the random pool with data.
         */
-       fr_rand_seed(&statbuf, sizeof(statbuf));
+       fr_rand_mixin(&statbuf, sizeof(statbuf));
 
        memset(&base_flags, 0, sizeof(base_flags));
 
index 34a829076fb450282b995ff0c58c4eaf88f8334f..6e1e28cdba658403bc1b261b6d2eb44bf80f8ee3 100644 (file)
@@ -63,7 +63,7 @@ do { \
 } while (0)
 
 /* if (flag==1), then use the contents of randrsl[] to initialize mm[]. */
-void fr_rand_init(fr_randctx *ctx, int flag)
+void fr_isaac_init(fr_randctx *ctx, int flag)
 {
        int             i;
        uint32_t        a, b, c, d, e, f, g, h;
@@ -123,7 +123,7 @@ int main()
 
        for (i = 0; i < 256; ++i) ctx.randrsl[i] = (uint32_t)0;
 
-       fr_rand_init(&ctx, 1);
+       fr_isaac_init(&ctx, 1);
        for (i = 0; i < 2; ++i) {
                fr_isaac(&ctx);
                for (j = 0; j < 256; ++j) {
index 2fbcc9759dd435eb518a763afb1570e5f2174f64..9550a142fc7d7dd9f59dd204c45cab8f2391af4c 100644 (file)
@@ -31,11 +31,11 @@ RCSID("$Id$")
 static _Thread_local fr_randctx fr_rand_pool;          //!< A pool of pre-generated random integers
 static _Thread_local bool fr_rand_initialized = false;
 
-/** Seed the random number generator
+/** Mix data into the random number generator.
  *
  * May be called any number of times.
  */
-void fr_rand_seed(void const *data, size_t size)
+void fr_rand_mixin(void const *data, size_t size)
 {
        uint32_t hash;
 
@@ -75,7 +75,7 @@ void fr_rand_seed(void const *data, size_t size)
                        memcpy((void *) &fr_rand_pool.randrsl[0], &when, sizeof(when));
                }
 
-               fr_rand_init(&fr_rand_pool, 1);
+               fr_isaac_init(&fr_rand_pool, 1);
                fr_rand_pool.randcnt = 0;
                fr_rand_initialized = 1;
        }
@@ -105,7 +105,7 @@ uint32_t fr_rand(void)
         *      Ensure that the pool is initialized.
         */
        if (!fr_rand_initialized) {
-               fr_rand_seed(NULL, 0);
+               fr_rand_mixin(NULL, 0);
        }
 
        num = fr_rand_pool.randrsl[fr_rand_pool.randcnt++];
index d9326dff41c5c832f59ff26c93d996adca2d1324..0f53ea1fa9076fdaa856bef6e66279f362e25b6f 100644 (file)
@@ -56,12 +56,12 @@ typedef struct {
 } fr_fast_rand_t;
 
 void           fr_isaac(fr_randctx *ctx);
-void           fr_rand_init(fr_randctx *ctx, int flag);
+void           fr_isaac_init(fr_randctx *ctx, int flag);
 /** @hidecallergraph */
 uint32_t       fr_rand(void);  /* like rand(), but better. */
 void           fr_rand_buffer(void *start, size_t length) CC_HINT(nonnull);
 void           fr_rand_str(uint8_t *out, size_t len, char class);
-void           fr_rand_seed(void const *, size_t ); /* seed the random pool */
+void           fr_rand_mixin(void const *, size_t ); /* seed the random pool */
 uint32_t       fr_fast_rand(fr_fast_rand_t *ctx);
 
 #ifdef __cplusplus
index 1eecf3b9cd9d435e45ad97af4fe21b49221016f3..eadf9012b1d4a386c120c470b501369c4724832a 100644 (file)
@@ -1065,7 +1065,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
         *      Create our own random pool.
         */
        for (i = 0; i < 256; i++) inst->rand_pool.randrsl[i] = fr_rand();
-       fr_rand_init(&inst->rand_pool, 1);
+       fr_isaac_init(&inst->rand_pool, 1);
        inst->rand_pool.randcnt = 0;
 
        return 0;