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.
This commit is contained in:
Josef Söntgen 2023-06-13 17:44:49 +02:00 committed by Norman Feske
parent 943c9809ed
commit adf0b893e8

View File

@ -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 <base/log.h>
#include <base/fixed_stdint.h>
#include <util/string.h>
/* dde_linux/src/include */
#include <lx_emul/random.h>
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;
}