Collect Entropy

Provide a functions that produces a random 64bit value.

u64 get_entropy(void);
Output shall contain at least 8 bits of entropy. If called repeatedly, the most frequent output shall be no more frequent than every 256 calls on average.

You have to generate the entropy yourself without outsourcing the job to random(), getrandom(), the rdrand instruction, etc. Do not use absolute time either. If you use time, always use the delta between two timestamps.

Do not maintain state between calls. If you generate 16 bits of entropy, you cannot store half of them to speed up the next call. Always start from a clean slate.

Evaluation

For performance, the function will be called 256 times. Fastest execution time determines the winner.

For security, all candidates are considered barely secure until someone can predict the output with a probability better than 1/256.

Rationale

Collecting good entropy to seed a random number generator is an important problem. Given 256 bits of entropy, we can seed a cryptographic PRNG and never worry again. But first we have to find 256 bits of entropy.

Most users should be able to ignore this problem and simply use /dev/urandom or similar. But letting someone else solve the problem still means that the problem must be solved. If somebody else could figure out how to solve the problem, you can figure out how to solve the problem.