summaryrefslogtreecommitdiff
path: root/src/sysdeps/trydevurandom.c
blob: 9c56e94a560d0ede0b307fe8f1a584ba8ccc8424 (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, 64, b)) ;  
}