blob: 58d933394695d22968bd4b908029b7c03019ab02 [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +01002 * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
Ashutosh Singhf4d88672017-11-29 13:35:43 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_SST_API__
9#define __TFM_SST_API__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
Antonio de Angeliseba14e12018-03-27 11:03:20 +010015#include "tfm_sst_defs.h"
16
Ashutosh Singhf4d88672017-11-29 13:35:43 +000017/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010018 * \brief Allocates space for the asset, referenced by asset UUID,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000019 * without setting any data in the asset.
20 *
21 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010022 * \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 Singhf4d88672017-11-29 13:35:43 +000030 *
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 Berengue10d0d362018-06-18 14:15:56 +010034enum tfm_sst_err_t tfm_sst_create(uint32_t asset_uuid,
35 const uint8_t* token,
36 uint32_t token_size);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000037
38/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010039 * \brief Gets asset's information referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +000040 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010041 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010042 * \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 Berengue4258e542018-06-18 13:55:59 +010050 * \param[out] info Pointer to store the asset's information
51 * \ref tfm_sst_asset_info_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +000052 *
53 * \return Returns error code as specified in \ref tfm_sst_err_t
54 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010055enum tfm_sst_err_t tfm_sst_get_info(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010056 const uint8_t* token,
57 uint32_t token_size,
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010058 struct tfm_sst_asset_info_t *info);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000059
60/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010061 * \brief Gets asset's attributes referenced by asset UUID.
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010062 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010063 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010064 * \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 Berengue4258e542018-06-18 13:55:59 +010072 * \param[out] attrs Pointer to store the asset's attributes
73 * \ref tfm_sst_asset_attrs_t
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010074 *
75 * \return Returns error code as specified in \ref tfm_sst_err_t
76 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010077enum tfm_sst_err_t tfm_sst_get_attributes(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010078 const uint8_t* token,
79 uint32_t token_size,
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010080 struct tfm_sst_asset_attrs_t *attrs);
81
82/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010083 * \brief Sets asset's attributes referenced by asset UUID.
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010084 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010085 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010086 * \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 Berengue4258e542018-06-18 13:55:59 +010094 * \param[in] attrs Pointer to new the asset's attributes
95 * \ref tfm_sst_asset_attrs_t
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010096 *
97 * \return Returns error code as specified in \ref tfm_sst_err_t
98 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010099enum tfm_sst_err_t tfm_sst_set_attributes(
100 uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100101 const uint8_t* token,
102 uint32_t token_size,
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100103 const struct tfm_sst_asset_attrs_t *attrs);
104
105/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100106 * \brief Reads asset's data from asset referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000107 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100108 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100109 * \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 Berengue4258e542018-06-18 13:55:59 +0100117 * \param[out] data Pointer to data vector \ref tfm_sst_buf_t to store
118 * data, size and offset
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000119 *
120 * \return Returns error code as specified in \ref tfm_sst_err_t
121 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100122enum tfm_sst_err_t tfm_sst_read(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100123 const uint8_t* token,
124 uint32_t token_size,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000125 struct tfm_sst_buf_t* data);
126
127/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100128 * \brief Writes data into an asset referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000129 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100130 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100131 * \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 Berengue4258e542018-06-18 13:55:59 +0100139 * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which
140 * contains the data to write
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000141 *
142 * \return Returns error code as specified in \ref tfm_sst_err_t
143 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100144enum tfm_sst_err_t tfm_sst_write(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100145 const uint8_t* token,
146 uint32_t token_size,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000147 struct tfm_sst_buf_t* data);
148
149/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100150 * \brief Deletes the asset referenced by the asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000151 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100152 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100153 * \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 Singhf4d88672017-11-29 13:35:43 +0000161 *
162 * \return Returns error code as specified in \ref tfm_sst_err_t
163 */
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100164enum tfm_sst_err_t tfm_sst_delete(uint32_t asset_uuid,
165 const uint8_t* token,
166 uint32_t token_size);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000167
168#ifdef __cplusplus
169}
170#endif
171
172#endif /* __TFM_SST_API__ */