File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,22 @@ static std::mutex cs_rng_state;
209209static unsigned char rng_state[32 ] = {0 };
210210static uint64_t rng_counter = 0 ;
211211
212+ static void AddDataToRng (void * data, size_t len) {
213+ CSHA512 hasher;
214+ hasher.Write ((const unsigned char *)&len, sizeof (len));
215+ hasher.Write ((const unsigned char *)data, len);
216+ unsigned char buf[64 ];
217+ {
218+ std::unique_lock<std::mutex> lock (cs_rng_state);
219+ hasher.Write (rng_state, sizeof (rng_state));
220+ hasher.Write ((const unsigned char *)&rng_counter, sizeof (rng_counter));
221+ ++rng_counter;
222+ hasher.Finalize (buf);
223+ memcpy (rng_state, buf + 32 , 32 );
224+ }
225+ memory_cleanse (buf, 64 );
226+ }
227+
212228void GetStrongRandBytes (unsigned char * out, int num)
213229{
214230 assert (num <= 32 );
You can’t perform that action at this time.
0 commit comments