1 /*
2  * Insecure but standalone implementation of mbedtls_psa_external_get_random().
3  * Only for use in tests!
4  */
5 /*
6  *  Copyright The Mbed TLS Contributors
7  *  SPDX-License-Identifier: Apache-2.0
8  *
9  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
10  *  not use this file except in compliance with the License.
11  *  You may obtain a copy of the License at
12  *
13  *  http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *  Unless required by applicable law or agreed to in writing, software
16  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  *  See the License for the specific language governing permissions and
19  *  limitations under the License.
20  */
21 
22 #ifndef FAKE_EXTERNAL_RNG_FOR_TEST_H
23 #define FAKE_EXTERNAL_RNG_FOR_TEST_H
24 
25 #include "mbedtls/build_info.h"
26 
27 #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
28 /** Enable the insecure implementation of mbedtls_psa_external_get_random().
29  *
30  * The insecure implementation of mbedtls_psa_external_get_random() is
31  * disabled by default.
32  *
33  * When MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled and the test
34  * helpers are linked into a program, you must enable this before running any
35  * code that uses the PSA subsystem to generate random data (including internal
36  * random generation for purposes such as blinding when the random generation
37  * is routed through PSA).
38  *
39  * You can enable and disable it at any time, regardless of the state
40  * of the PSA subsystem. You may disable it temporarily to simulate a
41  * depleted entropy source.
42  */
43 void mbedtls_test_enable_insecure_external_rng( void );
44 
45 /** Disable the insecure implementation of mbedtls_psa_external_get_random().
46  *
47  * See mbedtls_test_enable_insecure_external_rng().
48  */
49 void mbedtls_test_disable_insecure_external_rng( void );
50 #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
51 
52 #endif /* FAKE_EXTERNAL_RNG_FOR_TEST_H */
53