A. Example header files¶
Each implementation of the Secure Storage API must provide a header file named psa/storage_common.h
, and also any of psa/internal_trusted_storage.h
and psa/protected_storage.h
for the APIs that are implemented.
This appendix provides examples of the header files with all of the API elements. This can be used as a starting point or reference for an implementation.
A.1. psa/storage_common.h¶
/* This file is a reference template for implementation of the * PSA Certified Secure Storage API v1.0.1 * * This file includes common definitions */ #ifndef PSA_STORAGE_COMMON_H #define PSA_STORAGE_COMMON_H #include <stddef.h> #include <stdint.h> #ifdef __cplusplus extern "C" { #endif struct psa_storage_info_t { size_t capacity; size_t size; psa_storage_create_flags_t flags; }; typedef uint32_t psa_storage_create_flags_t; typedef uint64_t psa_storage_uid_t; #define PSA_STORAGE_FLAG_NONE 0u #define PSA_STORAGE_FLAG_WRITE_ONCE (1u << 0) #define PSA_STORAGE_FLAG_NO_CONFIDENTIALITY (1u << 1) #define PSA_STORAGE_FLAG_NO_REPLAY_PROTECTION (1u << 2) #define PSA_STORAGE_SUPPORT_SET_EXTENDED (1u << 0) #ifdef __cplusplus } #endif #endif // PSA_STORAGE_COMMON_H
A.2. psa/internal_trusted_storage.h¶
/* This file is a reference template for implementation of the * PSA Certified Secure Storage API v1.0.1 * * This file describes the Internal Trusted Storage API */ #ifndef PSA_INTERNAL_TRUSTED_STORAGE_H #define PSA_INTERNAL_TRUSTED_STORAGE_H #include <stddef.h> #include <stdint.h> #include "psa/error.h" #include "psa/storage_common.h" #ifdef __cplusplus extern "C" { #endif #define PSA_ITS_API_VERSION_MAJOR 1 #define PSA_ITS_API_VERSION_MINOR 0 psa_status_t psa_its_set(psa_storage_uid_t uid, size_t data_length, const void * p_data, psa_storage_create_flags_t create_flags); psa_status_t psa_its_get(psa_storage_uid_t uid, size_t data_offset, size_t data_size, void * p_data, size_t * p_data_length); psa_status_t psa_its_get_info(psa_storage_uid_t uid, struct psa_storage_info_t * p_info); psa_status_t psa_its_remove(psa_storage_uid_t uid); #ifdef __cplusplus } #endif #endif // PSA_INTERNAL_TRUSTED_STORAGE_H
A.3. psa/protected_storage.h¶
/* This file is a reference template for implementation of the * PSA Certified Secure Storage API v1.0.1 * * This file describes the Protected Storage API */ #ifndef PSA_PROTECTED_STORAGE_H #define PSA_PROTECTED_STORAGE_H #include <stddef.h> #include <stdint.h> #include "psa/error.h" #include "psa/storage_common.h" #ifdef __cplusplus extern "C" { #endif #define PSA_PS_API_VERSION_MAJOR 1 #define PSA_PS_API_VERSION_MINOR 0 psa_status_t psa_ps_set(psa_storage_uid_t uid, size_t data_length, const void * p_data, psa_storage_create_flags_t create_flags); psa_status_t psa_ps_get(psa_storage_uid_t uid, size_t data_offset, size_t data_size, void * p_data, size_t * p_data_length); psa_status_t psa_ps_get_info(psa_storage_uid_t uid, struct psa_storage_info_t * p_info); psa_status_t psa_ps_remove(psa_storage_uid_t uid); psa_status_t psa_ps_create(psa_storage_uid_t uid, size_t capacity, psa_storage_create_flags_t create_flags); psa_status_t psa_ps_set_extended(psa_storage_uid_t uid, size_t data_offset, size_t data_length, const void * p_data); uint32_t psa_ps_get_support(void); #ifdef __cplusplus } #endif #endif // PSA_PROTECTED_STORAGE_H