blob: 4ad50d2cd6fadad091524380dc570b777671eeff [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
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +01008/**
9 * \file psa_sst_api.h
10 *
11 * \brief Platform security architecture (PSA) API for secure storage partition
12 */
13
14#ifndef __PSA_SST_API__
15#define __PSA_SST_API__
16
17#include "psa_sst_asset_defs.h"
18#include "psa_sst_asset_macros.h"
19
20#include "tfm_api.h"
Ashutosh Singhf4d88672017-11-29 13:35:43 +000021
22#ifdef __cplusplus
23extern "C" {
24#endif
25
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010026/*
27 * PSA SST API version
28 */
29#define PSA_SST_API_VERSION_MAJOR 0
30#define PSA_SST_API_VERSION_MINOR 1
31
32/* The return value is shared with the TF-M partition status value.
33 * The SST return codes shouldn't overlap with predefined TFM status values.
34 */
35#define PSA_SST_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
36
37/*!
38 * \enum psa_sst_err_t
39 *
40 * \brief Secure storage service error types
41 *
42 */
43enum psa_sst_err_t {
44 PSA_SST_ERR_SUCCESS = 0,
45 PSA_SST_ERR_ASSET_NOT_PREPARED = PSA_SST_ERR_OFFSET,
46 PSA_SST_ERR_ASSET_NOT_FOUND,
47 PSA_SST_ERR_PARAM_ERROR,
48 PSA_SST_ERR_STORAGE_SYSTEM_FULL,
49 PSA_SST_ERR_SYSTEM_ERROR,
50 /* Following entry is only to ensure the error code of int size */
51 PSA_SST_ERR_FORCE_INT_SIZE = INT_MAX
52};
Antonio de Angeliseba14e12018-03-27 11:03:20 +010053
Ashutosh Singhf4d88672017-11-29 13:35:43 +000054/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010055 * \brief Allocates space for the asset, referenced by asset UUID,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000056 * without setting any data in the asset.
57 *
58 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010059 * \param[in] token Must be set to NULL, reserved for future use.
60 * Pointer to the asset token to be used to generate
61 * the asset key to encrypt and decrypt the asset
62 * data. This is an optional parameter that has to
63 * be NULL in case the token is not provied.
64 * \param[in] token_size Must be set to 0, reserved for future use.
65 * Token size. In case the token is not provided
66 * the token size has to be 0.
Ashutosh Singhf4d88672017-11-29 13:35:43 +000067 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010068 * \return Returns an PSA_SST_ERR_SUCCESS if asset is created correctly.
69 * Otherwise, error code as specified in \ref psa_sst_err_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +000070 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010071enum psa_sst_err_t psa_sst_create(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010072 const uint8_t* token,
73 uint32_t token_size);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000074
75/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010076 * \brief Gets asset's information referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +000077 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010078 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010079 * \param[in] token Must be set to NULL, reserved for future use.
80 * Pointer to the asset token to be used to generate
81 * the asset key to encrypt and decrypt the asset
82 * data. This is an optional parameter that has to
83 * be NULL in case the token is not provied.
84 * \param[in] token_size Must be set to 0, reserved for future use.
85 * Token size. In case the token is not provided
86 * the token size has to be 0.
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010087 * \param[out] info Pointer to store the asset's information
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010088 * \ref psa_sst_asset_info_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +000089 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010090 * \return Returns error code as specified in \ref psa_sst_err_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +000091 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010092enum psa_sst_err_t psa_sst_get_info(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010093 const uint8_t* token,
94 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010095 struct psa_sst_asset_info_t *info);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000096
97/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010098 * \brief Gets asset's attributes referenced by asset UUID.
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010099 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100100 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100101 * \param[in] token Must be set to NULL, reserved for future use.
102 * Pointer to the asset token to be used to generate
103 * the asset key to encrypt and decrypt the asset
104 * data. This is an optional parameter that has to
105 * be NULL in case the token is not provied.
106 * \param[in] token_size Must be set to 0, reserved for future use.
107 * Token size. In case the token is not provided
108 * the token size has to be 0.
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100109 * \param[out] attrs Pointer to store the asset's attributes
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100110 * \ref psa_sst_asset_attrs_t
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100111 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100112 * \return Returns error code as specified in \ref psa_sst_err_t
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100113 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100114enum psa_sst_err_t psa_sst_get_attributes(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100115 const uint8_t* token,
116 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100117 struct psa_sst_asset_attrs_t *attrs);
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100118
119/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100120 * \brief Sets asset's attributes referenced by asset UUID.
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100121 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100122 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100123 * \param[in] token Must be set to NULL, reserved for future use.
124 * Pointer to the asset token to be used to generate
125 * the asset key to encrypt and decrypt the asset
126 * data. This is an optional parameter that has to
127 * be NULL in case the token is not provied.
128 * \param[in] token_size Must be set to 0, reserved for future use.
129 * Token size. In case the token is not provided
130 * the token size has to be 0.
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100131 * \param[in] attrs Pointer to new the asset's attributes
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100132 * \ref psa_sst_asset_attrs_t
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100133 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100134 * \return Returns error code as specified in \ref psa_sst_err_t
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100135 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100136enum psa_sst_err_t psa_sst_set_attributes(
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100137 uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100138 const uint8_t* token,
139 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100140 const struct psa_sst_asset_attrs_t *attrs);
Marc Moreno Berengue51af9512018-06-14 18:28:14 +0100141
142/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100143 * \brief Reads asset's data from asset referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000144 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100145 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100146 * \param[in] token Must be set to NULL, reserved for future use.
147 * Pointer to the asset token to be used to generate
148 * the asset key to encrypt and decrypt the asset
149 * data. This is an optional parameter that has to
150 * be NULL in case the token is not provied.
151 * \param[in] token_size Must be set to 0, reserved for future use.
152 * Token size. In case the token is not provided
153 * the token size has to be 0.
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100154 * \param[in] size Size of the data to read
155 * \param[in] offset Offset within asset to start to read
156 * \param[out] data Pointer to data vector to store data
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000157 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100158 * \return Returns error code as specified in \ref psa_sst_err_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000159 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100160enum psa_sst_err_t psa_sst_read(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100161 const uint8_t* token,
162 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100163 uint32_t size,
164 uint32_t offset,
165 uint8_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000166
167/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100168 * \brief Writes data into an asset referenced by asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000169 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100170 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100171 * \param[in] token Must be set to NULL, reserved for future use.
172 * Pointer to the asset token to be used to generate
173 * the asset key to encrypt and decrypt the asset
174 * data. This is an optional parameter that has to
175 * be NULL in case the token is not provied.
176 * \param[in] token_size Must be set to 0, reserved for future use.
177 * Token size. In case the token is not provided
178 * the token size has to be 0.
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100179 * \param[in] size Size of the data to start to write
180 * \param[in] offset Offset within asset to write the data
181 * \param[in] data Pointer to data vector which contains the data to
182 * write
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000183 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100184 * \return Returns error code as specified in \ref psa_sst_err_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000185 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100186enum psa_sst_err_t psa_sst_write(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100187 const uint8_t* token,
188 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100189 uint32_t size,
190 uint32_t offset,
191 const uint8_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000192
193/**
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100194 * \brief Deletes the asset referenced by the asset UUID.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000195 *
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100196 * \param[in] asset_uuid Asset UUID
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100197 * \param[in] token Must be set to NULL, reserved for future use.
198 * Pointer to the asset token to be used to generate
199 * the asset key to encrypt and decrypt the asset
200 * data. This is an optional parameter that has to
201 * be NULL in case the token is not provied.
202 * \param[in] token_size Must be set to 0, reserved for future use.
203 * Token size. In case the token is not provided
204 * the token size has to be 0.
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000205 *
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100206 * \return Returns error code as specified in \ref psa_sst_err_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000207 */
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100208enum psa_sst_err_t psa_sst_delete(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100209 const uint8_t* token,
210 uint32_t token_size);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000211
212#ifdef __cplusplus
213}
214#endif
215
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100216#endif /* __PSA_SST_API__ */