commit 60d3db8e6bafa21d807ea31690eddf44bb7ef020 from: wkj date: Wed Apr 21 03:06:03 2004 UTC Try to gather entropy from /dev/random. commit - 551445b92c1f11d4f543e96790ff29762ab1ad10 commit + 60d3db8e6bafa21d807ea31690eddf44bb7ef020 blob - /dev/null blob + aaf10f0a95020d62d8386d9ae5381d619bfdf93d (mode 644) --- /dev/null +++ src/lib9/truerand.c @@ -0,0 +1,21 @@ +#include +#include + +ulong +truerand(void) +{ + int i, n; + uchar buf[sizeof(ulong)]; + static int randfd = -1; + + if(randfd < 0){ + randfd = open("/dev/random", OREAD); + fcntl(randfd, F_SETFD, FD_CLOEXEC); + } + if(randfd < 0) + sysfatal("can't open /dev/random: %r"); + for(i=0; i