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 #if !defined(MBEDTLS_CONFIG_FILE) 26 #include "mbedtls/config.h" 27 #else 28 #include MBEDTLS_CONFIG_FILE 29 #endif 30 31 #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) 32 /** Enable the insecure implementation of mbedtls_psa_external_get_random(). 33 * 34 * The insecure implementation of mbedtls_psa_external_get_random() is 35 * disabled by default. 36 * 37 * When MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled and the test 38 * helpers are linked into a program, you must enable this before running any 39 * code that uses the PSA subsystem to generate random data (including internal 40 * random generation for purposes such as blinding when the random generation 41 * is routed through PSA). 42 * 43 * You can enable and disable it at any time, regardless of the state 44 * of the PSA subsystem. You may disable it temporarily to simulate a 45 * depleted entropy source. 46 */ 47 void mbedtls_test_enable_insecure_external_rng( void ); 48 49 /** Disable the insecure implementation of mbedtls_psa_external_get_random(). 50 * 51 * See mbedtls_test_enable_insecure_external_rng(). 52 */ 53 void mbedtls_test_disable_insecure_external_rng( void ); 54 #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ 55 56 #endif /* FAKE_EXTERNAL_RNG_FOR_TEST_H */ 57