1 /*
2  * Copyright The Mbed TLS Contributors
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /**
20  * \file crypto_spe.h
21  *
22  * \brief When Mbed Crypto is built with the MBEDTLS_PSA_CRYPTO_SPM option
23  *        enabled, this header is included by all .c files in Mbed Crypto that
24  *        use PSA Crypto function names. This avoids duplication of symbols
25  *        between TF-M and Mbed Crypto.
26  *
27  * \note  This file should be included before including any PSA Crypto headers
28  *        from Mbed Crypto.
29  */
30 
31 #ifndef CRYPTO_SPE_H
32 #define CRYPTO_SPE_H
33 
34 #define PSA_FUNCTION_NAME(x) mbedcrypto__ ## x
35 
36 #define psa_crypto_init \
37     PSA_FUNCTION_NAME(psa_crypto_init)
38 #define psa_key_derivation_get_capacity \
39     PSA_FUNCTION_NAME(psa_key_derivation_get_capacity)
40 #define psa_key_derivation_set_capacity \
41     PSA_FUNCTION_NAME(psa_key_derivation_set_capacity)
42 #define psa_key_derivation_input_bytes \
43     PSA_FUNCTION_NAME(psa_key_derivation_input_bytes)
44 #define psa_key_derivation_output_bytes \
45     PSA_FUNCTION_NAME(psa_key_derivation_output_bytes)
46 #define psa_key_derivation_input_key \
47     PSA_FUNCTION_NAME(psa_key_derivation_input_key)
48 #define psa_key_derivation_output_key \
49     PSA_FUNCTION_NAME(psa_key_derivation_output_key)
50 #define psa_key_derivation_setup \
51     PSA_FUNCTION_NAME(psa_key_derivation_setup)
52 #define psa_key_derivation_abort \
53     PSA_FUNCTION_NAME(psa_key_derivation_abort)
54 #define psa_key_derivation_key_agreement \
55     PSA_FUNCTION_NAME(psa_key_derivation_key_agreement)
56 #define psa_raw_key_agreement \
57     PSA_FUNCTION_NAME(psa_raw_key_agreement)
58 #define psa_generate_random \
59     PSA_FUNCTION_NAME(psa_generate_random)
60 #define psa_aead_encrypt \
61     PSA_FUNCTION_NAME(psa_aead_encrypt)
62 #define psa_aead_decrypt \
63     PSA_FUNCTION_NAME(psa_aead_decrypt)
64 #define psa_open_key \
65     PSA_FUNCTION_NAME(psa_open_key)
66 #define psa_close_key \
67     PSA_FUNCTION_NAME(psa_close_key)
68 #define psa_import_key \
69     PSA_FUNCTION_NAME(psa_import_key)
70 #define psa_destroy_key \
71     PSA_FUNCTION_NAME(psa_destroy_key)
72 #define psa_get_key_attributes \
73     PSA_FUNCTION_NAME(psa_get_key_attributes)
74 #define psa_reset_key_attributes \
75     PSA_FUNCTION_NAME(psa_reset_key_attributes)
76 #define psa_export_key \
77     PSA_FUNCTION_NAME(psa_export_key)
78 #define psa_export_public_key \
79     PSA_FUNCTION_NAME(psa_export_public_key)
80 #define psa_purge_key \
81     PSA_FUNCTION_NAME(psa_purge_key)
82 #define psa_copy_key \
83     PSA_FUNCTION_NAME(psa_copy_key)
84 #define psa_cipher_operation_init \
85     PSA_FUNCTION_NAME(psa_cipher_operation_init)
86 #define psa_cipher_generate_iv \
87     PSA_FUNCTION_NAME(psa_cipher_generate_iv)
88 #define psa_cipher_set_iv \
89     PSA_FUNCTION_NAME(psa_cipher_set_iv)
90 #define psa_cipher_encrypt_setup \
91     PSA_FUNCTION_NAME(psa_cipher_encrypt_setup)
92 #define psa_cipher_decrypt_setup \
93     PSA_FUNCTION_NAME(psa_cipher_decrypt_setup)
94 #define psa_cipher_update \
95     PSA_FUNCTION_NAME(psa_cipher_update)
96 #define psa_cipher_finish \
97     PSA_FUNCTION_NAME(psa_cipher_finish)
98 #define psa_cipher_abort \
99     PSA_FUNCTION_NAME(psa_cipher_abort)
100 #define psa_hash_operation_init \
101     PSA_FUNCTION_NAME(psa_hash_operation_init)
102 #define psa_hash_setup \
103     PSA_FUNCTION_NAME(psa_hash_setup)
104 #define psa_hash_update \
105     PSA_FUNCTION_NAME(psa_hash_update)
106 #define psa_hash_finish \
107     PSA_FUNCTION_NAME(psa_hash_finish)
108 #define psa_hash_verify \
109     PSA_FUNCTION_NAME(psa_hash_verify)
110 #define psa_hash_abort \
111     PSA_FUNCTION_NAME(psa_hash_abort)
112 #define psa_hash_clone \
113     PSA_FUNCTION_NAME(psa_hash_clone)
114 #define psa_hash_compute \
115     PSA_FUNCTION_NAME(psa_hash_compute)
116 #define psa_hash_compare \
117     PSA_FUNCTION_NAME(psa_hash_compare)
118 #define psa_mac_operation_init \
119     PSA_FUNCTION_NAME(psa_mac_operation_init)
120 #define psa_mac_sign_setup \
121     PSA_FUNCTION_NAME(psa_mac_sign_setup)
122 #define psa_mac_verify_setup \
123     PSA_FUNCTION_NAME(psa_mac_verify_setup)
124 #define psa_mac_update \
125     PSA_FUNCTION_NAME(psa_mac_update)
126 #define psa_mac_sign_finish \
127     PSA_FUNCTION_NAME(psa_mac_sign_finish)
128 #define psa_mac_verify_finish \
129     PSA_FUNCTION_NAME(psa_mac_verify_finish)
130 #define psa_mac_abort \
131     PSA_FUNCTION_NAME(psa_mac_abort)
132 #define psa_sign_hash \
133     PSA_FUNCTION_NAME(psa_sign_hash)
134 #define psa_verify_hash \
135     PSA_FUNCTION_NAME(psa_verify_hash)
136 #define psa_asymmetric_encrypt \
137     PSA_FUNCTION_NAME(psa_asymmetric_encrypt)
138 #define psa_asymmetric_decrypt \
139     PSA_FUNCTION_NAME(psa_asymmetric_decrypt)
140 #define psa_generate_key \
141     PSA_FUNCTION_NAME(psa_generate_key)
142 
143 #endif /* CRYPTO_SPE_H */
144