Move random number file reading to shared function

The random number providers that read from /dev/random and /dev/urandom
respectively is the same apart from the name of the file they are
reading from. Use a shared function that both can use so that we don't
have code duplication.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>