Branch: Tag:

2017-11-26

2017-11-26 01:30:25 by Martin Nilsson <nilsson@fastmail.com>

Added support for automatic entropy underflow management.

9:   inherit Builtin.RandomInterface;   inherit Nettle.AES128_CTR_DRBG;    - #define SEEDLEN 32/* keylen + ctrlen */ + #define SEEDLEN 32 /* keylen + ctrlen */      //! Instantiate a random generator without derivation function, with   //! the given initial entropy and personalization.
22:    personalization = sprintf("%-*'\0's", SEEDLEN, personalization);    entropy ^= personalization;    } -  ::reseed(entropy); +  reseed(entropy);   } -  +  + protected .Interface rnd; +  + //! This method is called when a reseed is forced. By default new + //! entropy is gethered from Random.System. Overload to change the + //! default behaviour. + protected void entropy_underflow() + { +  if(!rnd) rnd = .System(); +  reseed(rnd->random_string(32)); + }