1 /*
2  *  Function signatures for functionality that can be provided by
3  *  cryptographic accelerators.
4  *  Warning: This file will be auto-generated in the future.
5  */
6 /*  Copyright The Mbed TLS Contributors
7  *  SPDX-License-Identifier: Apache-2.0
8  *
9  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
10  *  not use this file except in compliance with the License.
11  *  You may obtain a copy of the License at
12  *
13  *  http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *  Unless required by applicable law or agreed to in writing, software
16  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  *  See the License for the specific language governing permissions and
19  *  limitations under the License.
20  */
21 
22 #ifndef PSA_CRYPTO_DRIVER_WRAPPERS_H
23 #define PSA_CRYPTO_DRIVER_WRAPPERS_H
24 
25 #include "psa/crypto.h"
26 #include "psa/crypto_driver_common.h"
27 
28 /*
29  * Signature functions
30  */
31 psa_status_t psa_driver_wrapper_sign_message(
32     const psa_key_attributes_t *attributes,
33     const uint8_t *key_buffer,
34     size_t key_buffer_size,
35     psa_algorithm_t alg,
36     const uint8_t *input,
37     size_t input_length,
38     uint8_t *signature,
39     size_t signature_size,
40     size_t *signature_length );
41 
42 psa_status_t psa_driver_wrapper_verify_message(
43     const psa_key_attributes_t *attributes,
44     const uint8_t *key_buffer,
45     size_t key_buffer_size,
46     psa_algorithm_t alg,
47     const uint8_t *input,
48     size_t input_length,
49     const uint8_t *signature,
50     size_t signature_length );
51 
52 psa_status_t psa_driver_wrapper_sign_hash(
53     const psa_key_attributes_t *attributes,
54     const uint8_t *key_buffer, size_t key_buffer_size,
55     psa_algorithm_t alg, const uint8_t *hash, size_t hash_length,
56     uint8_t *signature, size_t signature_size, size_t *signature_length );
57 
58 psa_status_t psa_driver_wrapper_verify_hash(
59     const psa_key_attributes_t *attributes,
60     const uint8_t *key_buffer, size_t key_buffer_size,
61     psa_algorithm_t alg, const uint8_t *hash, size_t hash_length,
62     const uint8_t *signature, size_t signature_length );
63 
64 /*
65  * Key handling functions
66  */
67 
68 psa_status_t psa_driver_wrapper_import_key(
69     const psa_key_attributes_t *attributes,
70     const uint8_t *data, size_t data_length,
71     uint8_t *key_buffer, size_t key_buffer_size,
72     size_t *key_buffer_length, size_t *bits );
73 
74 psa_status_t psa_driver_wrapper_export_key(
75     const psa_key_attributes_t *attributes,
76     const uint8_t *key_buffer, size_t key_buffer_size,
77     uint8_t *data, size_t data_size, size_t *data_length );
78 
79 psa_status_t psa_driver_wrapper_export_public_key(
80     const psa_key_attributes_t *attributes,
81     const uint8_t *key_buffer, size_t key_buffer_size,
82     uint8_t *data, size_t data_size, size_t *data_length );
83 
84 psa_status_t psa_driver_wrapper_get_key_buffer_size(
85     const psa_key_attributes_t *attributes,
86     size_t *key_buffer_size );
87 
88 psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
89     const psa_key_attributes_t *attributes,
90     const uint8_t *data,
91     size_t data_length,
92     size_t *key_buffer_size );
93 
94 psa_status_t psa_driver_wrapper_generate_key(
95     const psa_key_attributes_t *attributes,
96     uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length );
97 
98 psa_status_t psa_driver_wrapper_get_builtin_key(
99     psa_drv_slot_number_t slot_number,
100     psa_key_attributes_t *attributes,
101     uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length );
102 
103 psa_status_t psa_driver_wrapper_copy_key(
104     psa_key_attributes_t *attributes,
105     const uint8_t *source_key, size_t source_key_length,
106     uint8_t *target_key_buffer, size_t target_key_buffer_size,
107     size_t *target_key_buffer_length );
108 /*
109  * Cipher functions
110  */
111 psa_status_t psa_driver_wrapper_cipher_encrypt(
112     const psa_key_attributes_t *attributes,
113     const uint8_t *key_buffer,
114     size_t key_buffer_size,
115     psa_algorithm_t alg,
116     const uint8_t *input,
117     size_t input_length,
118     uint8_t *output,
119     size_t output_size,
120     size_t *output_length );
121 
122 psa_status_t psa_driver_wrapper_cipher_decrypt(
123     const psa_key_attributes_t *attributes,
124     const uint8_t *key_buffer,
125     size_t key_buffer_size,
126     psa_algorithm_t alg,
127     const uint8_t *input,
128     size_t input_length,
129     uint8_t *output,
130     size_t output_size,
131     size_t *output_length );
132 
133 psa_status_t psa_driver_wrapper_cipher_encrypt_setup(
134     psa_cipher_operation_t *operation,
135     const psa_key_attributes_t *attributes,
136     const uint8_t *key_buffer, size_t key_buffer_size,
137     psa_algorithm_t alg );
138 
139 psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
140     psa_cipher_operation_t *operation,
141     const psa_key_attributes_t *attributes,
142     const uint8_t *key_buffer, size_t key_buffer_size,
143     psa_algorithm_t alg );
144 
145 psa_status_t psa_driver_wrapper_cipher_set_iv(
146     psa_cipher_operation_t *operation,
147     const uint8_t *iv,
148     size_t iv_length );
149 
150 psa_status_t psa_driver_wrapper_cipher_update(
151     psa_cipher_operation_t *operation,
152     const uint8_t *input,
153     size_t input_length,
154     uint8_t *output,
155     size_t output_size,
156     size_t *output_length );
157 
158 psa_status_t psa_driver_wrapper_cipher_finish(
159     psa_cipher_operation_t *operation,
160     uint8_t *output,
161     size_t output_size,
162     size_t *output_length );
163 
164 psa_status_t psa_driver_wrapper_cipher_abort(
165     psa_cipher_operation_t *operation );
166 
167 /*
168  * Hashing functions
169  */
170 psa_status_t psa_driver_wrapper_hash_compute(
171     psa_algorithm_t alg,
172     const uint8_t *input,
173     size_t input_length,
174     uint8_t *hash,
175     size_t hash_size,
176     size_t *hash_length);
177 
178 psa_status_t psa_driver_wrapper_hash_setup(
179     psa_hash_operation_t *operation,
180     psa_algorithm_t alg );
181 
182 psa_status_t psa_driver_wrapper_hash_clone(
183     const psa_hash_operation_t *source_operation,
184     psa_hash_operation_t *target_operation );
185 
186 psa_status_t psa_driver_wrapper_hash_update(
187     psa_hash_operation_t *operation,
188     const uint8_t *input,
189     size_t input_length );
190 
191 psa_status_t psa_driver_wrapper_hash_finish(
192     psa_hash_operation_t *operation,
193     uint8_t *hash,
194     size_t hash_size,
195     size_t *hash_length );
196 
197 psa_status_t psa_driver_wrapper_hash_abort(
198     psa_hash_operation_t *operation );
199 
200 /*
201  * AEAD functions
202  */
203 
204 psa_status_t psa_driver_wrapper_aead_encrypt(
205     const psa_key_attributes_t *attributes,
206     const uint8_t *key_buffer, size_t key_buffer_size,
207     psa_algorithm_t alg,
208     const uint8_t *nonce, size_t nonce_length,
209     const uint8_t *additional_data, size_t additional_data_length,
210     const uint8_t *plaintext, size_t plaintext_length,
211     uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length );
212 
213 psa_status_t psa_driver_wrapper_aead_decrypt(
214     const psa_key_attributes_t *attributes,
215     const uint8_t *key_buffer, size_t key_buffer_size,
216     psa_algorithm_t alg,
217     const uint8_t *nonce, size_t nonce_length,
218     const uint8_t *additional_data, size_t additional_data_length,
219     const uint8_t *ciphertext, size_t ciphertext_length,
220     uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length );
221 
222 psa_status_t psa_driver_wrapper_aead_encrypt_setup(
223     psa_aead_operation_t *operation,
224     const psa_key_attributes_t *attributes,
225     const uint8_t *key_buffer, size_t key_buffer_size,
226     psa_algorithm_t alg );
227 
228 psa_status_t psa_driver_wrapper_aead_decrypt_setup(
229     psa_aead_operation_t *operation,
230     const psa_key_attributes_t *attributes,
231     const uint8_t *key_buffer, size_t key_buffer_size,
232     psa_algorithm_t alg );
233 
234 psa_status_t psa_driver_wrapper_aead_set_nonce(
235     psa_aead_operation_t *operation,
236     const uint8_t *nonce,
237     size_t nonce_length );
238 
239 psa_status_t psa_driver_wrapper_aead_set_lengths(
240     psa_aead_operation_t *operation,
241     size_t ad_length,
242     size_t plaintext_length );
243 
244 psa_status_t psa_driver_wrapper_aead_update_ad(
245     psa_aead_operation_t *operation,
246     const uint8_t *input,
247     size_t input_length );
248 
249 psa_status_t psa_driver_wrapper_aead_update(
250     psa_aead_operation_t *operation,
251     const uint8_t *input,
252     size_t input_length,
253     uint8_t *output,
254     size_t output_size,
255     size_t *output_length );
256 
257 psa_status_t psa_driver_wrapper_aead_finish(
258     psa_aead_operation_t *operation,
259     uint8_t *ciphertext,
260     size_t ciphertext_size,
261     size_t *ciphertext_length,
262     uint8_t *tag,
263     size_t tag_size,
264     size_t *tag_length );
265 
266 psa_status_t psa_driver_wrapper_aead_verify(
267     psa_aead_operation_t *operation,
268     uint8_t *plaintext,
269     size_t plaintext_size,
270     size_t *plaintext_length,
271     const uint8_t *tag,
272     size_t tag_length );
273 
274 psa_status_t psa_driver_wrapper_aead_abort(
275     psa_aead_operation_t *operation );
276 
277 /*
278  * MAC functions
279  */
280 psa_status_t psa_driver_wrapper_mac_compute(
281     const psa_key_attributes_t *attributes,
282     const uint8_t *key_buffer,
283     size_t key_buffer_size,
284     psa_algorithm_t alg,
285     const uint8_t *input,
286     size_t input_length,
287     uint8_t *mac,
288     size_t mac_size,
289     size_t *mac_length );
290 
291 psa_status_t psa_driver_wrapper_mac_sign_setup(
292     psa_mac_operation_t *operation,
293     const psa_key_attributes_t *attributes,
294     const uint8_t *key_buffer,
295     size_t key_buffer_size,
296     psa_algorithm_t alg );
297 
298 psa_status_t psa_driver_wrapper_mac_verify_setup(
299     psa_mac_operation_t *operation,
300     const psa_key_attributes_t *attributes,
301     const uint8_t *key_buffer,
302     size_t key_buffer_size,
303     psa_algorithm_t alg );
304 
305 psa_status_t psa_driver_wrapper_mac_update(
306     psa_mac_operation_t *operation,
307     const uint8_t *input,
308     size_t input_length );
309 
310 psa_status_t psa_driver_wrapper_mac_sign_finish(
311     psa_mac_operation_t *operation,
312     uint8_t *mac,
313     size_t mac_size,
314     size_t *mac_length );
315 
316 psa_status_t psa_driver_wrapper_mac_verify_finish(
317     psa_mac_operation_t *operation,
318     const uint8_t *mac,
319     size_t mac_length );
320 
321 psa_status_t psa_driver_wrapper_mac_abort(
322     psa_mac_operation_t *operation );
323 
324 #endif /* PSA_CRYPTO_DRIVER_WRAPPERS_H */
325 
326 /* End of automatically generated file. */
327