blob: f27c53f9e5e04277dd9f76988618dcfb19a7e1e1 [file] [log] [blame]
Jamie Foxefb8b372018-12-14 14:52:15 +00001/*
Jamie Fox8a1c7ed2019-06-13 15:04:46 +01002 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
Jamie Foxefb8b372018-12-14 14:52:15 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Jamie Fox8a1c7ed2019-06-13 15:04:46 +01008/* This file describes the PSA Protected Storage API */
Jamie Foxefb8b372018-12-14 14:52:15 +00009
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010010#ifndef PSA_PROTECTED_STORAGE_H
11#define PSA_PROTECTED_STORAGE_H
Jamie Foxefb8b372018-12-14 14:52:15 +000012
13#include <stddef.h>
14#include <stdint.h>
15
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010016#include "psa/error.h"
17#include "psa/storage_common.h"
18
Jamie Foxefb8b372018-12-14 14:52:15 +000019#ifdef __cplusplus
20extern "C" {
21#endif
22
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010023#define PSA_PS_API_VERSION_MAJOR 1
24#define PSA_PS_API_VERSION_MINOR 0
Jamie Foxefb8b372018-12-14 14:52:15 +000025
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010026// This version of the header file is associated with 1.0 final release.
Jamie Foxefb8b372018-12-14 14:52:15 +000027
28/**
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010029 * Create a new or modify an existing key/value pair
30 *
Jamie Foxefb8b372018-12-14 14:52:15 +000031 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010032psa_status_t psa_ps_set(psa_storage_uid_t uid,
33 size_t data_length,
34 const void *p_data,
35 psa_storage_create_flags_t create_flags);
Jamie Foxefb8b372018-12-14 14:52:15 +000036
37/**
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010038 * Retrieve data associated with a provided UID
Jamie Foxefb8b372018-12-14 14:52:15 +000039 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010040psa_status_t psa_ps_get(psa_storage_uid_t uid,
41 size_t data_offset,
42 size_t data_size,
43 void *p_data,
44 size_t *p_data_length);
Jamie Foxefb8b372018-12-14 14:52:15 +000045
46/**
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010047 * Retrieve the metadata about the provided uid
Jamie Foxefb8b372018-12-14 14:52:15 +000048 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010049psa_status_t psa_ps_get_info(psa_storage_uid_t uid,
50 struct psa_storage_info_t *p_info);
Jamie Foxefb8b372018-12-14 14:52:15 +000051
52/**
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010053 * Remove the provided uid and its associated data from the storage
Jamie Foxefb8b372018-12-14 14:52:15 +000054 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010055psa_status_t psa_ps_remove(psa_storage_uid_t uid);
Jamie Foxefb8b372018-12-14 14:52:15 +000056
57/**
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010058 * Reserves storage for the specified UID.
Jamie Foxefb8b372018-12-14 14:52:15 +000059 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010060psa_status_t psa_ps_create(psa_storage_uid_t uid,
61 size_t capacity,
62 psa_storage_create_flags_t create_flags);
Jamie Foxefb8b372018-12-14 14:52:15 +000063
64/**
65 * Sets partial data into an asset based on the given identifier, data_offset,
66 * data length and p_data.
Jamie Foxefb8b372018-12-14 14:52:15 +000067 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010068psa_status_t psa_ps_set_extended(psa_storage_uid_t uid,
69 size_t data_offset,
70 size_t data_length,
71 const void *p_data);
Jamie Foxefb8b372018-12-14 14:52:15 +000072
73/**
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010074 * Returns a bitmask with flags set for all of the optional features supported
Jamie Foxefb8b372018-12-14 14:52:15 +000075 * by the implementation.
76 *
Jamie Foxefb8b372018-12-14 14:52:15 +000077 */
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010078uint32_t psa_ps_get_support(void);
Jamie Foxefb8b372018-12-14 14:52:15 +000079
80#ifdef __cplusplus
81}
82#endif
83
Jamie Fox8a1c7ed2019-06-13 15:04:46 +010084#endif // PSA_PROTECTED_STORAGE_H