Mbed TLS v3.5.0
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
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22
23#ifndef MBEDTLS_PSA_UTIL_H
24#define MBEDTLS_PSA_UTIL_H
26
27#include "mbedtls/build_info.h"
28
29#if defined(MBEDTLS_PSA_CRYPTO_C)
30
31/* Expose whatever RNG the PSA subsystem uses to applications using the
32 * mbedtls_xxx API. The declarations and definitions here need to be
33 * consistent with the implementation in library/psa_crypto_random_impl.h.
34 * See that file for implementation documentation. */
35
36
37/* The type of a `f_rng` random generator function that many library functions
38 * take.
39 *
40 * This type name is not part of the Mbed TLS stable API. It may be renamed
41 * or moved without warning.
42 */
43typedef int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size);
44
45#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
46
82int mbedtls_psa_get_random(void *p_rng,
83 unsigned char *output,
84 size_t output_size);
85
96#define MBEDTLS_PSA_RANDOM_STATE NULL
97
98#else /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
99
100#if defined(MBEDTLS_CTR_DRBG_C)
101#include "mbedtls/ctr_drbg.h"
104#elif defined(MBEDTLS_HMAC_DRBG_C)
105#include "mbedtls/hmac_drbg.h"
108#endif
110
111#define MBEDTLS_PSA_RANDOM_STATE mbedtls_psa_random_state
112
113#endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
114
115#endif /* MBEDTLS_PSA_CRYPTO_C */
116#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:102
static mbedtls_f_rng_t *const mbedtls_psa_get_random
Definition: psa_util.h:103
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:43
The CTR_DRBG context structure.
Definition: ctr_drbg.h:168