ti_psa_crypto.h
Go to the documentation of this file.
1 /*
2  * Copyright The Mbed TLS Contributors
3  * Copyright 2025, Texas Instruments Incorporated
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License"); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Modified by Texas Instruments to support SimpleLink device crypto hardware
19  * drivers.
20  */
21 
22 #ifndef TI_PSA_CRYPTO_H
23 #define TI_PSA_CRYPTO_H
24 
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 #if ((TFM_ENABLED == 1) && !defined(TFM_BUILD))
29  #include <third_party/tfm/interface/include/psa/crypto.h>
30 #else
31  #include <third_party/mbedtls/include/psa/crypto.h>
32 #endif
33 
34 typedef enum
35 {
39 
40 /******************************************************************************/
41 /* Key management */
42 /******************************************************************************/
43 psa_status_t ti_psa_copy_key(mbedtls_svc_key_id_t source_key,
44  const psa_key_attributes_t *attributes,
45  mbedtls_svc_key_id_t *target_key);
46 
47 psa_status_t ti_psa_destroy_key(mbedtls_svc_key_id_t key);
48 
49 psa_status_t ti_psa_export_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length);
50 
51 psa_status_t ti_psa_export_public_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length);
52 
53 psa_status_t ti_psa_generate_key(const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *key);
54 
55 psa_status_t ti_psa_get_key_attributes(mbedtls_svc_key_id_t key, psa_key_attributes_t *attributes);
56 
57 psa_status_t ti_psa_import_key(const psa_key_attributes_t *attributes,
58  const uint8_t *data,
59  size_t data_length,
60  mbedtls_svc_key_id_t *key);
61 
62 psa_status_t ti_psa_purge_key(mbedtls_svc_key_id_t key);
63 
64 void ti_psa_reset_key_attributes(psa_key_attributes_t *attributes);
65 
66 /******************************************************************************/
67 /* Asymmetric cryptography */
68 /******************************************************************************/
69 psa_status_t ti_psa_asymmetric_encrypt(mbedtls_svc_key_id_t key,
70  psa_algorithm_t alg,
71  const uint8_t *input,
72  size_t input_length,
73  const uint8_t *salt,
74  size_t salt_length,
75  uint8_t *output,
76  size_t output_size,
77  size_t *output_length);
78 
79 psa_status_t ti_psa_asymmetric_decrypt(mbedtls_svc_key_id_t key,
80  psa_algorithm_t alg,
81  const uint8_t *input,
82  size_t input_length,
83  const uint8_t *salt,
84  size_t salt_length,
85  uint8_t *output,
86  size_t output_size,
87  size_t *output_length);
88 
89 psa_status_t ti_psa_sign_message(mbedtls_svc_key_id_t key,
90  psa_algorithm_t alg,
91  const uint8_t *input,
92  size_t input_length,
93  uint8_t *signature,
94  size_t signature_size,
95  size_t *signature_length);
96 
97 psa_status_t ti_psa_verify_message(mbedtls_svc_key_id_t key,
98  psa_algorithm_t alg,
99  const uint8_t *input,
100  size_t input_length,
101  const uint8_t *signature,
102  size_t signature_length);
103 
104 psa_status_t ti_psa_sign_hash(mbedtls_svc_key_id_t key,
105  psa_algorithm_t alg,
106  const uint8_t *hash,
107  size_t hash_length,
108  uint8_t *signature,
109  size_t signature_size,
110  size_t *signature_length);
111 
112 psa_status_t ti_psa_verify_hash(mbedtls_svc_key_id_t key,
113  psa_algorithm_t alg,
114  const uint8_t *hash,
115  size_t hash_length,
116  const uint8_t *signature,
117  size_t signature_length);
118 
119 /******************************************************************************/
120 /* Key Derivation */
121 /******************************************************************************/
122 psa_status_t ti_psa_key_derivation_abort(psa_key_derivation_operation_t *operation);
123 
124 psa_status_t ti_psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, size_t *capacity);
125 
126 psa_status_t ti_psa_key_derivation_input_bytes(psa_key_derivation_operation_t *operation,
127  psa_key_derivation_step_t step,
128  const uint8_t *data,
129  size_t data_length);
130 
131 psa_status_t ti_psa_key_derivation_input_integer(psa_key_derivation_operation_t *operation,
132  psa_key_derivation_step_t step,
133  uint64_t value);
134 
135 psa_status_t ti_psa_key_derivation_input_key(psa_key_derivation_operation_t *operation,
136  psa_key_derivation_step_t step,
137  mbedtls_svc_key_id_t key);
138 
139 psa_status_t ti_psa_key_derivation_output_bytes(psa_key_derivation_operation_t *operation,
140  uint8_t *output,
141  size_t output_length);
142 
143 psa_status_t ti_psa_key_derivation_output_key(const psa_key_attributes_t *attributes,
144  psa_key_derivation_operation_t *operation,
145  mbedtls_svc_key_id_t *key);
146 
147 psa_status_t ti_psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity);
148 
149 psa_status_t ti_psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg);
150 
151 psa_status_t ti_psa_key_derivation_verify_bytes(psa_key_derivation_operation_t *operation,
152  const uint8_t *expected_output,
153  size_t output_length);
154 
155 psa_status_t ti_psa_key_derivation_verify_key(psa_key_derivation_operation_t *operation, mbedtls_svc_key_id_t expected);
156 
157 /******************************************************************************/
158 /* Key Agreement */
159 /******************************************************************************/
160 psa_status_t ti_psa_raw_key_agreement(psa_algorithm_t alg,
161  mbedtls_svc_key_id_t private_key,
162  const uint8_t *peer_key,
163  size_t peer_key_length,
164  uint8_t *output,
165  size_t output_size,
166  size_t *output_length);
167 
168 psa_status_t ti_psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation,
169  psa_key_derivation_step_t step,
170  mbedtls_svc_key_id_t private_key,
171  const uint8_t *peer_key,
172  size_t peer_key_length);
173 
174 #endif /* TI_PSA_CRYPTO_H */
psa_status_t ti_psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, size_t *capacity)
psa_status_t ti_psa_purge_key(mbedtls_svc_key_id_t key)
psa_status_t ti_psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, mbedtls_svc_key_id_t private_key, const uint8_t *peer_key, size_t peer_key_length)
psa_status_t ti_psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
psa_status_t ti_psa_verify_hash(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)
psa_status_t ti_psa_sign_hash(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
void ti_psa_reset_key_attributes(psa_key_attributes_t *attributes)
psa_status_t ti_psa_key_derivation_verify_key(psa_key_derivation_operation_t *operation, mbedtls_svc_key_id_t expected)
psa_status_t ti_psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity)
psa_status_t ti_psa_copy_key(mbedtls_svc_key_id_t source_key, const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *target_key)
psa_status_t ti_psa_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, mbedtls_svc_key_id_t *key)
psa_status_t ti_psa_raw_key_agreement(psa_algorithm_t alg, mbedtls_svc_key_id_t private_key, const uint8_t *peer_key, size_t peer_key_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t ti_psa_verify_message(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *signature, size_t signature_length)
psa_status_t ti_psa_export_public_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
psa_status_t ti_psa_key_derivation_input_key(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, mbedtls_svc_key_id_t key)
psa_status_t ti_psa_key_derivation_input_integer(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, uint64_t value)
psa_status_t ti_psa_key_derivation_verify_bytes(psa_key_derivation_operation_t *operation, const uint8_t *expected_output, size_t output_length)
psa_status_t ti_psa_get_key_attributes(mbedtls_svc_key_id_t key, psa_key_attributes_t *attributes)
aes_operation_t
Definition: ti_psa_crypto.h:34
psa_status_t ti_psa_sign_message(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
psa_status_t ti_psa_key_derivation_output_key(const psa_key_attributes_t *attributes, psa_key_derivation_operation_t *operation, mbedtls_svc_key_id_t *key)
Definition: ti_psa_crypto.h:37
psa_status_t ti_psa_generate_key(const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *key)
Definition: ti_psa_crypto.h:36
psa_status_t ti_psa_key_derivation_output_bytes(psa_key_derivation_operation_t *operation, uint8_t *output, size_t output_length)
psa_status_t ti_psa_asymmetric_encrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t ti_psa_destroy_key(mbedtls_svc_key_id_t key)
psa_status_t ti_psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
psa_status_t ti_psa_export_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
psa_status_t ti_psa_asymmetric_decrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t ti_psa_key_derivation_input_bytes(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, const uint8_t *data, size_t data_length)
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale