Skip to content

Commit

Permalink
updated RNG seed
Browse files Browse the repository at this point in the history
  • Loading branch information
hsaleemsupra committed Sep 19, 2023
1 parent 1643337 commit 0a1267d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ void randseed (RandGen &randgen)
void randseed (csprng& RNG)
{

std::random_device rd;
std::uniform_int_distribution<unsigned char> dist(0, 255);
char random_data[128];
for (unsigned long int i = 0; i < sizeof(random_data); i++) {
random_data[i] = static_cast<char>(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
}

0 comments on commit 0a1267d

Please sign in to comment.