modify using KRNG

try /dev/random first with O_NONBLOCK mode to obtain good entropy.
try /dev/urandom second if reading from /dev/random fail.

keeping fallback function in case both of above fail.