SEcube
SEcube Open Source Library - Device
Enumerations | Functions
se3_keys.c File Reference

Key management. More...

#include "se3_keys.h"

Enumerations

enum  {
  SE3_KEY_OFFSET_ID = 0, SE3_KEY_OFFSET_VALIDITY = 4, SE3_KEY_OFFSET_DATALEN = 8, SE3_KEY_OFFSET_NAMELEN = 10,
  SE3_KEY_OFFSET_DATA = 12
}
 

Functions

bool se3_key_find (uint32_t id, se3_flash_it *it)
 Find a key. More...
 
bool se3_key_remove (se3_flash_it *it)
 Remove a key. More...
 
bool se3_key_new (se3_flash_it *it, se3_flash_key *key)
 Add a new key. More...
 
void se3_key_read (se3_flash_it *it, se3_flash_key *key)
 Read a key. More...
 
bool se3_key_equal (se3_flash_it *it, se3_flash_key *key)
 Check if key is equal. More...
 
void se3_key_read_data (se3_flash_it *it, uint16_t data_size, uint8_t *data)
 Read data from key node. More...
 
bool se3_key_write (se3_flash_it *it, se3_flash_key *key)
 Write key data. More...
 

Detailed Description

Key management.

Author
Nicola Ferri

Function Documentation

bool se3_key_equal ( se3_flash_it it,
se3_flash_key key 
)

Check if key is equal.

Check if the supplied key is equal to a key stored in the flash.

Parameters
ita flash iterator pointing to a key
keya flash key structure to compare
Returns
true if equal, else false
bool se3_key_find ( uint32_t  id,
se3_flash_it it 
)

Find a key.

Find a key in the flash memory

Parameters
ididentifier of the key
ita flash iterator that will be set to the key's position
Returns
true on success
bool se3_key_new ( se3_flash_it it,
se3_flash_key key 
)

Add a new key.

Create a new node with the necessary amount of space for the key, then write the key.

Remarks
if a flash operation fails, the hwerror flag (se3c0.hwerror) is set.
Parameters
ita flash iterator which will receive the position of the new node
keya flash key structure containing the key information The data and name fields must point to a valid memory region, unless their size (data_size, name_size) is zero.
Returns
true on success, else false
void se3_key_read ( se3_flash_it it,
se3_flash_key key 
)

Read a key.

Read a key from a flash node

Parameters
ita flash iterator pointing to the key
keya flash key structure which will receive the key's information. The data and name fields will be filled only if not NULL.
void se3_key_read_data ( se3_flash_it it,
uint16_t  data_size,
uint8_t *  data 
)

Read data from key node.

Read the key's data from a ket node

Parameters
ita flash iterator pointing to the key
data_sizethe number of bytes to read
dataoutput data buffer
bool se3_key_remove ( se3_flash_it it)

Remove a key.

Delete a key from the flash

Remarks
if a flash operation fails, the hwerror flag (se3c0.hwerror) is set.
Parameters
ita flash iterator pointing to the key
Returns
true on success
bool se3_key_write ( se3_flash_it it,
se3_flash_key key 
)

Write key data.

Write key data to a flash node

Remarks
if a flash operation fails, the hwerror flag (se3c0.hwerror) is set.
Parameters
ita flash iterator pointing to a newly created flash node of key type
keya flash key structure containing the key information The data and name fields must point to a valid memory region, unless their size (data_size, name_size) is zero.
Returns
true on success, else false