diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-05-02 23:34:21 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-05-02 23:34:21 +0800 |
| commit | b1b0b1aad65b57900e18539d6f25b38e51801822 (patch) | |
| tree | 905062ec0dec32f9106e0e6a2da48b818c7924e0 /na/include | |
| parent | 4e7a069f8c39c2f97cde675492d7c55491f10fa3 (diff) | |
| download | lume-b1b0b1aad65b57900e18539d6f25b38e51801822.tar.gz lume-b1b0b1aad65b57900e18539d6f25b38e51801822.tar.xz | |
feat: implement hardware random number generation and early PRNG initialization
Diffstat (limited to 'na/include')
| -rw-r--r-- | na/include/lume/random.h | 26 |
1 files changed, 26 insertions, 0 deletions
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 <lume/types.h> + +/* + * 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); |
