Mbed TLS v3.5.2
Loading...
Searching...
No Matches
psa_util.h
Go to the documentation of this file.
1
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 */
10
11#ifndef MBEDTLS_PSA_UTIL_H
12#define MBEDTLS_PSA_UTIL_H
14
15#include "mbedtls/build_info.h"
16
17#if defined(MBEDTLS_PSA_CRYPTO_C)
18
19/* Expose whatever RNG the PSA subsystem uses to applications using the
20 * mbedtls_xxx API. The declarations and definitions here need to be
21 * consistent with the implementation in library/psa_crypto_random_impl.h.
22 * See that file for implementation documentation. */
23
24
25/* The type of a `f_rng` random generator function that many library functions
26 * take.
27 *
28 * This type name is not part of the Mbed TLS stable API. It may be renamed
29 * or moved without warning.
30 */
31typedef int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size);
32
33#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
34
70int mbedtls_psa_get_random(void *p_rng,
71 unsigned char *output,
72 size_t output_size);
73
84#define MBEDTLS_PSA_RANDOM_STATE NULL
85
86#else /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
87
88#if defined(MBEDTLS_CTR_DRBG_C)
89#include "mbedtls/ctr_drbg.h"
92#elif defined(MBEDTLS_HMAC_DRBG_C)
93#include "mbedtls/hmac_drbg.h"
96#endif
98
99#define MBEDTLS_PSA_RANDOM_STATE mbedtls_psa_random_state
100
101#endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
102
103#endif /* MBEDTLS_PSA_CRYPTO_C */
104#endif /* MBEDTLS_PSA_UTIL_H */
This file contains definitions and functions for the CTR_DRBG pseudorandom generator.
int mbedtls_ctr_drbg_random(void *p_rng, unsigned char *output, size_t output_len)
This function uses CTR_DRBG to generate random data.
The HMAC_DRBG pseudorandom generator.
int mbedtls_hmac_drbg_random(void *p_rng, unsigned char *output, size_t out_len)
This function uses HMAC_DRBG to generate random data.
Build-time configuration info.
Macro wrapper for struct's members.
mbedtls_ctr_drbg_context mbedtls_psa_drbg_context_t
Definition psa_util.h:90
static mbedtls_f_rng_t *const mbedtls_psa_get_random
Definition psa_util.h:91
mbedtls_psa_drbg_context_t *const mbedtls_psa_random_state
int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size)
Definition psa_util.h:31
The CTR_DRBG context structure.
Definition ctr_drbg.h:156