ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
psa_kat_shim.c
Go to the documentation of this file.
1
24
25#include <stddef.h>
26#include <stdint.h>
27
28#include "mbedtls/platform_util.h"
29#include "psa/crypto.h"
30
32typedef enum : uint32_t {
33 k_shim_lcg_mul = 1664525U,
34 k_shim_lcg_add = 1013904223U,
35 k_shim_seed = 0x1234ABCDU,
38
39psa_status_t mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t* context,
40 uint8_t* output,
41 size_t output_size,
42 size_t* output_length)
43{
44 (void)context;
45 static uint32_t s = (uint32_t)k_shim_seed;
46 for (size_t i = 0U; i < output_size; ++i) {
47 s = (s * (uint32_t)k_shim_lcg_mul) + (uint32_t)k_shim_lcg_add;
48 output[i] = (uint8_t)(s >> (uint32_t)k_shim_top_shift);
49 }
50 *output_length = output_size;
51 return PSA_SUCCESS;
52}
53
54#if defined(MBEDTLS_HAVE_TIME) && defined(MBEDTLS_PLATFORM_MS_TIME_ALT)
55mbedtls_ms_time_t mbedtls_ms_time(void)
56{
57 return 0;
58}
59#endif
shim_const_t
LCG multiplier (Numerical Recipes) for the deterministic test RNG.
@ k_shim_lcg_add
Shim lcg add.
@ k_shim_top_shift
Shim top shift.
@ k_shim_seed
Shim seed.
@ k_shim_lcg_mul
Shim lcg mul.
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)