comparison randombytes.c @ 9:765303f4f2da

Attempt to fix randombytes.c for unpatched NaCl
author Ivo Smits <Ivo@UCIS.nl>
date Thu, 14 Jul 2011 16:49:21 +0200
parents a139bed53614
children
comparison
equal deleted inserted replaced
8:a1fc155ca80b 9:765303f4f2da
1 #include <time.h> 1 #include <time.h>
2 2
3 void randombytes(unsigned char *x,unsigned long long xlen) { 3 void randombytes(unsigned char *x,unsigned long long xlen) {
4 int fd = open("/dev/urandom",O_RDONLY); 4 FILE* fd = fopen("/dev/urandom", "rb");
5 if (fd != -1) { 5 if (fd != NULL) {
6 fread(x, 1, xlen, fd); 6 fread(x, 1, xlen, fd);
7 fclose(fd); 7 fclose(fd);
8 } else { 8 } else {
9 srand(time(NULL)); 9 srand(time(NULL));
10 for (int i = 0; i < xlen; i++) x[i] = rand() % 256; 10 for (int i = 0; i < xlen; i++) x[i] = rand() % 256;