blob: a3ecc8dc68fd103c0406cf6979c19ccf4ec25254 [file] [log] [blame]
Antonio de Angelis8908f472018-08-31 15:44:25 +01001/*
Antonio de Angelis377a1552018-11-22 17:02:40 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Antonio de Angelis8908f472018-08-31 15:44:25 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include "tfm_crypto_veneers.h"
9#include "secure_fw/services/crypto/tfm_crypto_api.h"
10#include "tfm_secure_api.h"
11#include "tfm_api.h"
12#include "spm_api.h"
13
14#include "psa_crypto.h"
15
16#include "crypto_psa_wrappers.h"
17
18__tfm_secure_gateway_attributes__
19enum tfm_crypto_err_t tfm_crypto_veneer_import_key(psa_key_slot_t key,
20 psa_key_type_t type,
21 const uint8_t *data,
22 size_t data_length)
23{
24 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_import_key,
25 key, type, data, data_length);
26}
27
28__tfm_secure_gateway_attributes__
29enum tfm_crypto_err_t tfm_crypto_veneer_destroy_key(psa_key_slot_t key)
30{
31 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_destroy_key,
32 key, 0, 0, 0);
33}
34
35__tfm_secure_gateway_attributes__
36enum tfm_crypto_err_t tfm_crypto_veneer_get_key_information(
37 psa_key_slot_t key,
38 psa_key_type_t *type,
39 size_t *bits)
40{
41 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_get_key_information,
42 key, type, bits, 0);
43}
44
45__tfm_secure_gateway_attributes__
46enum tfm_crypto_err_t tfm_crypto_veneer_export_key(psa_key_slot_t key,
47 uint8_t *data,
48 size_t data_size,
49 size_t *data_length)
50{
51 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_export_key,
52 key, data, data_size, data_length);
53}
54
55
56__tfm_secure_gateway_attributes__
Antonio de Angelis377a1552018-11-22 17:02:40 +000057enum tfm_crypto_err_t tfm_crypto_veneer_cipher_set_iv(
Antonio de Angelis8908f472018-08-31 15:44:25 +010058 psa_cipher_operation_t *operation,
59 const unsigned char *iv,
60 size_t iv_length)
61{
Antonio de Angelis377a1552018-11-22 17:02:40 +000062 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_set_iv,
Antonio de Angelis8908f472018-08-31 15:44:25 +010063 operation, iv, iv_length, 0);
64}
65
66__tfm_secure_gateway_attributes__
Antonio de Angelis377a1552018-11-22 17:02:40 +000067enum tfm_crypto_err_t tfm_crypto_veneer_cipher_encrypt_setup(
Antonio de Angelis8908f472018-08-31 15:44:25 +010068 psa_cipher_operation_t *operation,
69 psa_key_slot_t key,
70 psa_algorithm_t alg)
71{
Antonio de Angelis377a1552018-11-22 17:02:40 +000072 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_encrypt_setup,
Antonio de Angelis8908f472018-08-31 15:44:25 +010073 operation, key, alg, 0);
74}
75
76__tfm_secure_gateway_attributes__
Antonio de Angelis377a1552018-11-22 17:02:40 +000077enum tfm_crypto_err_t tfm_crypto_veneer_cipher_decrypt_setup(
Antonio de Angelis8908f472018-08-31 15:44:25 +010078 psa_cipher_operation_t *operation,
79 psa_key_slot_t key,
80 psa_algorithm_t alg)
81{
Antonio de Angelis377a1552018-11-22 17:02:40 +000082 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_decrypt_setup,
Antonio de Angelis8908f472018-08-31 15:44:25 +010083 operation, key, alg, 0);
84}
85
86__tfm_secure_gateway_attributes__
87enum tfm_crypto_err_t tfm_crypto_veneer_cipher_update(
88 psa_cipher_operation_t *operation,
89 struct psa_cipher_update_input *input_s,
90 struct psa_cipher_update_output *output_s)
91{
92 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_update_wrapper,
93 operation, input_s, output_s, 0);
94}
95
96__tfm_secure_gateway_attributes__
97enum tfm_crypto_err_t tfm_crypto_veneer_cipher_abort(
98 psa_cipher_operation_t *operation)
99{
100 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_abort,
101 operation, 0, 0, 0);
102}
103
104__tfm_secure_gateway_attributes__
105enum tfm_crypto_err_t tfm_crypto_veneer_cipher_finish(
106 psa_cipher_operation_t *operation,
107 uint8_t *output,
108 size_t output_size,
109 size_t *output_length)
110{
111 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_finish,
112 operation, output, output_size, output_length);
113}
Antonio de Angelisa6f72162018-09-05 11:00:37 +0100114
115__tfm_secure_gateway_attributes__
Antonio de Angelis377a1552018-11-22 17:02:40 +0000116enum tfm_crypto_err_t tfm_crypto_veneer_hash_setup(
Antonio de Angelisa6f72162018-09-05 11:00:37 +0100117 psa_hash_operation_t *operation,
118 psa_algorithm_t alg)
119{
Antonio de Angelis377a1552018-11-22 17:02:40 +0000120 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_setup,
Antonio de Angelisa6f72162018-09-05 11:00:37 +0100121 operation, alg, 0, 0);
122}
123
124__tfm_secure_gateway_attributes__
125enum tfm_crypto_err_t tfm_crypto_veneer_hash_update(
126 psa_hash_operation_t *operation,
127 const uint8_t *input,
128 size_t input_length)
129{
130 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_update,
131 operation, input, input_length, 0);
132}
133
134__tfm_secure_gateway_attributes__
135enum tfm_crypto_err_t tfm_crypto_veneer_hash_finish(
136 psa_hash_operation_t *operation,
137 uint8_t *hash,
138 size_t hash_size,
139 size_t *hash_length)
140{
141 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_finish,
142 operation, hash, hash_size, hash_length);
143}
144
145__tfm_secure_gateway_attributes__
146enum tfm_crypto_err_t tfm_crypto_veneer_hash_verify(
147 psa_hash_operation_t *operation,
148 const uint8_t *hash,
149 size_t hash_length)
150{
151 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_verify,
152 operation, hash, hash_length, 0);
153}
154
155__tfm_secure_gateway_attributes__
156enum tfm_crypto_err_t tfm_crypto_veneer_hash_abort(
157 psa_hash_operation_t *operation)
158{
159 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_abort,
160 operation, 0, 0, 0);
161}
Louis Mayencourt7a36f782018-09-24 14:00:57 +0100162
163__tfm_secure_gateway_attributes__
164enum tfm_crypto_err_t tfm_crypto_veneer_mac_sign_setup(
165 psa_mac_operation_t *operation,
166 psa_key_slot_t key,
167 psa_algorithm_t alg)
168{
169 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_mac_sign_setup,
170 operation, key, alg, 0);
171}
172
173__tfm_secure_gateway_attributes__
174enum tfm_crypto_err_t tfm_crypto_veneer_mac_verify_setup(
175 psa_mac_operation_t *operation,
176 psa_key_slot_t key,
177 psa_algorithm_t alg)
178{
179 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_mac_verify_setup,
180 operation, key, alg, 0);
181}
182
183__tfm_secure_gateway_attributes__
184enum tfm_crypto_err_t tfm_crypto_veneer_mac_update(
185 psa_mac_operation_t *operation,
186 const uint8_t *input,
187 size_t input_length)
188{
189 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_mac_update,
190 operation, input, input_length, 0);
191}
192
193__tfm_secure_gateway_attributes__
194enum tfm_crypto_err_t tfm_crypto_veneer_mac_sign_finish(
195 psa_mac_operation_t *operation,
196 uint8_t *mac,
197 size_t mac_size,
198 size_t *mac_length)
199{
200 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_mac_sign_finish,
201 operation, mac, mac_size, mac_length);
202}
203
204__tfm_secure_gateway_attributes__
205enum tfm_crypto_err_t tfm_crypto_veneer_mac_verify_finish(
206 psa_mac_operation_t *operation,
207 const uint8_t *mac,
208 size_t mac_length)
209{
210 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_mac_verify_finish,
211 operation, mac, mac_length, 0);
212}
213
214__tfm_secure_gateway_attributes__
215enum tfm_crypto_err_t tfm_crypto_veneer_mac_abort(
216 psa_mac_operation_t *operation)
217{
218 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_mac_abort,
219 operation, 0, 0, 0);
220}
Antonio de Angelis3a480992018-11-07 11:53:28 +0000221
222__tfm_secure_gateway_attributes__
223enum tfm_crypto_err_t tfm_crypto_veneer_aead_encrypt(
224 struct psa_aead_encrypt_input *input_s,
225 struct psa_aead_encrypt_output *output_s)
226{
227 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_aead_encrypt_wrapper,
228 input_s, output_s, 0, 0);
229}
230
231__tfm_secure_gateway_attributes__
232enum tfm_crypto_err_t tfm_crypto_veneer_aead_decrypt(
233 struct psa_aead_decrypt_input *input_s,
234 struct psa_aead_decrypt_output *output_s)
235{
236 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_aead_decrypt_wrapper,
237 input_s, output_s, 0, 0);
238}