mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Add psa_trusted_storage_linux persistent storage support for v1.0.0 APIs
The following provides more information on this PR: - PSA stands for Platform Security Architecture. - Add support for use of psa_trusted_storage_api internal_trusted_storage.h v1.0.0 as the interface to the psa_trusted_storage_linux backend (i.e. for persistent storage when MBEDTLS_PSA_ITS_FILE_C is not defined). This requires changes to psa_crypto_its.h and psa_crypto_storage.c to migrate to the new API.
This commit is contained in:
committed by
Simon Hughes
parent
b6229e304e
commit
bda5a21112
@ -91,6 +91,7 @@ psa_status_t psa_its_set(psa_storage_uid_t uid,
|
||||
* \param[in] data_offset The starting offset of the data requested
|
||||
* \param[in] data_length the amount of data requested (and the minimum allocated size of the `p_data` buffer)
|
||||
* \param[out] p_data The buffer where the data will be placed upon successful completion
|
||||
* \param[out] p_data_length The amount of data returned in the p_data buffer
|
||||
*
|
||||
*
|
||||
* \return A status indicating the success/failure of the operation
|
||||
@ -106,7 +107,8 @@ psa_status_t psa_its_set(psa_storage_uid_t uid,
|
||||
psa_status_t psa_its_get(psa_storage_uid_t uid,
|
||||
uint32_t data_offset,
|
||||
uint32_t data_length,
|
||||
void *p_data);
|
||||
void *p_data,
|
||||
size_t *p_data_length );
|
||||
|
||||
/**
|
||||
* \brief Retrieve the metadata about the provided uid
|
||||
|
@ -96,12 +96,15 @@ static psa_status_t psa_crypto_storage_load( const psa_key_file_id_t key,
|
||||
psa_status_t status;
|
||||
psa_storage_uid_t data_identifier = psa_its_identifier_of_slot( key );
|
||||
struct psa_storage_info_t data_identifier_info;
|
||||
size_t data_length = 0;
|
||||
|
||||
status = psa_its_get_info( data_identifier, &data_identifier_info );
|
||||
if( status != PSA_SUCCESS )
|
||||
return( status );
|
||||
|
||||
status = psa_its_get( data_identifier, 0, (uint32_t) data_size, data );
|
||||
status = psa_its_get( data_identifier, 0, (uint32_t) data_size, data, &data_length );
|
||||
if( data_size != data_length )
|
||||
return( PSA_ERROR_STORAGE_FAILURE );
|
||||
|
||||
return( status );
|
||||
}
|
||||
|
@ -44,7 +44,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(PSA_ITS_STORAGE_PREFIX)
|
||||
#define PSA_ITS_STORAGE_PREFIX ""
|
||||
#endif
|
||||
|
||||
#define PSA_ITS_STORAGE_FILENAME_PATTERN "%08lx%08lx"
|
||||
#define PSA_ITS_STORAGE_SUFFIX ".psa_its"
|
||||
@ -137,7 +139,8 @@ psa_status_t psa_its_get_info( psa_storage_uid_t uid,
|
||||
psa_status_t psa_its_get( psa_storage_uid_t uid,
|
||||
uint32_t data_offset,
|
||||
uint32_t data_length,
|
||||
void *p_data )
|
||||
void *p_data,
|
||||
size_t *p_data_length )
|
||||
{
|
||||
psa_status_t status;
|
||||
FILE *stream = NULL;
|
||||
@ -172,6 +175,8 @@ psa_status_t psa_its_get( psa_storage_uid_t uid,
|
||||
if( n != data_length )
|
||||
goto exit;
|
||||
status = PSA_SUCCESS;
|
||||
if( p_data_length != NULL )
|
||||
*p_data_length = n;
|
||||
|
||||
exit:
|
||||
if( stream != NULL )
|
||||
|
Reference in New Issue
Block a user