tTry to gather entropy from /dev/random. - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 60d3db8e6bafa21d807ea31690eddf44bb7ef020
parent 551445b92c1f11d4f543e96790ff29762ab1ad10
Author: wkj 
Date:   Wed, 21 Apr 2004 03:06:03 +0000

Try to gather entropy from /dev/random.

Diffstat:
  A src/lib9/truerand.c                 |      21 +++++++++++++++++++++

1 file changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/lib9/truerand.c b/src/lib9/truerand.c
t@@ -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