openssl: use Genode specific RAND backend
The backend merely provides simpler access to '/dev/random' because on Genode the common random device checks are unnecessary. Fixes #1236.devel
parent
baa64bf795
commit
e23a0c8a13
@ -1 +1 @@
|
||||
50bfa7824abc38d4d1eecbc80d8433639c0cb731
|
||||
7b4517a076012f43036912dcc693fb6b035ddf3c
|
||||
|
@ -0,0 +1,29 @@
|
||||
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
|
||||
index e3a6557..27b26e4 100644
|
||||
--- a/crypto/rand/rand_unix.c
|
||||
+++ b/crypto/rand/rand_unix.c
|
||||
@@ -233,6 +233,24 @@ int RAND_poll(void)
|
||||
|
||||
return 1;
|
||||
}
|
||||
+#elif defined RAND_GENODE
|
||||
+int RAND_poll(void)
|
||||
+{
|
||||
+ unsigned char buf[ENTROPY_NEEDED];
|
||||
+
|
||||
+ int fd = open("/dev/random", O_RDONLY);
|
||||
+ if (fd == -1) {
|
||||
+ perror("open");
|
||||
+ 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;
|
||||
+}
|
||||
#else /* !defined(__OpenBSD__) */
|
||||
int RAND_poll(void)
|
||||
{
|
Loading…
Reference in New Issue