Gilles Peskine | 514a8fd | 2020-11-13 17:41:53 +0100 | [diff] [blame] | 1 | /** \file psa_crypto_helpers.c |
| 2 | * |
| 3 | * \brief Helper functions to test PSA crypto functionality. |
| 4 | */ |
| 5 | |
| 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 | #include <test/helpers.h> |
| 24 | #include <test/macros.h> |
| 25 | |
| 26 | #if defined(MBEDTLS_PSA_CRYPTO_C) |
| 27 | |
| 28 | #include <psa/crypto.h> |
| 29 | |
Gilles Peskine | 4fc21fd | 2020-11-13 18:47:18 +0100 | [diff] [blame] | 30 | #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) |
| 31 | #include <test/random.h> |
| 32 | |
| 33 | psa_status_t mbedtls_psa_external_get_random( |
| 34 | mbedtls_psa_external_random_context_t *context, |
| 35 | uint8_t *output, size_t output_size, size_t *output_length ) |
| 36 | { |
| 37 | /* This implementation is for test purposes only! |
| 38 | * Use the libc non-cryptographic random generator. */ |
| 39 | (void) context; |
| 40 | mbedtls_test_rnd_std_rand( NULL, output, output_size ); |
| 41 | *output_length = output_size; |
| 42 | return( PSA_SUCCESS ); |
| 43 | } |
| 44 | #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ |
| 45 | |
Gilles Peskine | 514a8fd | 2020-11-13 17:41:53 +0100 | [diff] [blame] | 46 | #endif /* MBEDTLS_PSA_CRYPTO_C */ |