From adf0b893e8e761363d2ba97386c122bf68f76913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Tue, 13 Jun 2023 17:44:49 +0200 Subject: [PATCH] lx_kit: add random dummy back end This back end can be used in place of the existing jitterentropy based on in case random is not strictly needed by the component but one wants to use the available 'shadow/drivers/char/random.c' implementation. Issue genodelabs/genode-allwinner#21. --- .../dde_linux/src/lib/lx_emul/random_dummy.cc | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 repos/dde_linux/src/lib/lx_emul/random_dummy.cc diff --git a/repos/dde_linux/src/lib/lx_emul/random_dummy.cc b/repos/dde_linux/src/lib/lx_emul/random_dummy.cc new file mode 100644 index 0000000000..f1106d4875 --- /dev/null +++ b/repos/dde_linux/src/lib/lx_emul/random_dummy.cc @@ -0,0 +1,50 @@ +/* + * \brief Dummy source of randomness in lx_emul + * \author Josef Soentgen + * \date 2023-06-13 + */ + +/* + * Copyright (C) 2023 Genode Labs GmbH + * + * This file is distributed under the terms of the GNU General Public License + * version 2. + */ + +/* base/include */ +#include +#include +#include + +/* dde_linux/src/include */ +#include + + +using namespace Genode; + +void lx_emul_random_gen_bytes(void *dst, + unsigned long nr_of_bytes) +{ + /* validate arguments */ + if (dst == nullptr || nr_of_bytes == 0) { + error(__func__, " called with invalid args!"); + return; + } + + warning(__func__, ": dummy implementation used, filling buffer with 0s"); + memset(dst, 0, nr_of_bytes); +} + + +genode_uint32_t lx_emul_random_gen_u32() +{ + warning(__func__, ": dummy implementation used, returning 0"); + return 0; +} + + +genode_uint64_t lx_emul_random_gen_u64() +{ + warning(__func__, ": dummy implementation used, returning 0"); + return 0; +}