blob: 6ffd25b2b8bacdddbb1c2cfb8d49923aeedc75c5 [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 Berengue79032942018-06-26 15:34:05 +0100117 * \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 Singhf4d88672017-11-29 13:35:43 +0000120 *
121 * \return Returns error code as specified in \ref tfm_sst_err_t
122 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100123enum tfm_sst_err_t tfm_sst_read(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100124 const uint8_t* token,
125 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100126 uint32_t size,
127 uint32_t offset,
128 uint8_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000129
130/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100131 * \brief Writes data into an asset referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000132 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100133 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100134 * \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 Berengue79032942018-06-26 15:34:05 +0100142 * \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 Singhf4d88672017-11-29 13:35:43 +0000146 *
147 * \return Returns error code as specified in \ref tfm_sst_err_t
148 */
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100149enum tfm_sst_err_t tfm_sst_write(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100150 const uint8_t* token,
151 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100152 uint32_t size,
153 uint32_t offset,
154 const uint8_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000155
156/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100157 * \brief Deletes the asset referenced by the asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000158 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100159 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100160 * \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 Singhf4d88672017-11-29 13:35:43 +0000168 *
169 * \return Returns error code as specified in \ref tfm_sst_err_t
170 */
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100171enum tfm_sst_err_t tfm_sst_delete(uint32_t asset_uuid,
172 const uint8_t* token,
173 uint32_t token_size);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000174
175#ifdef __cplusplus
176}
177#endif
178
179#endif /* __TFM_SST_API__ */