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 | 7903294 | 2018-06-26 15:34:05 +0100 | [diff] [blame^] | 117 | * \param[in] size Size of the data to read |
| 118 | * \param[in] offset Offset within asset to start to read |
| 119 | * \param[out] data Pointer to data vector to store data |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 120 | * |
| 121 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 122 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 123 | 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] | 124 | const uint8_t* token, |
| 125 | uint32_t token_size, |
Marc Moreno Berengue | 7903294 | 2018-06-26 15:34:05 +0100 | [diff] [blame^] | 126 | uint32_t size, |
| 127 | uint32_t offset, |
| 128 | uint8_t *data); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 129 | |
| 130 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 131 | * \brief Writes data into an asset referenced by asset UUID. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 132 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 133 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame] | 134 | * \param[in] token Must be set to NULL, reserved for future use. |
| 135 | * Pointer to the asset token to be used to generate |
| 136 | * the asset key to encrypt and decrypt the asset |
| 137 | * data. This is an optional parameter that has to |
| 138 | * be NULL in case the token is not provied. |
| 139 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 140 | * Token size. In case the token is not provided |
| 141 | * the token size has to be 0. |
Marc Moreno Berengue | 7903294 | 2018-06-26 15:34:05 +0100 | [diff] [blame^] | 142 | * \param[in] size Size of the data to start to write |
| 143 | * \param[in] offset Offset within asset to write the data |
| 144 | * \param[in] data Pointer to data vector which contains the data to |
| 145 | * write |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 146 | * |
| 147 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 148 | */ |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 149 | 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] | 150 | const uint8_t* token, |
| 151 | uint32_t token_size, |
Marc Moreno Berengue | 7903294 | 2018-06-26 15:34:05 +0100 | [diff] [blame^] | 152 | uint32_t size, |
| 153 | uint32_t offset, |
| 154 | const uint8_t *data); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 155 | |
| 156 | /** |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 157 | * \brief Deletes the asset referenced by the asset UUID. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 158 | * |
Marc Moreno Berengue | 4258e54 | 2018-06-18 13:55:59 +0100 | [diff] [blame] | 159 | * \param[in] asset_uuid Asset UUID |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame] | 160 | * \param[in] token Must be set to NULL, reserved for future use. |
| 161 | * Pointer to the asset token to be used to generate |
| 162 | * the asset key to encrypt and decrypt the asset |
| 163 | * data. This is an optional parameter that has to |
| 164 | * be NULL in case the token is not provied. |
| 165 | * \param[in] token_size Must be set to 0, reserved for future use. |
| 166 | * Token size. In case the token is not provided |
| 167 | * the token size has to be 0. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 168 | * |
| 169 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 170 | */ |
Marc Moreno Berengue | 10d0d36 | 2018-06-18 14:15:56 +0100 | [diff] [blame] | 171 | enum tfm_sst_err_t tfm_sst_delete(uint32_t asset_uuid, |
| 172 | const uint8_t* token, |
| 173 | uint32_t token_size); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 174 | |
| 175 | #ifdef __cplusplus |
| 176 | } |
| 177 | #endif |
| 178 | |
| 179 | #endif /* __TFM_SST_API__ */ |