1 /*
2  * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 /**
9  * \file crypto_spe.h
10  *
11  * \brief When Mbed Crypto is built with the MBEDTLS_PSA_CRYPTO_SPM option
12  *        enabled, this header is included by all .c files in Mbed Crypto that
13  *        use PSA Crypto function names. This avoids duplication of symbols
14  *        between TF-M and Mbed Crypto.
15  *
16  * \note  This file should be included before including any PSA Crypto headers
17  *        from Mbed Crypto.
18  */
19 
20 #ifndef CRYPTO_SPE_H
21 #define CRYPTO_SPE_H
22 
23 #define PSA_FUNCTION_NAME(x) mbedcrypto__ ## x
24 
25 #define psa_crypto_init \
26         PSA_FUNCTION_NAME(psa_crypto_init)
27 #define psa_key_derivation_get_capacity \
28         PSA_FUNCTION_NAME(psa_key_derivation_get_capacity)
29 #define psa_key_derivation_set_capacity \
30         PSA_FUNCTION_NAME(psa_key_derivation_set_capacity)
31 #define psa_key_derivation_input_bytes \
32         PSA_FUNCTION_NAME(psa_key_derivation_input_bytes)
33 #define psa_key_derivation_input_integer \
34         PSA_FUNCTION_NAME(psa_key_derivation_input_integer)
35 #define psa_key_derivation_output_bytes \
36         PSA_FUNCTION_NAME(psa_key_derivation_output_bytes)
37 #define psa_key_derivation_input_key \
38         PSA_FUNCTION_NAME(psa_key_derivation_input_key)
39 #define psa_key_derivation_output_key \
40         PSA_FUNCTION_NAME(psa_key_derivation_output_key)
41 #define psa_key_derivation_setup \
42         PSA_FUNCTION_NAME(psa_key_derivation_setup)
43 #define psa_key_derivation_abort \
44         PSA_FUNCTION_NAME(psa_key_derivation_abort)
45 #define psa_key_derivation_key_agreement \
46         PSA_FUNCTION_NAME(psa_key_derivation_key_agreement)
47 #define psa_raw_key_agreement \
48         PSA_FUNCTION_NAME(psa_raw_key_agreement)
49 #define psa_generate_random \
50         PSA_FUNCTION_NAME(psa_generate_random)
51 #define psa_aead_encrypt \
52         PSA_FUNCTION_NAME(psa_aead_encrypt)
53 #define psa_aead_decrypt \
54         PSA_FUNCTION_NAME(psa_aead_decrypt)
55 #define psa_aead_encrypt_setup \
56         PSA_FUNCTION_NAME(psa_aead_encrypt_setup)
57 #define psa_aead_decrypt_setup \
58         PSA_FUNCTION_NAME(psa_aead_decrypt_setup)
59 #define psa_aead_generate_nonce \
60         PSA_FUNCTION_NAME(psa_aead_generate_nonce)
61 #define psa_aead_set_nonce \
62         PSA_FUNCTION_NAME(psa_aead_set_nonce)
63 #define psa_aead_set_lengths \
64         PSA_FUNCTION_NAME(psa_aead_set_lengths)
65 #define psa_aead_update_ad \
66         PSA_FUNCTION_NAME(psa_aead_update_ad)
67 #define psa_aead_update \
68         PSA_FUNCTION_NAME(psa_aead_update)
69 #define psa_aead_finish \
70         PSA_FUNCTION_NAME(psa_aead_finish)
71 #define psa_aead_verify \
72         PSA_FUNCTION_NAME(psa_aead_verify)
73 #define psa_aead_abort \
74         PSA_FUNCTION_NAME(psa_aead_abort)
75 #define psa_open_key \
76         PSA_FUNCTION_NAME(psa_open_key)
77 #define psa_close_key \
78         PSA_FUNCTION_NAME(psa_close_key)
79 #define psa_import_key \
80         PSA_FUNCTION_NAME(psa_import_key)
81 #define psa_destroy_key \
82         PSA_FUNCTION_NAME(psa_destroy_key)
83 #define psa_get_key_attributes \
84         PSA_FUNCTION_NAME(psa_get_key_attributes)
85 #define psa_reset_key_attributes \
86         PSA_FUNCTION_NAME(psa_reset_key_attributes)
87 #define psa_export_key \
88         PSA_FUNCTION_NAME(psa_export_key)
89 #define psa_export_public_key \
90         PSA_FUNCTION_NAME(psa_export_public_key)
91 #define psa_purge_key \
92         PSA_FUNCTION_NAME(psa_purge_key)
93 #define psa_copy_key \
94         PSA_FUNCTION_NAME(psa_copy_key)
95 #define psa_cipher_operation_init \
96         PSA_FUNCTION_NAME(psa_cipher_operation_init)
97 #define psa_cipher_generate_iv \
98         PSA_FUNCTION_NAME(psa_cipher_generate_iv)
99 #define psa_cipher_set_iv \
100         PSA_FUNCTION_NAME(psa_cipher_set_iv)
101 #define psa_cipher_encrypt_setup \
102         PSA_FUNCTION_NAME(psa_cipher_encrypt_setup)
103 #define psa_cipher_decrypt_setup \
104         PSA_FUNCTION_NAME(psa_cipher_decrypt_setup)
105 #define psa_cipher_update \
106         PSA_FUNCTION_NAME(psa_cipher_update)
107 #define psa_cipher_encrypt \
108         PSA_FUNCTION_NAME(psa_cipher_encrypt)
109 #define psa_cipher_decrypt \
110         PSA_FUNCTION_NAME(psa_cipher_decrypt)
111 #define psa_cipher_finish \
112         PSA_FUNCTION_NAME(psa_cipher_finish)
113 #define psa_cipher_abort \
114         PSA_FUNCTION_NAME(psa_cipher_abort)
115 #define psa_hash_operation_init \
116         PSA_FUNCTION_NAME(psa_hash_operation_init)
117 #define psa_hash_setup \
118         PSA_FUNCTION_NAME(psa_hash_setup)
119 #define psa_hash_update \
120         PSA_FUNCTION_NAME(psa_hash_update)
121 #define psa_hash_finish \
122         PSA_FUNCTION_NAME(psa_hash_finish)
123 #define psa_hash_verify \
124         PSA_FUNCTION_NAME(psa_hash_verify)
125 #define psa_hash_abort \
126         PSA_FUNCTION_NAME(psa_hash_abort)
127 #define psa_hash_clone \
128         PSA_FUNCTION_NAME(psa_hash_clone)
129 #define psa_hash_compute \
130         PSA_FUNCTION_NAME(psa_hash_compute)
131 #define psa_hash_compare \
132         PSA_FUNCTION_NAME(psa_hash_compare)
133 #define psa_mac_operation_init \
134         PSA_FUNCTION_NAME(psa_mac_operation_init)
135 #define psa_mac_sign_setup \
136         PSA_FUNCTION_NAME(psa_mac_sign_setup)
137 #define psa_mac_verify_setup \
138         PSA_FUNCTION_NAME(psa_mac_verify_setup)
139 #define psa_mac_update \
140         PSA_FUNCTION_NAME(psa_mac_update)
141 #define psa_mac_sign_finish \
142         PSA_FUNCTION_NAME(psa_mac_sign_finish)
143 #define psa_mac_verify_finish \
144         PSA_FUNCTION_NAME(psa_mac_verify_finish)
145 #define psa_mac_compute \
146         PSA_FUNCTION_NAME(psa_mac_compute)
147 #define psa_mac_verify \
148         PSA_FUNCTION_NAME(psa_mac_verify)
149 #define psa_mac_abort \
150         PSA_FUNCTION_NAME(psa_mac_abort)
151 #define psa_sign_message \
152         PSA_FUNCTION_NAME(psa_sign_message)
153 #define psa_verify_message \
154         PSA_FUNCTION_NAME(psa_verify_message)
155 #define psa_sign_hash \
156         PSA_FUNCTION_NAME(psa_sign_hash)
157 #define psa_verify_hash \
158         PSA_FUNCTION_NAME(psa_verify_hash)
159 #define psa_asymmetric_encrypt \
160         PSA_FUNCTION_NAME(psa_asymmetric_encrypt)
161 #define psa_asymmetric_decrypt \
162         PSA_FUNCTION_NAME(psa_asymmetric_decrypt)
163 #define psa_generate_key \
164         PSA_FUNCTION_NAME(psa_generate_key)
165 
166 #endif /* CRYPTO_SPE_H */
167