// random generator functions
// ----------------------------------------------------------------------------
-unsigned int init_random_number(int nr, int seed)
+static unsigned int init_random_number_ext(int nr, int seed)
{
if (seed == NEW_RANDOMIZE)
{
return (unsigned int) seed;
}
+static unsigned int prng_seed_gettimeofday(void)
+{
+ struct timeval current_time;
+
+ gettimeofday(¤t_time, NULL);
+
+ prng_seed_bytes(¤t_time, sizeof(current_time));
+
+ return 0;
+}
+
+unsigned int init_random_number(int nr, int seed)
+{
+ return (nr == RANDOM_BETTER ? prng_seed_gettimeofday() :
+ init_random_number_ext(nr, seed));
+}
+
+static unsigned int get_random_number_ext(int nr)
+{
+ return (nr == RANDOM_BETTER ? prng_get_uint() :
+ random_linux_libc(nr));
+}
+
unsigned int get_random_number(int nr, int max)
{
- return (max > 0 ? random_linux_libc(nr) % max : 0);
+ return (max > 0 ? get_random_number_ext(nr) % max : 0);
}
#define RANDOM_ENGINE 0
#define RANDOM_SIMPLE 1
+#define RANDOM_BETTER 2
#define InitEngineRandom(seed) init_random_number(RANDOM_ENGINE, seed)
#define InitSimpleRandom(seed) init_random_number(RANDOM_SIMPLE, seed)
+#define InitBetterRandom(seed) init_random_number(RANDOM_BETTER, seed)
#define GetEngineRandom(max) get_random_number(RANDOM_ENGINE, max)
#define GetSimpleRandom(max) get_random_number(RANDOM_SIMPLE, max)
+#define GetBetterRandom(max) get_random_number(RANDOM_BETTER, max)
// values for getFile...() and putFile...()
#define BYTE_ORDER_BIG_ENDIAN 0
boolean getTokenValueFromString(char *, char **, char **);
+char *getUUIDExt(unsigned int (*function)(int));
char *getUUID(void);
void InitCounter(void);