qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 10/14] linux-user: Call qcrypto_init if not using


From: Richard Henderson
Subject: [Qemu-devel] [PATCH v2 10/14] linux-user: Call qcrypto_init if not using -seed
Date: Wed, 13 Mar 2019 21:55:22 -0700

This is required before using qcrypto_random_bytes
by way of qemu_getrandom.

Cc: Laurent Vivier <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
 linux-user/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

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);
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]