diff mbox series

[v2,10/14] linux-user: Call qcrypto_init if not using -seed

Message ID 20190314045526.13342-11-richard.henderson@linaro.org
State New
Headers show
Series Add qemu_getrandom and ARMv8.5-RNG | expand

Commit Message

Richard Henderson March 14, 2019, 4:55 a.m. UTC
This is required before using qcrypto_random_bytes
by way of qemu_getrandom.

Cc: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.17.1
diff mbox series

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index 9682e81610..192bf759b8 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -38,6 +38,7 @@ 
 #include "trace/control.h"
 #include "target_elf.h"
 #include "cpu_loop-common.h"
+#include "crypto/init.h"
 
 char *exec_path;
 
@@ -688,6 +689,13 @@  int main(int argc, char **argv, char **envp)
     }
     if (seed_optarg != NULL) {
         qemu_seedrandom_main(seed_optarg, &error_fatal);
+    } else {
+        /* ??? This assumes qcrypto is only used by qemu_getrandom.  */
+        Error *err = NULL;
+        if (qcrypto_init(&err) < 0) {
+            error_reportf_err(err, "cannot initialize crypto: ");
+            exit(1);
+        }
     }
 
     target_environ = envlist_to_environ(envlist, NULL);