[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 12/24] linux-user: Call qcrypto_random_init if no
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v7 12/24] linux-user: Call qcrypto_random_init if not using -seed |
Date: |
Tue, 14 May 2019 12:16:41 -0700 |
When not using -seed, we will use the random part of the crypto
subsystem. For softmmu, we initialize the full qcrypto_init,
because we use crypto for reasons other than random numbers.
Reviewed-by: Laurent Vivier <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/main.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 7e704845c0..4c72f07555 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -39,6 +39,7 @@
#include "trace/control.h"
#include "target_elf.h"
#include "cpu_loop-common.h"
+#include "crypto/random.h"
char *exec_path;
@@ -688,17 +689,26 @@ int main(int argc, char **argv, char **envp)
if (seed_optarg == NULL) {
seed_optarg = getenv("QEMU_RAND_SEED");
}
- if (seed_optarg != NULL) {
- unsigned long long seed;
+ {
+ Error *err = NULL;
+ if (seed_optarg != NULL) {
+ unsigned long long seed;
- /* This will go away with the last user of rand(). */
- if (parse_uint_full(seed_optarg, &seed, 0) != 0) {
- fprintf(stderr, "Invalid seed number: %s\n", seed_optarg);
- exit(EXIT_FAILURE);
+ /* This will go away with the last user of rand(). */
+ if (parse_uint_full(seed_optarg, &seed, 0) != 0) {
+ fprintf(stderr, "Invalid seed number: %s\n", seed_optarg);
+ exit(EXIT_FAILURE);
+ }
+ srand(seed);
+
+ qemu_guest_random_seed_main(seed_optarg, &err);
+ } else {
+ qcrypto_random_init(&err);
+ }
+ if (err) {
+ error_reportf_err(err, "cannot initialize crypto: ");
+ exit(1);
}
- srand(seed);
-
- qemu_guest_random_seed_main(seed_optarg, &error_fatal);
}
target_environ = envlist_to_environ(envlist, NULL);
--
2.17.1
- [Qemu-devel] [PATCH v7 00/24] Add qemu_getrandom and ARMv8.5-RNG etc, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 01/24] build: Link user-only with crypto-rng-obj-y, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 02/24] crypto: Reverse code blocks in random-platform.c, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 03/24] crypto: Do not fail for EINTR during qcrypto_random_bytes, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 04/24] crypto: Use O_CLOEXEC in qcrypto_random_init, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 05/24] crypto: Use getrandom for qcrypto_random_bytes, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 07/24] ui/vnc: Split out authentication_failed, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 06/24] crypto: Change the qcrypto_random_bytes buffer type to void*, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 09/24] util: Add qemu_guest_getrandom and associated routines, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 08/24] ui/vnc: Use gcrypto_random_bytes for start_auth_vnc, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 12/24] linux-user: Call qcrypto_random_init if not using -seed,
Richard Henderson <=
- [Qemu-devel] [PATCH v7 10/24] cpus: Initialize pseudo-random seeds for all guest cpus, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 13/24] linux-user: Use qemu_guest_getrandom_nofail for AT_RANDOM, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 11/24] linux-user: Initialize pseudo-random seeds for all guest cpus, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 15/24] linux-user: Remove srand call, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 14/24] linux-user/aarch64: Use qemu_guest_getrandom for PAUTH keys, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 17/24] hw/misc/nrf51_rng: Use qemu_guest_getrandom_nofail, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 16/24] aspeed/scu: Use qemu_guest_getrandom_nofail, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 18/24] hw/misc/bcm2835_rng: Use qemu_guest_getrandom_nofail, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 19/24] hw/misc/exynos4210_rng: Use qemu_guest_getrandom, Richard Henderson, 2019/05/14
- [Qemu-devel] [PATCH v7 20/24] target/arm: Put all PAC keys into a structure, Richard Henderson, 2019/05/14