• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * \file psa_crypto_invasive.h
3  *
4  * \brief PSA cryptography module: invasive interfaces for test only.
5  *
6  * The interfaces in this file are intended for testing purposes only.
7  * They MUST NOT be made available to clients over IPC in integrations
8  * with isolation, and they SHOULD NOT be made available in library
9  * integrations except when building the library for testing.
10  */
11 /*
12  *  Copyright The Mbed TLS Contributors
13  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
14  */
15 
16 #ifndef PSA_CRYPTO_INVASIVE_H
17 #define PSA_CRYPTO_INVASIVE_H
18 
19 #if defined(MBEDTLS_CONFIG_FILE)
20 #include MBEDTLS_CONFIG_FILE
21 #else
22 #include "mbedtls/config.h"
23 #endif
24 
25 #include "psa/crypto.h"
26 #include "common.h"
27 
28 #include "mbedtls/entropy.h"
29 
30 #if !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
31 /** \brief Configure entropy sources.
32  *
33  * This function may only be called before a call to psa_crypto_init(),
34  * or after a call to mbedtls_psa_crypto_free() and before any
35  * subsequent call to psa_crypto_init().
36  *
37  * This function is only intended for test purposes. The functionality
38  * it provides is also useful for system integrators, but
39  * system integrators should configure entropy drivers instead of
40  * breaking through to the Mbed TLS API.
41  *
42  * \param entropy_init  Function to initialize the entropy context
43  *                      and set up the desired entropy sources.
44  *                      It is called by psa_crypto_init().
45  *                      By default this is mbedtls_entropy_init().
46  *                      This function cannot report failures directly.
47  *                      To indicate a failure, set the entropy context
48  *                      to a state where mbedtls_entropy_func() will
49  *                      return an error.
50  * \param entropy_free  Function to free the entropy context
51  *                      and associated resources.
52  *                      It is called by mbedtls_psa_crypto_free().
53  *                      By default this is mbedtls_entropy_free().
54  *
55  * \retval #PSA_SUCCESS
56  *         Success.
57  * \retval #PSA_ERROR_NOT_PERMITTED
58  *         The caller does not have the permission to configure
59  *         entropy sources.
60  * \retval #PSA_ERROR_BAD_STATE
61  *         The library has already been initialized.
62  */
63 psa_status_t mbedtls_psa_crypto_configure_entropy_sources(
64     void (* entropy_init)(mbedtls_entropy_context *ctx),
65     void (* entropy_free)(mbedtls_entropy_context *ctx));
66 #endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
67 
68 #if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C)
69 psa_status_t psa_mac_key_can_do(
70     psa_algorithm_t algorithm,
71     psa_key_type_t key_type);
72 #endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_PSA_CRYPTO_C */
73 
74 #endif /* PSA_CRYPTO_INVASIVE_H */
75