From b1b0b1aad65b57900e18539d6f25b38e51801822 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sat, 2 May 2026 23:34:21 +0800 Subject: feat: implement hardware random number generation and early PRNG initialization --- na/include/lume/random.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 na/include/lume/random.h (limited to 'na/include') diff --git a/na/include/lume/random.h b/na/include/lume/random.h new file mode 100644 index 0000000..0705b1b --- /dev/null +++ b/na/include/lume/random.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2026 Richard Qin */ + +#pragma once + +#include + +/* + * MI: Machine-Independent Random Number Generator API + * + * Provides early PRNG and eventually a full CSPRNG. + */ + +/* + * Initialize early PRNG with a seed (e.g., from FDT). + * If seed is 0, attempts to use hardware TRNG or falls back to timer jitter. + */ +void random_early_init(uint64 seed); + +/* Consume random bits */ +uint64 get_random_u64(); +uint32 get_random_u32(); +void get_random_bytes(void* buf, size_t len); + +/* Inject entropy (for future interrupt/device mixing) */ +void add_device_randomness(const void* buf, size_t len); -- cgit v1.2.3