Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 1 | /* |
Marc Moreno Berengue | 675b6e9 | 2018-06-14 17:31:01 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, Arm Limited. All rights reserved. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __TFM_SST_API__ |
| 9 | #define __TFM_SST_API__ |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
Antonio de Angelis | eba14e1 | 2018-03-27 11:03:20 +0100 | [diff] [blame] | 15 | #include "tfm_sst_defs.h" |
| 16 | |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 17 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 18 | * \brief Allocates space for the asset, referenced by asset UUID, |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 19 | * without setting any data in the asset. |
| 20 | * |
| 21 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 22 | * \param[in] token Must be set to NULL, reserved for future use. |
| 23 | * Pointer to the asset token to be used to generate |
| 24 | * the asset key to encrypt and decrypt the asset |
| 25 | * data. This is an optional parameter that has to |
| 26 | * be NULL in case the token is not provied. |
| 27 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 28 | * Token size. In case the token is not provided |
| 29 | * the token size has to be 0. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 30 | * |
| 31 | * \return Returns an TFM_SST_ERR_SUCCESS if asset is created correctly. |
| 32 | * Otherwise, error code as specified in \ref tfm_sst_err_t |
| 33 | */ |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 34 | enum tfm_sst_err_t tfm_sst_create(uint32_t asset_uuid, |
| 35 | const uint8_t* token, |
| 36 | uint32_t token_size); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 37 | |
| 38 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 39 | * \brief Gets asset's information referenced by asset UUID. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 40 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 41 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 42 | * \param[in] token Must be set to NULL, reserved for future use. |
| 43 | * Pointer to the asset token to be used to generate |
| 44 | * the asset key to encrypt and decrypt the asset |
| 45 | * data. This is an optional parameter that has to |
| 46 | * be NULL in case the token is not provied. |
| 47 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 48 | * Token size. In case the token is not provided |
| 49 | * the token size has to be 0. |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 50 | * \param[out] info Pointer to store the asset's information |
| 51 | * \ref tfm_sst_asset_info_t |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 52 | * |
| 53 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 54 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 55 | enum tfm_sst_err_t tfm_sst_get_info(uint32_t asset_uuid, |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 56 | const uint8_t* token, |
| 57 | uint32_t token_size, |
Marc Moreno Berengue | 675b6e9 | 2018-06-14 17:31:01 +0100 | [diff] [blame] | 58 | struct tfm_sst_asset_info_t *info); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 59 | |
| 60 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 61 | * \brief Gets asset's attributes referenced by asset UUID. |
Marc Moreno Berengue | 51af951 | 2018-06-14 18:28:14 +0100 | [diff] [blame] | 62 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 63 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 64 | * \param[in] token Must be set to NULL, reserved for future use. |
| 65 | * Pointer to the asset token to be used to generate |
| 66 | * the asset key to encrypt and decrypt the asset |
| 67 | * data. This is an optional parameter that has to |
| 68 | * be NULL in case the token is not provied. |
| 69 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 70 | * Token size. In case the token is not provided |
| 71 | * the token size has to be 0. |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 72 | * \param[out] attrs Pointer to store the asset's attributes |
| 73 | * \ref tfm_sst_asset_attrs_t |
Marc Moreno Berengue | 51af951 | 2018-06-14 18:28:14 +0100 | [diff] [blame] | 74 | * |
| 75 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 76 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 77 | enum tfm_sst_err_t tfm_sst_get_attributes(uint32_t asset_uuid, |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 78 | const uint8_t* token, |
| 79 | uint32_t token_size, |
Marc Moreno Berengue | 51af951 | 2018-06-14 18:28:14 +0100 | [diff] [blame] | 80 | struct tfm_sst_asset_attrs_t *attrs); |
| 81 | |
| 82 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 83 | * \brief Sets asset's attributes referenced by asset UUID. |
Marc Moreno Berengue | 51af951 | 2018-06-14 18:28:14 +0100 | [diff] [blame] | 84 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 85 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 86 | * \param[in] token Must be set to NULL, reserved for future use. |
| 87 | * Pointer to the asset token to be used to generate |
| 88 | * the asset key to encrypt and decrypt the asset |
| 89 | * data. This is an optional parameter that has to |
| 90 | * be NULL in case the token is not provied. |
| 91 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 92 | * Token size. In case the token is not provided |
| 93 | * the token size has to be 0. |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 94 | * \param[in] attrs Pointer to new the asset's attributes |
| 95 | * \ref tfm_sst_asset_attrs_t |
Marc Moreno Berengue | 51af951 | 2018-06-14 18:28:14 +0100 | [diff] [blame] | 96 | * |
| 97 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 98 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 99 | enum tfm_sst_err_t tfm_sst_set_attributes( |
| 100 | uint32_t asset_uuid, |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 101 | const uint8_t* token, |
| 102 | uint32_t token_size, |
Marc Moreno Berengue | 51af951 | 2018-06-14 18:28:14 +0100 | [diff] [blame] | 103 | const struct tfm_sst_asset_attrs_t *attrs); |
| 104 | |
| 105 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 106 | * \brief Reads asset's data from asset referenced by asset UUID. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 107 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 108 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 109 | * \param[in] token Must be set to NULL, reserved for future use. |
| 110 | * Pointer to the asset token to be used to generate |
| 111 | * the asset key to encrypt and decrypt the asset |
| 112 | * data. This is an optional parameter that has to |
| 113 | * be NULL in case the token is not provied. |
| 114 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 115 | * Token size. In case the token is not provided |
| 116 | * the token size has to be 0. |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 117 | * \param[out] data Pointer to data vector \ref tfm_sst_buf_t to store |
| 118 | * data, size and offset |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 119 | * |
| 120 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 121 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 122 | enum tfm_sst_err_t tfm_sst_read(uint32_t asset_uuid, |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 123 | const uint8_t* token, |
| 124 | uint32_t token_size, |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 125 | struct tfm_sst_buf_t* data); |
| 126 | |
| 127 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 128 | * \brief Writes data into an asset referenced by asset UUID. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 129 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 130 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 131 | * \param[in] token Must be set to NULL, reserved for future use. |
| 132 | * Pointer to the asset token to be used to generate |
| 133 | * the asset key to encrypt and decrypt the asset |
| 134 | * data. This is an optional parameter that has to |
| 135 | * be NULL in case the token is not provied. |
| 136 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 137 | * Token size. In case the token is not provided |
| 138 | * the token size has to be 0. |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 139 | * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which |
| 140 | * contains the data to write |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 141 | * |
| 142 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 143 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 144 | enum tfm_sst_err_t tfm_sst_write(uint32_t asset_uuid, |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 145 | const uint8_t* token, |
| 146 | uint32_t token_size, |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 147 | struct tfm_sst_buf_t* data); |
| 148 | |
| 149 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 150 | * \brief Deletes the asset referenced by the asset UUID. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 151 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 152 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 153 | * \param[in] token Must be set to NULL, reserved for future use. |
| 154 | * Pointer to the asset token to be used to generate |
| 155 | * the asset key to encrypt and decrypt the asset |
| 156 | * data. This is an optional parameter that has to |
| 157 | * be NULL in case the token is not provied. |
| 158 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 159 | * Token size. In case the token is not provided |
| 160 | * the token size has to be 0. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 161 | * |
| 162 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 163 | */ |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame^] | 164 | enum tfm_sst_err_t tfm_sst_delete(uint32_t asset_uuid, |
| 165 | const uint8_t* token, |
| 166 | uint32_t token_size); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 167 | |
| 168 | #ifdef __cplusplus |
| 169 | } |
| 170 | #endif |
| 171 | |
| 172 | #endif /* __TFM_SST_API__ */ |