summaryrefslogtreecommitdiff
path: root/src/sysdeps/trydevurandom.c
blob: 8504f6e895bcb7f99b9f974858d9b6f8a7e3c2b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* ISC license. */

#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>

int main (void)
{
  char a[64] ;
  char b[64] ;
  int fd ;
  fd = open("/dev/urandom", O_RDONLY) ;
  if ((fd == -1) || (read(fd, a, 64) < 64) ) return 111 ;
  close(fd) ;
  fd = open("/dev/urandom", O_RDONLY) ;
  if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ;
  close(fd) ;
  return (!memcmp(a, b, 64)) ;  
}