genode/repos/libports/src/lib/openssl/rand_unix_c.patch

30 lines
631 B
Diff

--- a/crypto/rand/rand_unix.c
+++ b/crypto/rand/rand_unix.c
@@ -222,6 +222,26 @@
}
return 1;
}
+# elif defined RAND_GENODE
+int RAND_poll(void)
+{
+ unsigned char buf[ENTROPY_NEEDED];
+ char const *rand_file = "/dev/random";
+
+ int fd = open(rand_file, O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "libcrypto: open(%s) failed with '%s'\n",
+ rand_file, strerror(errno));
+ return 0;
+ }
+
+ read(fd, buf, sizeof(buf)); /* XXX check read */
+
+ RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
+ memset(buf, 0, sizeof(buf)); /* XXX make explicit */
+
+ return 1;
+}
# elif defined __OpenBSD__
int RAND_poll(void)
{