#ifdef DEVRANDOM
static const char *randomfiles[] = { DEVRANDOM };
struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])];
- int fd,i;
+ int fd;
+ unsigned int i;
#endif
#ifdef DEVRANDOM_EGD
static const char *egdsockets[] = { DEVRANDOM_EGD, NULL };
* have this. Use /dev/urandom if you can as /dev/random may block
* if it runs out of random entries. */
- for (i=0; i<sizeof(randomfiles)/sizeof(randomfiles[0]) && n < ENTROPY_NEEDED; i++)
+ for (i = 0; (i < sizeof(randomfiles)/sizeof(randomfiles[0])) &&
+ (n < ENTROPY_NEEDED); i++)
{
if ((fd = open(randomfiles[i], O_RDONLY
#ifdef O_NONBLOCK
{
struct timeval t = { 0, 10*1000 }; /* Spend 10ms on
each file. */
- int r,j;
+ int r;
+ unsigned int j;
fd_set fset;
struct stat *st=&randomstats[i];
for (j=0;j<i;j++)
{
if (randomstats[j].st_ino==st->st_ino &&
- randomstats[j].st_dev!=st->st_dev)
+ randomstats[j].st_dev==st->st_dev)
break;
}
if (j<i) { close(fd); continue; }
do
{
+#if defined(OPENSSL_SYS_BEOS_R5)
+ /* select() is broken in BeOS R5, so we simply
+ * try to read something and snooze if we couldn't: */
+ r=read(fd,(unsigned char *)tmpbuf+n,
+ ENTROPY_NEEDED-n);
+ if (r > 0)
+ n += r;
+ else if (r == 0)
+ snooze(t.tv_usec);
+#else
FD_ZERO(&fset);
FD_SET(fd, &fset);
r = -1;
if (r > 0)
n += r;
}
-
+#endif
/* Some Unixen will update t, some
won't. For those who won't, give
up here, otherwise, we will do
l=time(NULL);
RAND_add(&l,sizeof(l),0.0);
+#if defined(OPENSSL_SYS_BEOS)
+ {
+ system_info sysInfo;
+ get_system_info(&sysInfo);
+ RAND_add(&sysInfo,sizeof(sysInfo),0);
+ }
+#endif
+
#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
return 1;
#else