ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
secure_trng.c File Reference

Secure-side TRNG read implementation (host PRNG stub). More...

#include <stdint.h>
#include "ra8_check.h"
#include "ra8_err.h"
#include "secure_trng_internal.h"
Include dependency graph for secure_trng.c:

Go to the source code of this file.

Functions

ra8_err_t priv_ra8_secure_trng_reset (void)
 Reset the TRNG seed (test-only; production reseeds from RSIP).
ra8_err_t priv_ra8_secure_trng_read (uint8_t *out, uint32_t len)
 Fill [out, out+len) with TRNG-quality entropy.

Variables

static const char * s_tag = "SECTRNG"

Detailed Description

Secure-side TRNG read implementation (host PRNG stub).

Tag
[Ring 5 / SECAPP] {World: S}

Host-friendly xorshift64* core. The real RSIP TRNG hookup lands in ; the wrapper interface here is the part the NSC veneer ra8_nsc_trng_read depends on, so the seam is committed now.

Definition in file secure_trng.c.

Function Documentation

◆ priv_ra8_secure_trng_read()

ra8_err_t priv_ra8_secure_trng_read ( uint8_t * out,
uint32_t len )
nodiscard

Fill [out, out+len) with TRNG-quality entropy.

Pulls 8 bytes at a time from the entropy core and copies the needed prefix into out. The caller must ensure out is already a secure buffer – the NSC veneer copies bytes from here back to the NS destination, so the secure-side function itself never touches NS memory.

Parameters
[out]outDestination buffer (secure scratch).
[in]lenBytes to fill, 1..k_ra8_secure_trng_max_bytes.
Returns
ra8_err_t error code.
Return values
k_ra8_okBytes written.
k_ra8_err_null_ptrout was NULL.
k_ra8_err_invalid_arglen zero or above the cap.
Precondition
out non-NULL and points to len bytes of secure RAM.
Postcondition
out[0..len-1] contains entropy bytes.
Note
Thread safety: not thread-safe; the seed is a single static.
Since
0.1.0

Definition at line 179 of file secure_trng.c.

References k_ra8_err_not_supported, RA8_CHECK_NULL_PTR, and s_tag.

◆ priv_ra8_secure_trng_reset()

ra8_err_t priv_ra8_secure_trng_reset ( void )
nodiscard

Reset the TRNG seed (test-only; production reseeds from RSIP).

Returns
ra8_err_t error code (currently always k_ra8_ok).
Precondition
Called from secure boot before any veneer can fire.
Postcondition
Subsequent reads produce a deterministic stream rooted at the new seed.
Note
Thread safety: secure-world only, single-threaded init.
Since
0.1.0

Definition at line 174 of file secure_trng.c.

References k_ra8_err_not_supported.

Variable Documentation

◆ s_tag

const char* s_tag = "SECTRNG"
static

Definition at line 24 of file secure_trng.c.