X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fuuid.c;h=2aac4c7201f661ec1f168dac820b8ff5f45def85;hb=67b30fcde789088b2e43407167f9ad656c2cc1e5;hp=9aaa91590d9a1bc0c025831f8674328c9dea1bbe;hpb=5f55c39b21e69025045437ffbd3bb98fe6ce2e89;p=openvswitch diff --git a/lib/uuid.c b/lib/uuid.c index 9aaa9159..2aac4c72 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -25,8 +25,8 @@ #include #include "aes128.h" +#include "entropy.h" #include "sha1.h" -#include "socket-util.h" #include "util.h" static struct aes128 key; @@ -34,7 +34,6 @@ static uint64_t counter[2]; BUILD_ASSERT_DECL(sizeof counter == 16); static void do_init(void); -static void read_urandom(void *buffer, size_t n); /* * Initialize the UUID module. Aborts the program with an error message if @@ -180,27 +179,6 @@ error: return false; } -static void -read_urandom(void *buffer, size_t n) -{ - static const char urandom[] = "/dev/urandom"; - size_t bytes_read; - int error; - int fd; - - fd = open(urandom, O_RDONLY); - if (fd < 0) { - ovs_fatal(errno, "%s: open failed", urandom); - } - error = read_fully(fd, buffer, n, &bytes_read); - if (error == EOF) { - ovs_fatal(0, "%s: unexpected end of file", urandom); - } else if (error) { - ovs_fatal(error, "%s: read error", urandom); - } - close(fd); -} - static void do_init(void) { @@ -213,7 +191,7 @@ do_init(void) gid_t gid; /* Get seed data. */ - read_urandom(random_seed, sizeof random_seed); + get_entropy_or_die(random_seed, sizeof random_seed); if (gettimeofday(&now, NULL)) { ovs_fatal(errno, "gettimeofday failed"); } @@ -236,5 +214,5 @@ do_init(void) aes128_schedule(&key, sha1); /* Generate initial counter. */ - read_urandom(counter, sizeof counter); + get_entropy_or_die(counter, sizeof counter); }