Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 1 | /* |
Antonio de Angelis | 3a48099 | 2018-11-07 11:53:28 +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 __CRYPTO_PSA_WRAPPERS_H__ |
| 9 | #define __CRYPTO_PSA_WRAPPERS_H__ |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | /*! |
| 16 | * \struct psa_cipher_update_input |
| 17 | * |
| 18 | * \brief Input structure for the tfm_crypto_cipher_update_wrapper function |
| 19 | * |
| 20 | */ |
| 21 | struct psa_cipher_update_input { |
| 22 | const uint8_t *input; /*!< Input data to the cipher */ |
| 23 | size_t input_length; /*!< Size of the input data */ |
| 24 | }; |
| 25 | |
| 26 | /*! |
| 27 | * \struct psa_cipher_update_output |
| 28 | * |
| 29 | * \brief Output structure for the tfm_crypto_cipher_update_wrapper function |
| 30 | * |
| 31 | */ |
| 32 | struct psa_cipher_update_output { |
| 33 | unsigned char *output; /*!< Buffer to hold the output data from the cipher*/ |
| 34 | size_t output_size; /*!< Size of the output buffer */ |
| 35 | size_t *output_length; /*!< Size of the output data from the cipher */ |
| 36 | }; |
| 37 | |
| 38 | /*! |
| 39 | * \brief This function is a TF-M compatible wrapper for the |
| 40 | * \ref tfm_crypto_cipher_update implemented in the Crypto service |
| 41 | * |
| 42 | * \param[in] input_s Pointer to the structure containing input parameters |
| 43 | * associated with \ref psa_cipher_update_input |
| 44 | * \param[out] output_s Pointer to the structure containing output parameters |
| 45 | * associated with \ref psa_cipher_update_output |
| 46 | * |
| 47 | */ |
| 48 | enum tfm_crypto_err_t tfm_crypto_cipher_update_wrapper( |
| 49 | psa_cipher_operation_t *operation, |
| 50 | struct psa_cipher_update_input *input_s, |
| 51 | struct psa_cipher_update_output *output_s); |
| 52 | |
Antonio de Angelis | 3a48099 | 2018-11-07 11:53:28 +0000 | [diff] [blame^] | 53 | /*! |
| 54 | * \struct psa_aead_encrypt_input |
| 55 | * |
| 56 | * \brief Input structure for the tfm_crypto_aead_encrypt_wrapper function |
| 57 | * |
| 58 | */ |
| 59 | struct psa_aead_encrypt_input { |
| 60 | psa_key_slot_t key; /*!< Key slot */ |
| 61 | psa_algorithm_t alg; /*!< Algorithm type */ |
| 62 | const uint8_t *nonce; /*!< Nonce or IV to be used */ |
| 63 | size_t nonce_length; /*!< Size in bytes of the nonce buffer */ |
| 64 | const uint8_t *additional_data; /*!< Additional data to be authenticated */ |
| 65 | size_t additional_data_length; /*!< Size in bytes of additional_data */ |
| 66 | const uint8_t *plaintext; /*!< Buffer holding data for encryption */ |
| 67 | size_t plaintext_length; /*!< Size in bytes of plaintext */ |
| 68 | }; |
| 69 | |
| 70 | /*! |
| 71 | * \struct psa_aead_encrypt_output |
| 72 | * |
| 73 | * \brief Output structure for the tfm_crypto_aead_encrypt_wrapper function |
| 74 | * |
| 75 | */ |
| 76 | struct psa_aead_encrypt_output { |
| 77 | uint8_t *ciphertext; /*!< Pointer for the buffer to hold ciphertext */ |
| 78 | size_t ciphertext_size; /*!< Size in bytes of the ciphertext buffer */ |
| 79 | size_t *ciphertext_length; /*!< Actual size in bytes of ciphertext */ |
| 80 | }; |
| 81 | |
| 82 | /*! |
| 83 | * \struct psa_aead_decrypt_input |
| 84 | * |
| 85 | * \brief Input structure for the tfm_crypto_aead_decrypt_wrapper function |
| 86 | * |
| 87 | */ |
| 88 | struct psa_aead_decrypt_input { |
| 89 | psa_key_slot_t key; /*!< Key slot */ |
| 90 | psa_algorithm_t alg; /*!< Algorithm type */ |
| 91 | const uint8_t *nonce; /*!< Nonce or IV to be used */ |
| 92 | size_t nonce_length; /*!< Size in bytes of the nonce buffer */ |
| 93 | const uint8_t *additional_data; /*!< Original data that was authenticated */ |
| 94 | size_t additional_data_length; /*!< Size in bytes of additional_data */ |
| 95 | const uint8_t *ciphertext; /*!< Buffer holding data for decryption */ |
| 96 | size_t ciphertext_length; /*!< Size in bytes of ciphertext */ |
| 97 | }; |
| 98 | |
| 99 | /*! |
| 100 | * \struct psa_aead_decrypt_output |
| 101 | * |
| 102 | * \brief Output structure for the tfm_crypto_aead_decrypt_wrapper function |
| 103 | * |
| 104 | */ |
| 105 | struct psa_aead_decrypt_output { |
| 106 | uint8_t *plaintext; /*!< Pointer for the buffer to hold plaintext */ |
| 107 | size_t plaintext_size; /*!< Size in bytes of the plaintext buffer */ |
| 108 | size_t *plaintext_length; /*!< Actual size in bytes of plaintext */ |
| 109 | }; |
| 110 | |
| 111 | /*! |
| 112 | * \brief This function is a TF-M compatible wrapper for the |
| 113 | * \ref tfm_crypto_aead_encrypt implemented in the Crypto service |
| 114 | * |
| 115 | * \param[in] input_s Pointer to the structure containing input parameters |
| 116 | * associated with \ref psa_aead_encrypt_input |
| 117 | * \param[out] output_s Pointer to the structure containing output parameters |
| 118 | * associated with \ref psa_aead_encrypt_output |
| 119 | * |
| 120 | */ |
| 121 | enum tfm_crypto_err_t tfm_crypto_aead_encrypt_wrapper( |
| 122 | struct psa_aead_encrypt_input *input_s, |
| 123 | struct psa_aead_encrypt_output *output_s); |
| 124 | /*! |
| 125 | * \brief This function is a TF-M compatible wrapper for the |
| 126 | * \ref tfm_crypto_aead_decrypt implemented in the Crypto service |
| 127 | * |
| 128 | * \param[in] input_s Pointer to the structure containing input parameters |
| 129 | * associated with \ref psa_aead_decrypt_input |
| 130 | * \param[out] output_s Pointer to the structure containing output parameters |
| 131 | * associated with \ref psa_aead_decrypt_output |
| 132 | * |
| 133 | */ |
| 134 | enum tfm_crypto_err_t tfm_crypto_aead_decrypt_wrapper( |
| 135 | struct psa_aead_decrypt_input *input_s, |
| 136 | struct psa_aead_decrypt_output *output_s); |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 137 | #ifdef __cplusplus |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | #endif /* __CRYPTO_PSA_WRAPPERS_H__ */ |