This PR removes the need for OpenSSL in bitcoind
, and the direct uses of it in the GUI.
It introduces a simple PRNG wrapper around GetOSRand()
that protects against some cases of VM duplication:
- tmp = SHA512(time() || stack_pointer || os_random() || state)
- seed = tmp[0:32]
- state = tmp[32:64]
- Use seed as key for ChaCha20 to produce desired randomness.
Then that wrapper is used to implement GetRandBytes, and GetStrongRandBytes is merged with it. This is overkill for some use cases, and they can later be replaced with FastRandomContext-based solutions (which is pretty strong now, since #9792).
Our cleanse function is also replaced with a self-implemented best-effort explicit zeroing.
It does not remove OpenSSL from existing unit tests or build system.