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

Mbed TLS PSA random-source adapter for the HTTPS client demo. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_rsip.h"
#include "psa/crypto.h"
Include dependency graph for mbedtls_psa_rng.c:

Go to the source code of this file.

Functions

psa_status_t mbedtls_psa_external_get_random (mbedtls_psa_external_random_context_t *context, uint8_t *output, size_t output_size, size_t *output_length)
 PSA external RNG hook – feeds RSIP TRNG straight into PSA.

Detailed Description

Mbed TLS PSA random-source adapter for the HTTPS client demo.

Tag
[Ring 6 / APP] {World: S}

Implements the Mbed TLS external PSA random callback using the RA8D2 RSIP true-random generator. Keeping the vendor callback in its own translation unit isolates the TLS adaptation boundary from the ThreadX and HTTP session orchestration in main.c.

Author
Brighton Sikarskie
Date
2026-08-27
Since
0.1.0

Definition in file mbedtls_psa_rng.c.

Function Documentation

◆ mbedtls_psa_external_get_random()

psa_status_t mbedtls_psa_external_get_random ( mbedtls_psa_external_random_context_t * context,
uint8_t * output,
size_t output_size,
size_t * output_length )

PSA external RNG hook – feeds RSIP TRNG straight into PSA.

Mbed TLS 4.x removed MBEDTLS_ENTROPY_C / MBEDTLS_CTR_DRBG_C from the standard build path. With MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG the SSL layer pulls random bytes from this callback (via psa_generate_random) instead of running an in-tree DRBG.

Parameters
[in,out]contextPSA's per-process external RNG context (unused).
[out]outputOutput buffer.
[in]output_sizeBytes requested.
[out]output_lengthBytes actually produced.
Returns
PSA status describing whether random generation succeeded.
Return values
PSA_SUCCESSExactly output_size random bytes were produced.
PSA_ERROR_INVALID_ARGUMENTAn output pointer is null.
PSA_ERROR_HARDWARE_FAILUREThe RSIP TRNG returned an error.
Precondition
RSIP has been initialized by ra8_rsip_init().
output and output_length are non-null caller-owned storage.
Postcondition
On success output contains output_size bytes from the RSIP TRNG.
On success output_length equals output_size.
An invalid pointer emits an error log before returning PSA_ERROR_INVALID_ARGUMENT; no output storage is modified.
Note
Not thread-safe; callers must serialize across threads.
See also
psa_generate_random
ra8_rsip_trng_read
Since
0.1.0

Definition at line 54 of file mbedtls_psa_rng.c.

References k_ra8_ok, RA8_CHECK_NULL_PTR_RETURN, and ra8_rsip_trng_read().