Refactor crypto RNG; add getrandom() support