TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_crypto_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __TFM_CRYPTO_API_H__
9 #define __TFM_CRYPTO_API_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 #include "tfm_crypto_defs.h"
17 #ifdef TFM_PSA_API
18 #include "psa/service.h"
19 
24 typedef psa_status_t (*tfm_crypto_us_t)(psa_invec[],size_t,psa_outvec[],size_t);
25 #endif
26 
28 
29 #define UNIFORM_SIGNATURE_API(api_name) \
30  psa_status_t api_name(psa_invec[], size_t, psa_outvec[], size_t)
31 
44 
45  /* Used to force the enum size */
47 };
48 
55 
62 
71 
82  const struct psa_client_key_attributes_s *client_key_attr,
83  int32_t client_id,
84  psa_key_attributes_t *key_attributes);
85 
95  const psa_key_attributes_t *key_attributes,
96  struct psa_client_key_attributes_s *client_key_attr);
97 
111  uint32_t *index);
112 
122 
144  uint32_t *handle,
145  void **ctx);
165  uint32_t handle,
166  void **ctx);
167 
168 #define LIST_TFM_CRYPTO_UNIFORM_SIGNATURE_API \
169  X(tfm_crypto_get_key_attributes) \
170  X(tfm_crypto_reset_key_attributes) \
171  X(tfm_crypto_open_key) \
172  X(tfm_crypto_close_key) \
173  X(tfm_crypto_import_key) \
174  X(tfm_crypto_destroy_key) \
175  X(tfm_crypto_export_key) \
176  X(tfm_crypto_export_public_key) \
177  X(tfm_crypto_copy_key) \
178  X(tfm_crypto_hash_compute) \
179  X(tfm_crypto_hash_compare) \
180  X(tfm_crypto_hash_setup) \
181  X(tfm_crypto_hash_update) \
182  X(tfm_crypto_hash_finish) \
183  X(tfm_crypto_hash_verify) \
184  X(tfm_crypto_hash_abort) \
185  X(tfm_crypto_hash_clone) \
186  X(tfm_crypto_mac_compute) \
187  X(tfm_crypto_mac_verify) \
188  X(tfm_crypto_mac_sign_setup) \
189  X(tfm_crypto_mac_verify_setup) \
190  X(tfm_crypto_mac_update) \
191  X(tfm_crypto_mac_sign_finish) \
192  X(tfm_crypto_mac_verify_finish) \
193  X(tfm_crypto_mac_abort) \
194  X(tfm_crypto_cipher_encrypt) \
195  X(tfm_crypto_cipher_decrypt) \
196  X(tfm_crypto_cipher_encrypt_setup) \
197  X(tfm_crypto_cipher_decrypt_setup) \
198  X(tfm_crypto_cipher_generate_iv) \
199  X(tfm_crypto_cipher_set_iv) \
200  X(tfm_crypto_cipher_update) \
201  X(tfm_crypto_cipher_finish) \
202  X(tfm_crypto_cipher_abort) \
203  X(tfm_crypto_aead_encrypt) \
204  X(tfm_crypto_aead_decrypt) \
205  X(tfm_crypto_aead_encrypt_setup) \
206  X(tfm_crypto_aead_decrypt_setup) \
207  X(tfm_crypto_aead_generate_nonce) \
208  X(tfm_crypto_aead_set_nonce) \
209  X(tfm_crypto_aead_set_lengths) \
210  X(tfm_crypto_aead_update_ad) \
211  X(tfm_crypto_aead_update) \
212  X(tfm_crypto_aead_finish) \
213  X(tfm_crypto_aead_verify) \
214  X(tfm_crypto_aead_abort) \
215  X(tfm_crypto_sign_hash) \
216  X(tfm_crypto_verify_hash) \
217  X(tfm_crypto_asymmetric_encrypt) \
218  X(tfm_crypto_asymmetric_decrypt) \
219  X(tfm_crypto_key_derivation_setup) \
220  X(tfm_crypto_key_derivation_get_capacity) \
221  X(tfm_crypto_key_derivation_set_capacity) \
222  X(tfm_crypto_key_derivation_input_bytes) \
223  X(tfm_crypto_key_derivation_input_key) \
224  X(tfm_crypto_key_derivation_key_agreement)\
225  X(tfm_crypto_key_derivation_output_bytes) \
226  X(tfm_crypto_key_derivation_output_key) \
227  X(tfm_crypto_key_derivation_abort) \
228  X(tfm_crypto_raw_key_agreement) \
229  X(tfm_crypto_generate_random) \
230  X(tfm_crypto_generate_key) \
231  X(tfm_crypto_set_key_domain_parameters) \
232  X(tfm_crypto_get_key_domain_parameters) \
233 
234 #define X(api_name) UNIFORM_SIGNATURE_API(api_name);
236 #undef X
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 
242 #endif /* __TFM_CRYPTO_API_H__ */
psa_key_handle_t key_handle
psa_status_t tfm_crypto_check_handle_owner(psa_key_handle_t handle, uint32_t *index)
Checks that the requested handle belongs to the requesting partition.
Definition: crypto_key.c:86
psa_status_t tfm_crypto_operation_alloc(enum tfm_crypto_operation_type type, uint32_t *handle, void **ctx)
Allocate an operation context in the backend.
Definition: crypto_alloc.c:94
psa_status_t tfm_crypto_get_caller_id(int32_t *id)
Returns the ID of the caller.
Definition: crypto_init.c:314
psa_status_t tfm_crypto_key_attributes_to_client(const psa_key_attributes_t *key_attributes, struct psa_client_key_attributes_s *client_key_attr)
Converts key attributes to client key attributes.
Definition: crypto_key.c:62
psa_status_t tfm_crypto_key_attributes_from_client(const struct psa_client_key_attributes_s *client_key_attr, int32_t client_id, psa_key_attributes_t *key_attributes)
Gets key attributes from client key attributes.
Definition: crypto_key.c:37
#define LIST_TFM_CRYPTO_UNIFORM_SIGNATURE_API
psa_status_t tfm_crypto_operation_release(uint32_t *handle)
Release an operation context in the backend.
Definition: crypto_alloc.c:132
psa_status_t tfm_crypto_init(void)
Initialise the service.
Definition: crypto_init.c:330
PSA cryptography client key attribute definitions.
psa_status_t tfm_crypto_set_key_storage(uint32_t index, psa_key_handle_t key_handle)
Sets the index of the local storage in use with a key requested by the calling partition, and stores the corresponding key_handle.
Definition: crypto_key.c:136
_unsigned_integral_type_ psa_key_handle_t
Key handle.
Definition: crypto.h:35
psa_status_t tfm_crypto_check_key_storage(uint32_t *index)
Checks that there is enough local storage in RAM to keep another key, and returns the index of the st...
Definition: crypto_key.c:118
psa_status_t tfm_crypto_init_alloc(void)
Initialise the Alloc module.
Definition: crypto_alloc.c:87
tfm_crypto_operation_type
List of possible operation types supported by the TFM based implementation. This type is needed by th...
psa_status_t tfm_crypto_operation_lookup(enum tfm_crypto_operation_type type, uint32_t handle, void **ctx)
Look up an operation context in the backend for the corresponding frontend operation.
Definition: crypto_alloc.c:159
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43