Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 1 | /* |
Antonio de Angelis | 377a155 | 2018-11-22 17:02:40 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __TFM_CRYPTO_VENEERS_H__ |
| 9 | #define __TFM_CRYPTO_VENEERS_H__ |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | #include "tfm_crypto_defs.h" |
| 16 | |
| 17 | #include "psa_crypto.h" |
| 18 | |
| 19 | #include "crypto_psa_wrappers.h" |
| 20 | |
| 21 | /** |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 22 | * \brief Import the key data in the provided key slot (veneer function) |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 23 | * |
| 24 | * \param[in] key Key slot |
| 25 | * \param[in] type Key type |
| 26 | * \param[in] data Key data to import |
| 27 | * \param[in] data_length Length in bytes of the data field |
| 28 | * |
| 29 | * \return Return values as described in \ref tfm_crypto_err_t |
| 30 | */ |
| 31 | enum tfm_crypto_err_t tfm_crypto_veneer_import_key(psa_key_slot_t key, |
| 32 | psa_key_type_t type, |
| 33 | const uint8_t *data, |
| 34 | size_t data_length); |
| 35 | /** |
| 36 | * \brief Destroy the key in the provided key slot (veneer function) |
| 37 | * |
| 38 | * \param[in] key Key slot |
| 39 | * |
| 40 | * \return Return values as described in \ref tfm_crypto_err_t |
| 41 | */ |
| 42 | enum tfm_crypto_err_t tfm_crypto_veneer_destroy_key(psa_key_slot_t key); |
| 43 | |
| 44 | /** |
| 45 | * \brief Retrieve key information for the provided key slot (veneer function) |
| 46 | * |
| 47 | * \param[in] key Key slot |
| 48 | * \param[out] type Key type associated to the key slot requested |
| 49 | * \param[out] bits Length in bits of the key in the requested slot |
| 50 | * |
| 51 | * \return Return values as described in \ref tfm_crypto_err_t |
| 52 | */ |
| 53 | enum tfm_crypto_err_t tfm_crypto_veneer_get_key_information( |
| 54 | psa_key_slot_t key, |
| 55 | psa_key_type_t *type, |
| 56 | size_t *bits); |
| 57 | /** |
| 58 | * \brief Export the key contained in the provided key slot (veneer function) |
| 59 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 60 | * \param[in] key Key slot |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 61 | * \param[out] data Buffer to hold the exported key |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 62 | * \param[in] data_size Length of the buffer pointed to by data |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 63 | * \param[out] data_length Length of the exported key |
| 64 | * |
| 65 | * \return Return values as described in \ref tfm_crypto_err_t |
| 66 | */ |
| 67 | enum tfm_crypto_err_t tfm_crypto_veneer_export_key(psa_key_slot_t key, |
| 68 | uint8_t *data, |
| 69 | size_t data_size, |
| 70 | size_t *data_length); |
Jamie Fox | efd8273 | 2018-11-26 10:34:32 +0000 | [diff] [blame^] | 71 | |
| 72 | /** |
| 73 | * \brief Initialise the key policy to a default that forbids any use of the |
| 74 | * key (veneer function) |
| 75 | * |
| 76 | * \param[out] policy Key policy to initialise |
| 77 | * |
| 78 | * \return Return values as described in \ref tfm_crypto_err_t |
| 79 | */ |
| 80 | enum tfm_crypto_err_t tfm_crypto_veneer_key_policy_init( |
| 81 | psa_key_policy_t *policy); |
| 82 | |
| 83 | /** |
| 84 | * \brief Set the permitted usage and algorithm for the provided key policy |
| 85 | * (veneer function) |
| 86 | * |
| 87 | * \param[out] policy Key policy to modify |
| 88 | * \param[in] usage Permitted usage |
| 89 | * \param[in] alg Permitted algorithm |
| 90 | * |
| 91 | * \return Return values as described in \ref tfm_crypto_err_t |
| 92 | */ |
| 93 | enum tfm_crypto_err_t tfm_crypto_veneer_key_policy_set_usage( |
| 94 | psa_key_policy_t *policy, |
| 95 | psa_key_usage_t usage, |
| 96 | psa_algorithm_t alg); |
| 97 | |
| 98 | /** |
| 99 | * \brief Get the permitted usage for the provided key policy (veneer function) |
| 100 | * |
| 101 | * \param[in] policy Key policy |
| 102 | * \param[out] usage Permitted usage for this key policy |
| 103 | * |
| 104 | * \return Return values as described in \ref tfm_crypto_err_t |
| 105 | */ |
| 106 | enum tfm_crypto_err_t tfm_crypto_veneer_key_policy_get_usage( |
| 107 | const psa_key_policy_t *policy, |
| 108 | psa_key_usage_t *usage); |
| 109 | |
| 110 | /** |
| 111 | * \brief Get the permitted algorithm for the provided key policy |
| 112 | * (veneer function) |
| 113 | * |
| 114 | * \param[in] policy Key policy |
| 115 | * \param[out] alg Permitted algorithm for this key policy |
| 116 | * |
| 117 | * \return Return values as described in \ref tfm_crypto_err_t |
| 118 | */ |
| 119 | enum tfm_crypto_err_t tfm_crypto_veneer_key_policy_get_algorithm( |
| 120 | const psa_key_policy_t *policy, |
| 121 | psa_algorithm_t *alg); |
| 122 | |
| 123 | /** |
| 124 | * \brief Set the key policy for the provided key slot (veneer function) |
| 125 | * |
| 126 | * \param[in] key Key slot |
| 127 | * \param[in] policy Key policy |
| 128 | * |
| 129 | * \return Return values as described in \ref tfm_crypto_err_t |
| 130 | */ |
| 131 | enum tfm_crypto_err_t tfm_crypto_veneer_set_key_policy( |
| 132 | psa_key_slot_t key, |
| 133 | const psa_key_policy_t *policy); |
| 134 | |
| 135 | /** |
| 136 | * \brief Get the key policy for the provided key slot (veneer function) |
| 137 | * |
| 138 | * \param[in] key Key slot |
| 139 | * \param[out] policy Key policy |
| 140 | * |
| 141 | * \return Return values as described in \ref tfm_crypto_err_t |
| 142 | */ |
| 143 | enum tfm_crypto_err_t tfm_crypto_veneer_get_key_policy( |
| 144 | psa_key_slot_t key, |
| 145 | psa_key_policy_t *policy); |
| 146 | |
| 147 | /** |
| 148 | * \brief Set the lifetime for the provided key slot (veneer function) |
| 149 | * |
| 150 | * \param[in] key Key slot |
| 151 | * \param[in] lifetime Lifetime value |
| 152 | * |
| 153 | * \return Return values as described in \ref tfm_crypto_err_t |
| 154 | */ |
| 155 | enum tfm_crypto_err_t tfm_crypto_veneer_set_key_lifetime( |
| 156 | psa_key_slot_t key, |
| 157 | psa_key_lifetime_t lifetime); |
| 158 | |
| 159 | /** |
| 160 | * \brief Get the lifetime for the provided key slot (veneer function) |
| 161 | * |
| 162 | * \param[in] key Key slot |
| 163 | * \param[out] lifetime Lifetime value |
| 164 | * |
| 165 | * \return Return values as described in \ref tfm_crypto_err_t |
| 166 | */ |
| 167 | enum tfm_crypto_err_t tfm_crypto_veneer_get_key_lifetime( |
| 168 | psa_key_slot_t key, |
| 169 | psa_key_lifetime_t *lifetime); |
| 170 | |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 171 | /** |
| 172 | * \brief Set the initialisation vector on the provided cipher operation (veneer |
| 173 | * function) |
| 174 | * |
| 175 | * \param[in] operation Cipher operation context |
| 176 | * \param[in] iv Buffer that contains the IV |
| 177 | * \param[in] iv_length Length of the provided IV |
| 178 | * |
| 179 | * \return Return values as described in \ref tfm_crypto_err_t |
| 180 | */ |
Antonio de Angelis | 377a155 | 2018-11-22 17:02:40 +0000 | [diff] [blame] | 181 | enum tfm_crypto_err_t tfm_crypto_veneer_cipher_set_iv( |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 182 | psa_cipher_operation_t *operation, |
| 183 | const unsigned char *iv, |
| 184 | size_t iv_length); |
| 185 | /** |
| 186 | * \brief Set the cipher operation using the provided algorithm and key slot, |
| 187 | * for encryption context (veneer function) |
| 188 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 189 | * \note A successful call to this function initialises a cipher operation |
| 190 | * context which will be referred using the operation parameter |
| 191 | * |
| 192 | * \param[out] operation Cipher operation context |
| 193 | * \param[in] key Key slot to bind to the cipher context |
| 194 | * \param[in] alg Algorithm to use for the cipher operation |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 195 | * |
| 196 | * \return Return values as described in \ref tfm_crypto_err_t |
| 197 | */ |
Antonio de Angelis | 377a155 | 2018-11-22 17:02:40 +0000 | [diff] [blame] | 198 | enum tfm_crypto_err_t tfm_crypto_veneer_cipher_encrypt_setup( |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 199 | psa_cipher_operation_t *operation, |
| 200 | psa_key_slot_t key, |
| 201 | psa_algorithm_t alg); |
| 202 | /** |
| 203 | * \brief Set the cipher operation using the provided algorithm and key slot, |
| 204 | * for decryption context (veneer function) |
| 205 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 206 | * \note A successful call to this function initialises a cipher operation |
| 207 | * context which will be referred using the operation parameter |
| 208 | * |
| 209 | * \param[out] operation Cipher operation context |
| 210 | * \param[in] key Key slot to bind to the cipher context |
| 211 | * \param[in] alg Algorithm to use for the cipher operation |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 212 | * |
| 213 | * \return Return values as described in \ref tfm_crypto_err_t |
| 214 | */ |
Antonio de Angelis | 377a155 | 2018-11-22 17:02:40 +0000 | [diff] [blame] | 215 | enum tfm_crypto_err_t tfm_crypto_veneer_cipher_decrypt_setup( |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 216 | psa_cipher_operation_t *operation, |
| 217 | psa_key_slot_t key, |
| 218 | psa_algorithm_t alg); |
| 219 | /** |
| 220 | * \brief Update the cipher context with a chunk of input data to create a |
| 221 | * chunk of encrypted output data (for encryption contexts), or to |
| 222 | * decrypt a chunk of encrypted input data to obtain decrypted data |
| 223 | * (for decryption contexts) (veneer function) |
| 224 | * |
| 225 | * \param[in] operation Cipher operation context |
| 226 | * \param[in] input_s Pointer to the struct containing input parameters |
| 227 | * \param[out] output_s Pointer to the struct containing output parameters |
| 228 | * |
| 229 | * \return Return values as described in \ref tfm_crypto_err_t |
| 230 | */ |
| 231 | enum tfm_crypto_err_t tfm_crypto_veneer_cipher_update( |
| 232 | psa_cipher_operation_t *operation, |
| 233 | struct psa_cipher_update_input *input_s, |
| 234 | struct psa_cipher_update_output *output_s); |
| 235 | /** |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 236 | * \brief Finalise a cipher context flushing out any remaining block of |
| 237 | * output data (veneer function) |
| 238 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 239 | * \note A successful call to this function releases the cipher operation |
| 240 | * context provided as parameter |
| 241 | * |
| 242 | * \param[in/out] operation Cipher operation context |
| 243 | * \param[out] output Buffer containing output data |
| 244 | * \param[in] output_size Size of the output buffer |
| 245 | * \param[out] output_length Size of the produced output |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 246 | * |
| 247 | * \return Return values as described in \ref tfm_crypto_err_t |
| 248 | */ |
| 249 | enum tfm_crypto_err_t tfm_crypto_veneer_cipher_finish( |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 250 | psa_cipher_operation_t *operation, |
| 251 | uint8_t *output, |
| 252 | size_t output_size, |
| 253 | size_t *output_length); |
| 254 | /** |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 255 | * \brief Abort a cipher operation, clear the operation context provided |
| 256 | * (veneer function) |
| 257 | * |
| 258 | * \note A successful call to this function releases the cipher operation |
| 259 | * context provided as parameter |
| 260 | * |
| 261 | * \param[in/out] operation Cipher operation context |
| 262 | * |
| 263 | * \return Return values as described in \ref tfm_crypto_err_t |
| 264 | */ |
| 265 | enum tfm_crypto_err_t tfm_crypto_veneer_cipher_abort( |
| 266 | psa_cipher_operation_t *operation); |
| 267 | /** |
Antonio de Angelis | 377a155 | 2018-11-22 17:02:40 +0000 | [diff] [blame] | 268 | * \brief Setup a hash operation with the provided algorithm (veneer function) |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 269 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 270 | * \note A successful call to this function initialises a hash operation |
| 271 | * context which will be referred using the operation parameter |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 272 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 273 | * \param[out] operation Hash operation context |
| 274 | * \param[in] alg Algorithm chosen as hash |
| 275 | * |
| 276 | * \return Return values as described in \ref tfm_crypto_err_t |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 277 | */ |
Antonio de Angelis | 377a155 | 2018-11-22 17:02:40 +0000 | [diff] [blame] | 278 | enum tfm_crypto_err_t tfm_crypto_veneer_hash_setup( |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 279 | psa_hash_operation_t *operation, |
| 280 | psa_algorithm_t alg); |
| 281 | /** |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 282 | * \brief Add a new input chunk to the data for which the final hash value |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 283 | * will be computed (veneer function) |
| 284 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 285 | * \param[in/out] operation Hash operation context |
| 286 | * \param[in] input Buffer containing the input data |
| 287 | * \param[in] input_length Size of the provided input data |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 288 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 289 | * \return Return values as described in \ref tfm_crypto_err_t |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 290 | */ |
| 291 | enum tfm_crypto_err_t tfm_crypto_veneer_hash_update( |
| 292 | psa_hash_operation_t *operation, |
| 293 | const uint8_t *input, |
| 294 | size_t input_length); |
| 295 | /** |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 296 | * \brief Finalise a hash context operation producing the final hash value |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 297 | * (veneer function) |
| 298 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 299 | * \note A successful call to this function releases the hash operation |
| 300 | * context provided as parameter |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 301 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 302 | * \param[in/out] operation Hash operation context |
| 303 | * \param[out] hash Buffer containing hash data |
| 304 | * \param[in] hash_size Size of the hash buffer |
| 305 | * \param[out] hash_length Size of the produced hash |
| 306 | * |
| 307 | * \return Return values as described in \ref tfm_crypto_err_t |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 308 | */ |
| 309 | enum tfm_crypto_err_t tfm_crypto_veneer_hash_finish( |
| 310 | psa_hash_operation_t *operation, |
| 311 | uint8_t *hash, |
| 312 | size_t hash_size, |
| 313 | size_t *hash_length); |
| 314 | /** |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 315 | * \brief Finalise a hash context operation, verifying that the final hash |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 316 | * value matches the one provided as input (veneer function) |
| 317 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 318 | * \note A successful call to this function releases the hash operation |
| 319 | * context provided as parameter. The hash operation is released |
| 320 | * also in case TFM_CRYPTO_ERR_PSA_ERROR_INVALID_SIGNATURE is returned |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 321 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 322 | * \param[in/out] operation Hash operation context |
| 323 | * \param[in] hash Buffer containing the provided hash value |
| 324 | * \param[in] hash_length Size of the provided hash value |
| 325 | * |
| 326 | * \return Return values as described in \ref tfm_crypto_err_t |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 327 | */ |
| 328 | enum tfm_crypto_err_t tfm_crypto_veneer_hash_verify( |
| 329 | psa_hash_operation_t *operation, |
| 330 | const uint8_t *hash, |
| 331 | size_t hash_length); |
| 332 | /** |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 333 | * \brief Abort a hash operation, clears the operation context provided |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 334 | * (veneer function) |
| 335 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 336 | * \note A successful call to this function releases the hash operation |
| 337 | * context provided as parameter |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 338 | * |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 339 | * \param[in/out] operation Hash operation context |
| 340 | * |
| 341 | * \return Return values as described in \ref tfm_crypto_err_t |
Antonio de Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 342 | */ |
| 343 | enum tfm_crypto_err_t tfm_crypto_veneer_hash_abort( |
| 344 | psa_hash_operation_t *operation); |
Louis Mayencourt | 7a36f78 | 2018-09-24 14:00:57 +0100 | [diff] [blame] | 345 | /** |
| 346 | * \brief Start a MAC operation with the provided algorithm (for signing) |
| 347 | * (veneer function) |
| 348 | * |
| 349 | * \note A successful call to this function initialises a MAC operation |
| 350 | * context which will be referred using the operation parameter |
| 351 | * |
| 352 | * \param[out] operation MAC operation context |
| 353 | * \param[in] key Key slot to bind to the MAC context |
| 354 | * \param[in] alg Algorithm chosen as MAC |
| 355 | * |
| 356 | * \return Return values as described in \ref tfm_crypto_err_t |
| 357 | */ |
| 358 | enum tfm_crypto_err_t tfm_crypto_veneer_mac_sign_setup( |
| 359 | psa_mac_operation_t *operation, |
| 360 | psa_key_slot_t key, |
| 361 | psa_algorithm_t alg); |
| 362 | /** |
| 363 | * \brief Start a MAC operation with the provided algorithm (for verifying) |
| 364 | * (veneer function) |
| 365 | * |
| 366 | * \note A successful call to this function initialises a MAC operation |
| 367 | * context which will be referred using the operation parameter |
| 368 | * |
| 369 | * \param[out] operation MAC operation context |
| 370 | * \param[in] key Key slot to bind to the MAC context |
| 371 | * \param[in] alg Algorithm chosen as MAC |
| 372 | * |
| 373 | * \return Return values as described in \ref tfm_crypto_err_t |
| 374 | */ |
| 375 | enum tfm_crypto_err_t tfm_crypto_veneer_mac_verify_setup( |
| 376 | psa_mac_operation_t *operation, |
| 377 | psa_key_slot_t key, |
| 378 | psa_algorithm_t alg); |
| 379 | /** |
| 380 | * \brief Adds a new input chunk to the data for which the final MAC value |
| 381 | * will be computed (veneer function) |
| 382 | * |
| 383 | * \param[in/out] operation MAC operation context |
| 384 | * \param[in] input Buffer containing the input data |
| 385 | * \param[in] input_length Size of the provided input data |
| 386 | * |
| 387 | * \return Return values as described in \ref tfm_crypto_err_t |
| 388 | */ |
| 389 | enum tfm_crypto_err_t tfm_crypto_veneer_mac_update( |
| 390 | psa_mac_operation_t *operation, |
| 391 | const uint8_t *input, |
| 392 | size_t input_length); |
| 393 | |
| 394 | /** |
| 395 | * \brief Finalises a MAC context operation producing the final MAC value |
| 396 | * (veneer function) |
| 397 | * |
| 398 | * \note A successful call to this function releases the MAC operation |
| 399 | * context provided as parameter |
| 400 | * |
| 401 | * \param[in/out] operation MAC operation context |
| 402 | * \param[out] mac Buffer containing MAC data |
| 403 | * \param[in] mac_size Size of the MAC buffer |
| 404 | * \param[out] mac_length Size of the produced MAC |
| 405 | * |
| 406 | * \return Return values as described in \ref tfm_crypto_err_t |
| 407 | */ |
| 408 | enum tfm_crypto_err_t tfm_crypto_veneer_mac_sign_finish( |
| 409 | psa_mac_operation_t *operation, |
| 410 | uint8_t *mac, |
| 411 | size_t mac_size, |
| 412 | size_t *mac_length); |
| 413 | /** |
| 414 | * \brief Finalise a MAC context operation, verifying that the final MAC value |
| 415 | * matches the one provided as input (veneer function) |
| 416 | * |
| 417 | * \note A successful call to this function releases the MAC operation |
| 418 | * context provided as parameter. The MAC operation is released |
| 419 | * also in case TFM_CRYPTO_ERR_PSA_ERROR_INVALID_SIGNATURE is returned |
| 420 | * |
| 421 | * \param[in/out] operation MAC operation context |
| 422 | * \param[in] mac Buffer containing the provided MAC value |
| 423 | * \param[in] mac_length Size of the provided MAC value |
| 424 | * |
| 425 | * \return Return values as described in \ref tfm_crypto_err_t |
| 426 | */ |
| 427 | enum tfm_crypto_err_t tfm_crypto_veneer_mac_verify_finish( |
| 428 | psa_mac_operation_t *operation, |
| 429 | const uint8_t *mac, |
| 430 | size_t mac_length); |
| 431 | /** |
| 432 | * \brief Abort a MAC operation, clear the operation context provided |
| 433 | * (veneer function) |
| 434 | * |
| 435 | * \note A successful call to this function releases the MAC operation |
| 436 | * context provided as parameter |
| 437 | * |
| 438 | * \param[in/out] operation MAC operation context |
| 439 | * |
| 440 | * \return Return values as described in \ref tfm_crypto_err_t |
| 441 | */ |
| 442 | enum tfm_crypto_err_t tfm_crypto_veneer_mac_abort( |
| 443 | psa_mac_operation_t *operation); |
Antonio de Angelis | 3a48099 | 2018-11-07 11:53:28 +0000 | [diff] [blame] | 444 | /** |
| 445 | * \brief Perform an AEAD encryption operation on input data with additional |
| 446 | * data to be authenticated, producing ciphertext in output with an |
| 447 | * appended authentication tag (veneer function) |
| 448 | * |
| 449 | * \param[in] input_s Pointer to the struct containing input parameters |
| 450 | * \param[out] output_s Pointer to the struct containing output parameters |
| 451 | * |
| 452 | * \return Return values as described in \ref tfm_crypto_err_t |
| 453 | */ |
| 454 | enum tfm_crypto_err_t tfm_crypto_veneer_aead_encrypt( |
| 455 | struct psa_aead_encrypt_input *input_s, |
| 456 | struct psa_aead_encrypt_output *output_s); |
| 457 | /** |
| 458 | * \brief Perform an AEAD decryption operation on input data with additional |
| 459 | * data to be verified, producing back the original plain text in case |
| 460 | * the verification of the authentication tag is successful (veneer |
| 461 | * function) |
| 462 | * |
| 463 | * \param[in] input_s Pointer to the struct containing input parameters |
| 464 | * \param[out] output_s Pointer to the struct containing output parameters |
| 465 | * |
| 466 | * \return Return values as described in \ref tfm_crypto_err_t |
| 467 | */ |
| 468 | enum tfm_crypto_err_t tfm_crypto_veneer_aead_decrypt( |
| 469 | struct psa_aead_decrypt_input *input_s, |
| 470 | struct psa_aead_decrypt_output *output_s); |
Louis Mayencourt | 7a36f78 | 2018-09-24 14:00:57 +0100 | [diff] [blame] | 471 | |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 472 | #ifdef __cplusplus |
| 473 | } |
| 474 | #endif |
| 475 | |
| 476 | #endif /* __TFM_CRYPTO_VENEERS_H__ */ |