From 0a1267d335938783c825d35c57b3ec1335017db5 Mon Sep 17 00:00:00 2001 From: Hamza Saleem Date: Tue, 19 Sep 2023 10:13:09 -0400 Subject: [PATCH] updated RNG seed --- src/Utils.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index 8b96174..2bf8e7f 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -57,14 +57,19 @@ void randseed (RandGen &randgen) void randseed (csprng& RNG) { - std::random_device rd; - std::uniform_int_distribution dist(0, 255); - char random_data[128]; - for (unsigned long int i = 0; i < sizeof(random_data); i++) { - random_data[i] = static_cast(dist(rd)); - } - - octet RAW = {0, sizeof(random_data), random_data}; + int i; + unsigned long ran; + char raw[100]; + octet RAW = {0, sizeof(raw), raw}; + + time((time_t *)&ran); + + RAW.len = 100; // fake random seed source + RAW.val[0] = ran; + RAW.val[1] = ran >> 8; + RAW.val[2] = ran >> 16; + RAW.val[3] = ran >> 24; + for (i = 4; i < 100; i++) RAW.val[i] = i; CREATE_CSPRNG(&RNG, &RAW); // initialise strong RNG } \ No newline at end of file