24static const char*
s_tag =
"SECTRNG";
36#if defined(RA8_INSECURE_STUB_CRYPTO) || defined(RA8_OFF_TARGET)
46typedef enum : uint64_t {
47 k_xorshift_seed = 0x9E3779B97F4A7C15ULL,
48 k_xorshift_multiplier = 0x2545F4914F6CDD1DULL,
49} ra8_secure_trng_consts64_t;
51typedef enum : uint8_t {
52 k_xorshift_shift_a = 12U,
53 k_xorshift_shift_b = 25U,
54 k_xorshift_shift_c = 27U,
57} ra8_secure_trng_consts8_t;
59typedef enum : uint32_t {
61} ra8_secure_trng_consts32_t;
71static uint64_t
s_state = k_xorshift_seed;
92static uint64_t internal_xorshift64(
void)
95 x ^= x >> k_xorshift_shift_a;
96 x ^= x << k_xorshift_shift_b;
97 x ^= x >> k_xorshift_shift_c;
99 return x * k_xorshift_multiplier;
152 uint32_t written = 0U;
154 while (written < len) {
155 const uint64_t word = internal_xorshift64();
157 for (uint32_t b = 0U; (b < (uint32_t)k_bytes_per_u64) && (written < len); ++b) {
@ k_byte_bits
Bits per byte (SHPR field width).
static const char * s_tag
Logging / check tag.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_err_t priv_ra8_secure_trng_read(uint8_t *out, uint32_t len)
Fill [out, out+len) with TRNG-quality entropy.
ra8_err_t priv_ra8_secure_trng_reset(void)
Reset the TRNG seed (test-only; production reseeds from RSIP).
Secure-side TRNG read API (RSIP-backed entropy).
@ k_ra8_secure_trng_max_bytes
Max bytes per call.