(des_rand_data): Use a table with random devices.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@745 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-09-15 21:39:23 +00:00
parent 56d530b451
commit 682884b05a

View File

@@ -156,26 +156,18 @@ des_rand_data(unsigned char *data, int size)
struct sigaction sa, osa; struct sigaction sa, osa;
int i, j; int i, j;
pid_t pid; pid_t pid;
char *rnd_devices[] = {"/dev/random",
/* "/dev/srandom",
* If there is a /dev/random it's use is preferred. NULL};
*/ char **p;
{
int fd = open("/dev/random", O_RDONLY); for(p = rnd_devices; *p; p++) {
if (fd != -1 && read(fd, data, size) == size) int fd = open(*p, O_RDONLY | O_NDELAY);
{
close(fd); if(fd >= 0 && read(fd, data, size) == size) {
return; close(fd);
} return;
close(fd); }
}
{
int fd = open("/dev/rnd", O_RDONLY);
if (fd != -1 && read(fd, data, size) == size)
{
close(fd);
return;
}
close(fd); close(fd);
} }