Any thoughts on a simplified version?
My main goal was to fuzz all random sources way beyond reproducibility, with time being the primary source. Time is envisioned somewhat repeatable (think restart a no realtime-clock device with no entropy gathering and immediately run this) and has 32 bits, but less than 16 could be considered entropy-like. I already made a large simplification for the sake of readability, there's not much to remove that wouldn't defeat the goal. Remember, there are demonstrations of cryptanalysis of hardware RND bias by affecting
heat generation through remotely running processes on a machine.
A white paper on the motivation and methods used may facilitate review without reading code. Here's a summary of
methods, in order they are used:
clockbase(): poll raw system timers twice,
clockrnd(): 512 bit entropy by random-length-loop of various hashings of clockbase(),
platform_check(): ensure repeating calls to clockrnd() never return same result,
keyboard_entropy(): accumulate XORs of clockrnd() before and after every keypress, XOR SHA512 of stretched presses,
random_key(): entropy by keyboard_entropy() + urandom state + time
seed system random generator (urandom) with entropy
privkey initial value by 256 bits urandom XOR sha256 of 512 bits urandom
then random 64-128 loops of:
XOR random 256 bit window of SHA512 of clockrnd()+clockrnd()+entropy
XOR random 256 bit window of SHA512 of 512 bytes urandom
XOR 256 more bits from 2nd urandom object
reseed urandom with SHA512 of the first two XORs plus entropy
By the time we're done we've asked for the epoch time or processor time
about 6000 between 43492-382796 times (or potentially millions on OSX), and done about that many hashes. Then we make a Bitcoin address from that garbage if it is a valid private key...
Or for users: bang on keys, get address.
In other news, I have gotten Python-only
BIP38 passphrase encryption running from a single script. That's native AES, PBKDF2, SCrypt; at least Python includes SHA1 and 2. It takes about
nine minutes to produce the encrypted private key on one core of Core2Quad 2.8GHz...