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 @@ -207,6 +207,22 @@ static std::mutex cs_rng_state;
207
207
static unsigned char rng_state[32 ] = {0 };
208
208
static uint64_t rng_counter = 0 ;
209
209
210
+ static void AddDataToRng (void * data, size_t len) {
211
+ CSHA512 hasher;
212
+ hasher.Write ((const unsigned char *)&len, sizeof (len));
213
+ hasher.Write ((const unsigned char *)data, len);
214
+ unsigned char buf[64 ];
215
+ {
216
+ std::unique_lock<std::mutex> lock (cs_rng_state);
217
+ hasher.Write (rng_state, sizeof (rng_state));
218
+ hasher.Write ((const unsigned char *)&rng_counter, sizeof (rng_counter));
219
+ ++rng_counter;
220
+ hasher.Finalize (buf);
221
+ memcpy (rng_state, buf + 32 , 32 );
222
+ }
223
+ memory_cleanse (buf, 64 );
224
+ }
225
+
210
226
void GetStrongRandBytes (unsigned char * out, int num)
211
227
{
212
228
assert (num <= 32 );
You can’t perform that action at this time.
0 commit comments