pull/9529/head
Oren Cohen 2019-01-24 12:06:58 +02:00
parent 34895a05ad
commit 642fce5022
7 changed files with 208 additions and 88 deletions

View File

@ -27,10 +27,10 @@
// So here we set a global pid value to be used for when calling IMPL functions
#define PSA_ITS_EMUL_PID 1
psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
psa_its_status_t psa_its_set(psa_its_uid_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
{
if (!p_data && data_length) {
return PSA_ITS_ERROR_BAD_POINTER;
return PSA_ITS_ERROR_IVALID_ARGUMENTS;
}
// KVStore initiation:
@ -46,10 +46,10 @@ psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_d
return res;
}
psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
psa_its_status_t psa_its_get(psa_its_uid_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
{
if (!p_data && data_length) {
return PSA_ITS_ERROR_BAD_POINTER;
return PSA_ITS_ERROR_IVALID_ARGUMENTS;
}
// KVStore initiation:
@ -63,10 +63,10 @@ psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_l
return psa_its_get_impl(PSA_ITS_EMUL_PID, uid, data_offset, data_length, p_data);
}
psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info)
psa_its_status_t psa_its_get_info(psa_its_uid_t uid, struct psa_its_info_t *p_info)
{
if (!p_info) {
return PSA_ITS_ERROR_BAD_POINTER;
return PSA_ITS_ERROR_IVALID_ARGUMENTS;
}
// KVStore initiation:
@ -80,7 +80,7 @@ psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info)
return psa_its_get_info_impl(PSA_ITS_EMUL_PID, uid, p_info);
}
psa_its_status_t psa_its_remove(uint32_t uid)
psa_its_status_t psa_its_remove(psa_its_uid_t uid)
{
// KVStore initiation:
// - In EMUL (non-secure single core) we do it here since we don't have another context to do it inside.

View File

@ -21,21 +21,20 @@
#include "TDBStore.h"
#include "psa_prot_internal_storage.h"
#include "pits_impl.h"
#include "pits_version_impl.h"
#include "mbed_error.h"
#include "mbed_toolchain.h"
using namespace mbed;
#ifdef __cplusplus
extern "C"
{
#endif
using namespace mbed;
#define STR_EXPAND(tok) #tok
// Maximum length of filename we use for kvstore API.
// uid: 6; delimiter: 1; pid: 6; str terminator: 1
#define PSA_ITS_FILENAME_MAX_LEN 14
// pid: 6; delimiter: 1; uid: 11; str terminator: 1
#define PSA_ITS_FILENAME_MAX_LEN 19
const uint8_t base64_coding_table[] = {
@ -49,22 +48,74 @@ const uint8_t base64_coding_table[] = {
'4', '5', '6', '7', '8', '9', '+', '-'
};
/*
* \brief Get default KVStore instance for internal flesh storage
*
* \return valid pointer to KVStore
*/
static KVStore *get_kvstore_instance(void)
static KVStore *kvstore = NULL;
static void its_init(void)
{
KVMap &kv_map = KVMap::get_instance();
KVStore *kvstore = kv_map.get_internal_kv_instance(STR_EXPAND(MBED_CONF_STORAGE_DEFAULT_KV));
kvstore = kv_map.get_internal_kv_instance(STR_EXPAND(MBED_CONF_STORAGE_DEFAULT_KV));
if (!kvstore) {
// Can only happen due to system misconfiguration.
// Thus considered as unrecoverable error for runtime.
error("Failed getting kvstore instance\n");
}
return kvstore;
its_version_t version = { 0, 0 };
size_t actual_size = 0;
KVStore::info_t kv_info;
bool write_version = false;
int status = kvstore->get_info(ITS_VERSION_KEY, &kv_info);
if (status != MBED_SUCCESS) {
version.major = PSA_ITS_API_VERSION_MAJOR;
version.minor = PSA_ITS_API_VERSION_MINOR;
write_version = true;
} else {
if (kv_info.size != sizeof(version)) {
error("ITS version data is corrupt");
}
status = kvstore->get(ITS_VERSION_KEY, &version, sizeof(version), &actual_size, 0);
if ((status != MBED_SUCCESS) ||
((status == MBED_SUCCESS) && (actual_size != sizeof(version)))) {
error("Could not read ITS version data");
}
}
if ((version.major > PSA_ITS_API_VERSION_MAJOR) ||
((version.major == PSA_ITS_API_VERSION_MAJOR) && (version.minor > PSA_ITS_API_VERSION_MINOR))) {
error("Downgrading ITS version is not allowed");
}
if ((version.major < PSA_ITS_API_VERSION_MAJOR) ||
((version.major == PSA_ITS_API_VERSION_MAJOR) && (version.minor < PSA_ITS_API_VERSION_MINOR))) {
psa_its_status_t migration_status = its_version_migrate(kvstore, &version);
if (migration_status != PSA_ITS_SUCCESS) {
error("ITS migration failed");
}
version.major = PSA_ITS_API_VERSION_MAJOR;
version.minor = PSA_ITS_API_VERSION_MINOR;
write_version = true;
}
if (write_version) {
if (kvstore->set(ITS_VERSION_KEY, &version, sizeof(version), 0) != MBED_SUCCESS) {
error("Could not write PSA ITS version");
}
}
}
// used from test only
void its_deinit(void)
{
kvstore = NULL;
}
MBED_WEAK psa_its_status_t its_version_migrate(void *storage, const its_version_t *version)
{
(void)storage;
(void)version;
return PSA_ITS_SUCCESS;
}
/*
@ -83,7 +134,7 @@ static psa_its_status_t convert_status(int status)
case MBED_ERROR_MEDIA_FULL:
return PSA_ITS_ERROR_INSUFFICIENT_SPACE;
case MBED_ERROR_ITEM_NOT_FOUND:
return PSA_ITS_ERROR_KEY_NOT_FOUND;
return PSA_ITS_ERROR_UID_NOT_FOUND;
default:
return PSA_ITS_ERROR_STORAGE_FAILURE;
}
@ -97,7 +148,20 @@ static psa_its_status_t convert_status(int status)
* \param n[in] number of bits to shift right
* \return the result
*/
MBED_FORCEINLINE uint32_t lsr(uint32_t x, uint32_t n)
MBED_FORCEINLINE uint32_t lsr32(uint32_t x, uint32_t n)
{
return x >> n;
}
/*
* \brief Logic shift right
*
* \note must operate on unsinged integers to prevent negative carry
* \param x[in] input number for shifting
* \param n[in] number of bits to shift right
* \return the result
*/
MBED_FORCEINLINE uint64_t lsr64(uint64_t x, uint32_t n)
{
return x >> n;
}
@ -113,7 +177,7 @@ MBED_FORCEINLINE uint32_t lsr(uint32_t x, uint32_t n)
* \param[in] uid - PSA internal storage unique ID
* \param[in] pid - owner PSA partition ID
*/
static void generate_fn(char *tdb_filename, uint32_t tdb_filename_size, uint32_t uid, int32_t pid)
static void generate_fn(char *tdb_filename, uint32_t tdb_filename_size, psa_its_uid_t uid, int32_t pid)
{
MBED_ASSERT(tdb_filename != NULL);
MBED_ASSERT(tdb_filename_size == PSA_ITS_FILENAME_MAX_LEN);
@ -124,7 +188,7 @@ static void generate_fn(char *tdb_filename, uint32_t tdb_filename_size, uint32_t
// Iterate on PID; each time convert 6 bits of PID into a character; first iteration must be done
do {
tdb_filename[filename_idx++] = base64_coding_table[unsigned_pid & 0x3F];
unsigned_pid = lsr(unsigned_pid, 6);
unsigned_pid = lsr32(unsigned_pid, 6);
} while (unsigned_pid != 0);
// Write delimiter
@ -133,19 +197,20 @@ static void generate_fn(char *tdb_filename, uint32_t tdb_filename_size, uint32_t
// Iterate on UID; each time convert 6 bits of UID into a character; first iteration must be done
do {
tdb_filename[filename_idx++] = base64_coding_table[uid & 0x3F];
uid = lsr(uid, 6);
uid = lsr64(uid, 6);
} while (uid != 0);
tdb_filename[filename_idx++] = '\0';
MBED_ASSERT(filename_idx <= PSA_ITS_FILENAME_MAX_LEN);
}
psa_its_status_t psa_its_set_impl(int32_t pid, uint32_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
psa_its_status_t psa_its_set_impl(int32_t pid, psa_its_uid_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
{
KVStore *kvstore = get_kvstore_instance();
MBED_ASSERT(kvstore);
if (!kvstore) {
its_init();
}
if ((create_flags != 0) && (create_flags != PSA_ITS_WRITE_ONCE_FLAG)) {
if ((create_flags & (~PSA_ITS_FLAGS_BIT_MASK)) != 0) {
return PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED;
}
@ -154,7 +219,7 @@ psa_its_status_t psa_its_set_impl(int32_t pid, uint32_t uid, uint32_t data_lengt
generate_fn(kv_key, PSA_ITS_FILENAME_MAX_LEN, uid, pid);
uint32_t kv_create_flags = 0;
if (create_flags & PSA_ITS_WRITE_ONCE_FLAG) {
if (create_flags & PSA_ITS_FLAG_WRITE_ONCE) {
kv_create_flags = KVStore::WRITE_ONCE_FLAG;
}
@ -163,10 +228,11 @@ psa_its_status_t psa_its_set_impl(int32_t pid, uint32_t uid, uint32_t data_lengt
return convert_status(status);
}
psa_its_status_t psa_its_get_impl(int32_t pid, uint32_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
psa_its_status_t psa_its_get_impl(int32_t pid, psa_its_uid_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
{
KVStore *kvstore = get_kvstore_instance();
MBED_ASSERT(kvstore);
if (!kvstore) {
its_init();
}
// Generate KVStore key
char kv_key[PSA_ITS_FILENAME_MAX_LEN] = {'\0'};
@ -177,7 +243,7 @@ psa_its_status_t psa_its_get_impl(int32_t pid, uint32_t uid, uint32_t data_offse
if (status == MBED_SUCCESS) {
if (data_offset > kv_info.size) {
return PSA_ITS_ERROR_OFFSET_INVALID;
return PSA_PS_ERROR_OFFSET_INVALID;
}
// Verify (size + offset) does not wrap around
@ -202,10 +268,11 @@ psa_its_status_t psa_its_get_impl(int32_t pid, uint32_t uid, uint32_t data_offse
return convert_status(status);
}
psa_its_status_t psa_its_get_info_impl(int32_t pid, uint32_t uid, struct psa_its_info_t *p_info)
psa_its_status_t psa_its_get_info_impl(int32_t pid, psa_its_uid_t uid, struct psa_its_info_t *p_info)
{
KVStore *kvstore = get_kvstore_instance();
MBED_ASSERT(kvstore);
if (!kvstore) {
its_init();
}
// Generate KVStore key
char kv_key[PSA_ITS_FILENAME_MAX_LEN] = {'\0'};
@ -217,7 +284,7 @@ psa_its_status_t psa_its_get_info_impl(int32_t pid, uint32_t uid, struct psa_its
if (status == MBED_SUCCESS) {
p_info->flags = 0;
if (kv_info.flags & KVStore::WRITE_ONCE_FLAG) {
p_info->flags |= PSA_ITS_WRITE_ONCE_FLAG;
p_info->flags |= PSA_ITS_FLAG_WRITE_ONCE;
}
p_info->size = (uint32_t)(kv_info.size); // kv_info.size is of type size_t
}
@ -225,10 +292,11 @@ psa_its_status_t psa_its_get_info_impl(int32_t pid, uint32_t uid, struct psa_its
return convert_status(status);
}
psa_its_status_t psa_its_remove_impl(int32_t pid, uint32_t uid)
psa_its_status_t psa_its_remove_impl(int32_t pid, psa_its_uid_t uid)
{
KVStore *kvstore = get_kvstore_instance();
MBED_ASSERT(kvstore);
if (!kvstore) {
its_init();
}
// Generate KVStore key
char kv_key[PSA_ITS_FILENAME_MAX_LEN] = {'\0'};

View File

@ -25,13 +25,14 @@ extern "C"
{
#endif
#define PITS_DATA_PTR_AT_OFFSET(ptr, offset) ((void *)(((uintptr_t)ptr) + ((uintptr_t)offset)))
#define STR_EXPAND(tok) #tok
#define PSA_ITS_FLAGS_BIT_MASK (PSA_ITS_FLAG_NONE | PSA_ITS_FLAG_WRITE_ONCE)
psa_its_status_t psa_its_set_impl(int32_t pid, uint32_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags);
psa_its_status_t psa_its_get_impl(int32_t pid, uint32_t uid, uint32_t data_offset, uint32_t data_length, void *p_data);
psa_its_status_t psa_its_get_info_impl(int32_t pid, uint32_t uid, struct psa_its_info_t *p_info);
psa_its_status_t psa_its_remove_impl(int32_t pid, uint32_t uid);
psa_its_status_t psa_its_set_impl(int32_t pid, psa_its_uid_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags);
psa_its_status_t psa_its_get_impl(int32_t pid, psa_its_uid_t uid, uint32_t data_offset, uint32_t data_length, void *p_data);
psa_its_status_t psa_its_get_info_impl(int32_t pid, psa_its_uid_t uid, struct psa_its_info_t *p_info);
psa_its_status_t psa_its_remove_impl(int32_t pid, psa_its_uid_t uid);
#ifdef __cplusplus
}

View File

@ -0,0 +1,41 @@
/* Copyright (c) 2018 ARM Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PITS_VER_IMPL_H__
#define __PITS_VER_IMPL_H__
#include "psa_prot_internal_storage.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define ITS_VERSION_KEY "PSA_ITS_VERSION" // ITS version entry identifier in TDBStore
typedef struct its_version {
uint32_t major;
uint32_t minor;
} its_version_t;
psa_its_status_t its_version_migrate(void *storage, const its_version_t *version);
#ifdef __cplusplus
}
#endif
#endif // __PITS_VER_IMPL_H__

View File

@ -19,10 +19,10 @@
#include "psa_prot_internal_storage.h"
#include "psa_its_ifs.h"
psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
psa_its_status_t psa_its_set(psa_its_uid_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
{
if (!p_data && data_length) {
return PSA_ITS_ERROR_BAD_POINTER;
return PSA_ITS_ERROR_IVALID_ARGUMENTS;
}
psa_invec msg[3] = {
@ -45,10 +45,10 @@ psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_d
return status;
}
psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
psa_its_status_t psa_its_get(psa_its_uid_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
{
if (!p_data && data_length) {
return PSA_ITS_ERROR_BAD_POINTER;
return PSA_ITS_ERROR_IVALID_ARGUMENTS;
}
psa_invec msg[2] = {
@ -72,13 +72,13 @@ psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_l
return status;
}
psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info)
psa_its_status_t psa_its_get_info(psa_its_uid_t uid, struct psa_its_info_t *p_info)
{
if (!p_info) {
return PSA_ITS_ERROR_BAD_POINTER;
return PSA_ITS_ERROR_IVALID_ARGUMENTS;
}
struct psa_its_info_t info = { 0 };
struct psa_its_info_t info = { 0, PSA_ITS_FLAG_NONE };
psa_invec msg = { &uid, sizeof(uid) };
psa_outvec resp = { &info, sizeof(info) };
psa_handle_t conn = psa_connect(PSA_ITS_INFO, 1);
@ -98,7 +98,7 @@ psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info)
return status;
}
psa_its_status_t psa_its_remove(uint32_t uid)
psa_its_status_t psa_its_remove(psa_its_uid_t uid)
{
psa_invec msg = { &uid, sizeof(uid) };
psa_handle_t conn = psa_connect(PSA_ITS_REMOVE, 1);

View File

@ -33,7 +33,7 @@ typedef psa_status_t (*SignalHandler)(psa_msg_t *);
static psa_status_t storage_set(psa_msg_t *msg)
{
uint32_t key = 0;
psa_its_uid_t key = 0;
void *data = NULL;
uint32_t alloc_size = msg->in_size[1];
psa_its_create_flags_t flags = 0;
@ -69,7 +69,7 @@ static psa_status_t storage_set(psa_msg_t *msg)
static psa_status_t storage_get(psa_msg_t *msg)
{
uint32_t key = 0;
psa_its_uid_t key = 0;
uint32_t offset = 0;
if ((msg->in_size[0] != sizeof(key)) || (msg->in_size[1] != sizeof(offset))) {
@ -102,7 +102,7 @@ static psa_status_t storage_get(psa_msg_t *msg)
static psa_status_t storage_info(psa_msg_t *msg)
{
struct psa_its_info_t info = { 0 };
uint32_t key = 0;
psa_its_uid_t key = 0;
if ((msg->in_size[0] != sizeof(key)) || (msg->out_size[0] != sizeof(info))) {
return PSA_DROP_CONNECTION;
@ -122,7 +122,7 @@ static psa_status_t storage_info(psa_msg_t *msg)
static psa_status_t storage_remove(psa_msg_t *msg)
{
uint32_t key = 0;
psa_its_uid_t key = 0;
if (msg->in_size[0] != sizeof(key)) {
return PSA_DROP_CONNECTION;

View File

@ -25,16 +25,22 @@
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#ifdef __cplusplus
extern "C" {
#endif
#define PSA_ITS_API_VERSION_MAJOR 1 /**< The major version number of the PSA ITS API. It will be incremented on significant updates that may include breaking changes */
#define PSA_ITS_API_VERSION_MINOR 0 /**< The minor version number of the PSA ITS API. It will be incremented in small updates that are unlikely to include breaking changes */
/** \brief Flags used when creating a key
*/
typedef uint32_t psa_its_create_flags_t;
#define PSA_ITS_WRITE_ONCE_FLAG (1 << 0) /**< The data associated with the key will not be able to be modified or deleted. Intended to be used to set bits in `psa_its_create_flags_t` */
/** \brief A type for UIDs used for identifying data
*/
typedef uint64_t psa_its_uid_t;
#define PSA_ITS_FLAG_NONE 0 /**< No flags to pass */
#define PSA_ITS_FLAG_WRITE_ONCE ( 1 << 0 ) /**< The data associated with the key will not be able to be modified or deleted. Intended to be used to set bits in `psa_its_create_flags_t` */
/**
* \brief A container for metadata associated with a specific key
@ -52,13 +58,11 @@ typedef uint32_t psa_its_status_t;
#define PSA_ITS_ERROR_WRITE_ONCE 1 /**< The operation failed because the provided key value was already created with PSA_ITS_WRITE_ONCE_FLAG */
#define PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED 2 /**< The operation failed because one or more of the flags provided in `create_flags` is not supported or is not valid */
#define PSA_ITS_ERROR_INSUFFICIENT_SPACE 3 /**< The operation failed because there was insufficient space on the storage medium */
#define PSA_ITS_ERROR_INVALID_KEY 4 /**< The operation failed because the key value provided was invalid */
#define PSA_ITS_ERROR_STORAGE_FAILURE 5 /**< The operation failed because the physical storage has failed (Fatal error) */
#define PSA_ITS_ERROR_BAD_POINTER 6 /**< The operation failed because one of the provided pointers is invalid, for example is `NULL` or references memory the caller cannot access */
#define PSA_ITS_ERROR_KEY_NOT_FOUND 7 /**< The operation failed because the provided key value was not found in the storage */
#define PSA_ITS_ERROR_INCORRECT_SIZE 8 /**< The operation failed because the data associated with provided key is not the same size as `data_size` */
#define PSA_ITS_ERROR_OFFSET_INVALID 9 /**< The operation failed because an offset was supplied that is invalid for the existing data associated with the uid. For example, offset + size is
past the end of the data */
#define PSA_ITS_ERROR_STORAGE_FAILURE 4 /**< The operation failed because the physical storage has failed (Fatal error) */
#define PSA_ITS_ERROR_IVALID_ARGUMENTS 5 /**< The operation failed because one of the provided pointers is invalid, for example is `NULL` or references memory the caller cannot access */
#define PSA_ITS_ERROR_UID_NOT_FOUND 6 /**< The operation failed because the provided key value was not found in the storage */
#define PSA_ITS_ERROR_INCORRECT_SIZE 7 /**< The operation failed because the data associated with provided key is not the same size as `data_size`, or `offset+data_size` is too large for the data, but `offset` is less than the size */
#define PSA_PS_ERROR_OFFSET_INVALID 8 /**< The operation failed because an offset was supplied that is invalid for the existing data associated with the uid. For example, offset is greater that the size of the data */
/**
* \brief create a new or modify an existing uid/value pair
@ -74,12 +78,14 @@ typedef uint32_t psa_its_status_t;
* \retval PSA_ITS_ERROR_WRITE_ONCE The operation failed because the provided `uid` value was already created with PSA_ITS_WRITE_ONCE_FLAG
* \retval PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED The operation failed because one or more of the flags provided in `create_flags` is not supported or is not valid
* \retval PSA_ITS_ERROR_INSUFFICIENT_SPACE The operation failed because there was insufficient space on the storage medium
* \retval PSA_ITS_ERROR_INVALID_KEY The operation failed because the value provided in `uid` was invalid
* \retval PSA_ITS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
* \retval PSA_ITS_ERROR_BAD_POINTER The operation failed because one of the provided pointers(`p_data`)
* is invalid, for example is `NULL` or references memory the caller cannot access
* \retval PSA_ITS_ERROR_INVALID_ARGUMENTS The operation failed because one of the provided pointers(`p_data`)
* is invalid, for example is `NULL` or references memory the caller cannot access
*/
psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags);
psa_its_status_t psa_its_set(psa_its_uid_t uid,
uint32_t data_length,
const void *p_data,
psa_its_create_flags_t create_flags);
/**
* \brief Retrieve the value associated with a provided uid
@ -93,15 +99,18 @@ psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_d
* \return A status indicating the success/failure of the operation
*
* \retval PSA_ITS_SUCCESS The operation completed successfully
* \retval PSA_ITS_ERROR_KEY_NOT_FOUND The operation failed because the provided `uid` value was not found in the storage
* \retval PSA_ITS_ERROR_UID_NOT_FOUND The operation failed because the provided `uid` value was not found in the storage
* \retval PSA_ITS_ERROR_INCORRECT_SIZE The operation failed because the data associated with provided `uid` is not the same size as `data_size`
* \retval PSA_ITS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
* \retval PSA_ITS_ERROR_BAD_POINTER The operation failed because one of the provided pointers(`p_data`, `p_data_length`)
* \retval PSA_ITS_ERROR_INVALID_ARGUMENTS The operation failed because one of the provided pointers(`p_data`, `p_data_length`)
* is invalid. For example is `NULL` or references memory the caller cannot access
* \retval PSA_ITS_ERROR_OFFSET_INVALID The operation failed because an offset was supplied that is invalid for the existing data associated with the
* uid. For example, offset + size is invalid,
* \retval PSA_PS_ERROR_OFFSET_INVALID The operation failed because an offset was supplied that is invalid for the existing data associated with the
* uid. For example, offset + size is invalid
*/
psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_length, void *p_data);
psa_its_status_t psa_its_get(psa_its_uid_t uid,
uint32_t data_offset,
uint32_t data_length,
void *p_data);
/**
* \brief Retrieve the metadata about the provided uid
@ -111,13 +120,14 @@ psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_
*
* \return A status indicating the success/failure of the operation
*
* \retval PSA_ITS_ERROR_SUCCESS The operation completed successfully
* \retval PSA_ITS_ERROR_KEY_NOT_FOUND The operation failed because the provided uid value was not found in the storage
* \retval PSA_ITS_SUCCESS The operation completed successfully
* \retval PSA_ITS_ERROR_UID_NOT_FOUND The operation failed because the provided uid value was not found in the storage
* \retval PSA_ITS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
* \retval PSA_ITS_ERROR_BAD_POINTER The operation failed because one of the provided pointers(`p_info`)
* is invalid, for example is `NULL` or references memory the caller cannot access
* \retval PSA_ITS_ERROR_INVALID_ARGUMENTS The operation failed because one of the provided pointers(`p_info`)
* is invalid, for example is `NULL` or references memory the caller cannot access
*/
psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info);
psa_its_status_t psa_its_get_info(psa_its_uid_t uid,
struct psa_its_info_t *p_info);
/**
* \brief Remove the provided key and its associated data from the storage
@ -127,13 +137,13 @@ psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info);
* \return A status indicating the success/failure of the operation
*
* \retval PSA_ITS_SUCCESS The operation completed successfully
* \retval PSA_ITS_ERROR_KEY_NOT_FOUND The operation failed because the provided key value was not found in the storage
* \retval PSA_ITS_ERROR_UID_NOT_FOUND The operation failed because the provided key value was not found in the storage
* \retval PSA_ITS_ERROR_WRITE_ONCE The operation failed because the provided key value was created with psa_its_WRITE_ONCE_FLAG
* \retval PSA_ITS_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
*/
psa_its_status_t psa_its_remove(uint32_t uid);
psa_its_status_t psa_its_remove(psa_its_uid_t uid);
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif