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