skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

trydevurandom.c (420B)


      1 /* ISC license. */
      2 
      3 #include <string.h>
      4 #include <unistd.h>
      5 #include <fcntl.h>
      6 #include <sys/stat.h>
      7 
      8 int main (void)
      9 {
     10   char a[64] ;
     11   char b[64] ;
     12   int fd ;
     13   fd = open("/dev/urandom", O_RDONLY) ;
     14   if ((fd == -1) || (read(fd, a, 64) < 64) ) return 111 ;
     15   close(fd) ;
     16   fd = open("/dev/urandom", O_RDONLY) ;
     17   if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ;
     18   close(fd) ;
     19   return (!memcmp(a, b, 64)) ;  
     20 }