-- COPYING file in the source package for more information.
--
-local urandom = assert(io.open("/dev/urandom", "r"));
+local ok, crand = pcall(require, "util.crand");
+if ok then return crand; end
+
+local urandom, urandom_err = io.open("/dev/urandom", "r");
local function seed()
end
return urandom:read(n);
end
+if not urandom then
+ function bytes()
+ error("Unable to obtain a secure random number generator, please see https://prosody.im/doc/random ("..urandom_err..")");
+ end
+end
+
return {
seed = seed;
bytes = bytes;