Wirepas SDK
app_secure_storage.h File Reference

Detailed Description

The secure storage library provides the APIs for protecting the content of application persistent data on internal or external flash. The content of the persistent memory area is encrypted and authenticated with secret device specific security keys.

The application should use the APIs to store or retrieve the application specific sensitive data. The same APIs can also be used to store and retrieve the non-sensitive data, then it won't be encrypted and authenticated but stored as plain text.

Definition in file app_secure_storage.h.

Go to the source code of this file.

Functions

app_secure_storage_res_e App_SecureStorage_init (uint32_t area_id)
 Initialize secure storage area. More...
 
app_secure_storage_res_e App_SecureStorage_erase (uint32_t area_id)
 Erase secure storage area. More...
 
app_secure_storage_res_e App_SecureStorage_check (uint32_t area_id)
 Check if secure storage area exists. More...
 
app_secure_storage_res_e App_SecureStorage_read (uint32_t area_id, uint32_t tag, uint8_t *data, size_t *max_amount)
 Read data from the secure storage area. More...
 
app_secure_storage_res_e App_SecureStorage_write (uint32_t area_id, uint32_t tag, const uint8_t *data, size_t len, app_secure_storage_flags_e flags)
 Write data to the secure storage area. More...
 
app_secure_storage_res_e App_SecureStorage_delete (uint32_t area_id, uint32_t tag)
 Delete data from the secure storage area. More...
 

Enumerations

enum  app_secure_storage_res_e {
  APP_SECURE_STORAGE_RES_OK = 0, APP_SECURE_STORAGE_RES_ERROR = 1, APP_SECURE_STORAGE_RES_BUSY = 2, APP_SECURE_STORAGE_RES_NODRIVER = 3,
  APP_SECURE_STORAGE_RES_PARAM = 4, APP_SECURE_STORAGE_RES_INVALID_AREA = 5, APP_SECURE_STORAGE_RES_INVALID_TAG = 6
}
 List of return code. More...
 
enum  app_secure_storage_flags_e { APP_SECURE_STORAGE_NO_ENCRYPT = (1 << 0), APP_SECURE_STORAGE_NO_AUTH = (1 << 1) }
 Secure storage option flags. More...
 

Function Documentation

◆ App_SecureStorage_check()

app_secure_storage_res_e App_SecureStorage_check ( uint32_t  area_id)

Check if secure storage area exists.

Parameters
area_idID of the memory area to check.
Returns
Return code of the operation

◆ App_SecureStorage_delete()

app_secure_storage_res_e App_SecureStorage_delete ( uint32_t  area_id,
uint32_t  tag 
)

Delete data from the secure storage area.

Parameters
area_idID of the secure storage memory area to write
tagID of the data to delete.
Returns
Return code of the operation

◆ App_SecureStorage_erase()

app_secure_storage_res_e App_SecureStorage_erase ( uint32_t  area_id)

Erase secure storage area.

Parameters
area_idID of the memory area to erase.
Returns
Return code of the operation

◆ App_SecureStorage_init()

app_secure_storage_res_e App_SecureStorage_init ( uint32_t  area_id)

Initialize secure storage area.

Parameters
area_idID of the memory area to initialize as secure storage area.
Returns
Return code of the operation
Note
The secure storage area must be initialized with this function before calling any other secure storage functions.

◆ App_SecureStorage_read()

app_secure_storage_res_e App_SecureStorage_read ( uint32_t  area_id,
uint32_t  tag,
uint8_t *  data,
size_t *  max_amount 
)

Read data from the secure storage area.

Parameters
area_idID of the secure storage memory area to write
tagID of the data to read.
dataPointer to store read data
max_amountNumber of bytes of space available for reading, actual number of bytes read returned
Returns
Return code of the operation

◆ App_SecureStorage_write()

app_secure_storage_res_e App_SecureStorage_write ( uint32_t  area_id,
uint32_t  tag,
const uint8_t *  data,
size_t  len,
app_secure_storage_flags_e  flags 
)

Write data to the secure storage area.

Parameters
area_idID of the secure storage memory area to write
tagID of the data to write.
dataPointer to the data to write
lenLength of data to write
Returns
Return code of the operation

Enumeration Type Documentation

◆ app_secure_storage_flags_e

Secure storage option flags.

Enumerator
APP_SECURE_STORAGE_NO_ENCRYPT 

Do not encrypt data

APP_SECURE_STORAGE_NO_AUTH 

Do not authenticate data

Definition at line 51 of file app_secure_storage.h.

◆ app_secure_storage_res_e

List of return code.

Enumerator
APP_SECURE_STORAGE_RES_OK 

Operation is successful

APP_SECURE_STORAGE_RES_ERROR 

Error during operation

APP_SECURE_STORAGE_RES_BUSY 

Underneath storage driver is busy

APP_SECURE_STORAGE_RES_NODRIVER 

The storage driver is missing

APP_SECURE_STORAGE_RES_PARAM 

Invalid parameters

APP_SECURE_STORAGE_RES_INVALID_AREA 

Memory area doesn't exist

APP_SECURE_STORAGE_RES_INVALID_TAG 

Given data tag not found

Definition at line 31 of file app_secure_storage.h.

APP_SECURE_STORAGE_RES_NODRIVER
@ APP_SECURE_STORAGE_RES_NODRIVER
Definition: app_secure_storage.h:40
APP_SECURE_STORAGE_RES_INVALID_AREA
@ APP_SECURE_STORAGE_RES_INVALID_AREA
Definition: app_secure_storage.h:44
APP_SECURE_STORAGE_NO_ENCRYPT
@ APP_SECURE_STORAGE_NO_ENCRYPT
Definition: app_secure_storage.h:54
app_secure_storage_flags_e
app_secure_storage_flags_e
Secure storage option flags.
Definition: app_secure_storage.h:51
APP_SECURE_STORAGE_RES_PARAM
@ APP_SECURE_STORAGE_RES_PARAM
Definition: app_secure_storage.h:42
APP_SECURE_STORAGE_RES_ERROR
@ APP_SECURE_STORAGE_RES_ERROR
Definition: app_secure_storage.h:36
APP_SECURE_STORAGE_NO_AUTH
@ APP_SECURE_STORAGE_NO_AUTH
Definition: app_secure_storage.h:56
APP_SECURE_STORAGE_RES_OK
@ APP_SECURE_STORAGE_RES_OK
Definition: app_secure_storage.h:34
APP_SECURE_STORAGE_RES_BUSY
@ APP_SECURE_STORAGE_RES_BUSY
Definition: app_secure_storage.h:38
APP_SECURE_STORAGE_RES_INVALID_TAG
@ APP_SECURE_STORAGE_RES_INVALID_TAG
Definition: app_secure_storage.h:46
app_secure_storage_res_e
app_secure_storage_res_e
List of return code.
Definition: app_secure_storage.h:31