SEcube
SEcube Open Source Library - Host
|
This file contains L1 functions and structures. More...
Go to the source code of this file.
Data Structures | |
struct | se3_session_ |
SEcube Communication session structure. More... | |
struct | se3_key_ |
SEcube Key structure. More... | |
struct | se3_algo_ |
SEcube Algorithm structure. More... | |
Typedefs | |
typedef struct se3_session_ | se3_session |
SEcube Communication session structure. | |
typedef struct se3_key_ | se3_key |
SEcube Key structure. | |
typedef struct se3_algo_ | se3_algo |
SEcube Algorithm structure. | |
Functions | |
uint16_t | L1_login (se3_session *s, se3_device *dev, const uint8_t *pin, uint16_t access) |
This function is used to let a user/admin login on the device. More... | |
uint16_t | L1_set_admin_PIN (se3_session *s, uint8_t *pin) |
This function is used to change the current admin pin. More... | |
uint16_t | L1_set_user_PIN (se3_session *s, uint8_t *pin) |
This function is used to change the current user pin. More... | |
uint16_t | L1_logout (se3_session *s) |
This function is used to logout from the device. More... | |
uint16_t | L1_key_list (se3_session *s, uint16_t skip, uint16_t max_keys, se3_key *key_array, uint16_t *count) |
This function is used get the list of the already of the already available keys on the device. More... | |
uint16_t | L1_key_edit (se3_session *s, uint16_t op, se3_key *k) |
This function is used to edit the keys data on the device. More... | |
bool | L1_find_key (se3_session *s, uint32_t key_id) |
Check if a Key is present or not. More... | |
uint16_t | L1_crypto_init (se3_session *s, uint16_t algorithm, uint16_t mode, uint32_t key_id, uint32_t *sess_id) |
Initialise a crypto session. More... | |
uint16_t | L1_crypto_update (se3_session *s, uint32_t sess_id, uint16_t flags, uint16_t data1_len, uint8_t *data1, uint16_t data2_len, uint8_t *data2, uint16_t *dataout_len, uint8_t *data_out) |
Update a crypto session. More... | |
uint16_t | L1_crypto_set_time (se3_session *s, uint32_t devtime) |
Set time for a crypto session. More... | |
uint16_t | L1_encrypt (se3_session *s, uint16_t algorithm, uint16_t mode, uint32_t key_id, size_t datain_len, int8_t *data_in, size_t *dataout_len, uint8_t *data_out) |
This function is used to encrypt a buffer of data given the algorithm, the encryption mode, the buffer size, and where to store the encrypted data. More... | |
uint16_t | L1_decrypt (se3_session *s, uint16_t algorithm, uint16_t mode, uint32_t key_id, size_t datain_len, int8_t *data_in, size_t *dataout_len, uint8_t *data_out) |
This function is used to decrypt a buffer of data given the algorithm, the decryption mode, the buffer size, and where to store the decrypted data. More... | |
uint16_t | L1_digest (se3_session *s, uint16_t algorithm, size_t datain_len, int8_t *data_in, size_t *dataout_len, uint8_t *data_out) |
This function is used to sign a buffer of data given the algorithm, the amount of data to sign and where to store them. More... | |
uint16_t | L1_get_algorithms (se3_session *s, uint16_t skip, uint16_t max_algorithms, se3_algo *algorithms_array, uint16_t *count) |
This function is used to retrieve a list from the device of available algorithms. More... | |
This file contains L1 functions and structures.
uint16_t L1_crypto_init | ( | se3_session * | s, |
uint16_t | algorithm, | ||
uint16_t | mode, | ||
uint32_t | key_id, | ||
uint32_t * | sess_id | ||
) |
Initialise a crypto session.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | algorithm | Which algorithm to use, see AlgorithmAvail |
[in] | mode | This parameter strictly depends on the which algorithm is chosen |
[in] | key_id | Which key ID to use for encryption |
[in] | sess_id | Session ID |
uint16_t L1_crypto_set_time | ( | se3_session * | s, |
uint32_t | devtime | ||
) |
Set time for a crypto session.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | devtime | Time to be set |
uint16_t L1_crypto_update | ( | se3_session * | s, |
uint32_t | sess_id, | ||
uint16_t | flags, | ||
uint16_t | data1_len, | ||
uint8_t * | data1, | ||
uint16_t | data2_len, | ||
uint8_t * | data2, | ||
uint16_t * | dataout_len, | ||
uint8_t * | data_out | ||
) |
Update a crypto session.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | sess_id | Session ID |
[in] | flags | Parameter_Description |
[in] | data1_len | How long is the buffer you want to encrypt |
[in] | data1 | Pointer to input buffer 1 |
[in] | data2_len | Length of input buffer 1 |
[in] | data2 | Pointer to input buffer 2 |
[out] | dataout_len | Length of input buffer 1 |
[out] | data_out | Pointer to the output buffer |
uint16_t L1_decrypt | ( | se3_session * | s, |
uint16_t | algorithm, | ||
uint16_t | mode, | ||
uint32_t | key_id, | ||
size_t | datain_len, | ||
int8_t * | data_in, | ||
size_t * | dataout_len, | ||
uint8_t * | data_out | ||
) |
This function is used to decrypt a buffer of data given the algorithm, the decryption mode, the buffer size, and where to store the decrypted data.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | algorithm | Which algorithm to use, see AlgorithmAvail |
[in] | mode | This parameter strictly depends on the which algorithm is chosen |
[in] | key_id | Which key ID to use for decryption |
[in] | datain_len | How long is the buffer you want to decrypt |
[in] | data_in | Pointer to the buffer |
[out] | dataout_len | How many data were actually decrypted |
[out] | data_out | Pointer to a pre-allocated buffer where to store the clear text |
uint16_t L1_digest | ( | se3_session * | s, |
uint16_t | algorithm, | ||
size_t | datain_len, | ||
int8_t * | data_in, | ||
size_t * | dataout_len, | ||
uint8_t * | data_out | ||
) |
This function is used to sign a buffer of data given the algorithm, the amount of data to sign and where to store them.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | algorithm | Which algorithm to use, see AlgorithmAvail |
[in] | datain_len | How long is the buffer you want to sign |
[in] | data_in | Pointer to the buffer |
[out] | dataout_len | How many data were actually signed (can be NULL) |
[out] | data_out | Pointer to a pre-allocated buffer where to store the digest |
uint16_t L1_encrypt | ( | se3_session * | s, |
uint16_t | algorithm, | ||
uint16_t | mode, | ||
uint32_t | key_id, | ||
size_t | datain_len, | ||
int8_t * | data_in, | ||
size_t * | dataout_len, | ||
uint8_t * | data_out | ||
) |
This function is used to encrypt a buffer of data given the algorithm, the encryption mode, the buffer size, and where to store the encrypted data.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | algorithm | Which algorithm to use, see AlgorithmAvail |
[in] | mode | This parameter strictly depends on the which algorithm is chosen |
[in] | key_id | Which key ID to use for encryption |
[in] | datain_len | How long is the buffer you want to encrypt |
[in] | data_in | Pointer to the buffer |
[out] | dataout_len | How many data were actually encrypted |
[out] | data_out | Pointer to a pre-allocated buffer where to store the cipher text |
bool L1_find_key | ( | se3_session * | s, |
uint32_t | key_id | ||
) |
Check if a Key is present or not.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | key_id | ID of key to be found |
uint16_t L1_get_algorithms | ( | se3_session * | s, |
uint16_t | skip, | ||
uint16_t | max_algorithms, | ||
se3_algo * | algorithms_array, | ||
uint16_t * | count | ||
) |
This function is used to retrieve a list from the device of available algorithms.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | skip | How many algorithms you want to skip from the beginning of the device list |
[in] | max_algorithms | How many algorithms you want to retrieve from the device |
[out] | algorithms_array | Pointer to the already allocated array where to store the algorithms |
[in] | count | Effective number of retrieved keys |
uint16_t L1_key_edit | ( | se3_session * | s, |
uint16_t | op, | ||
se3_key * | k | ||
) |
This function is used to edit the keys data on the device.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | op | see KeyOpEdit |
[in] | k | Key value you want to add/update/delete |
uint16_t L1_key_list | ( | se3_session * | s, |
uint16_t | skip, | ||
uint16_t | max_keys, | ||
se3_key * | key_array, | ||
uint16_t * | count | ||
) |
This function is used get the list of the already of the already available keys on the device.
[in] | s | Pointer to current se3_session, you must be logged in |
[in] | skip | How many keys you want to skip from the beginning of the list |
[in] | max_keys | How many keys you want to retrieve from the device |
[out] | key_array | Pointer to the already allocated array where to store the keys |
[out] | count | Effective number of retrieved keys |
uint16_t L1_login | ( | se3_session * | s, |
se3_device * | dev, | ||
const uint8_t * | pin, | ||
uint16_t | access | ||
) |
This function is used to let a user/admin login on the device.
[out] | s | Pointer to an already allocated se3_session object where to store current logged in session |
[in] | dev | Device you want to login to |
[in] | pin | Password to login |
[in] | access | see AccessLogin |
Before issueing any command to the device, you need to login. Some operations are allowed only to the admin user. After a flash erase, the admin pin and the user pin are both a sequence of 32 0s, please use L1_set_admin_PIN or L1_set_user_PIN to change them.
uint16_t L1_logout | ( | se3_session * | s | ) |
This function is used to logout from the device.
[in] | s | Current session you want to end |
After issueing this function, you will be forbidden to perform any command on the device. This can also be used to free the allocated resources, such as cryptographic sessions, with just one call.
uint16_t L1_set_admin_PIN | ( | se3_session * | s, |
uint8_t * | pin | ||
) |
This function is used to change the current admin pin.
[in] | s | Pointer to current se3_session, you must be logged in as admin to issue this command |
[in] | pin | New pin to be set |
uint16_t L1_set_user_PIN | ( | se3_session * | s, |
uint8_t * | pin | ||
) |
This function is used to change the current user pin.
[in] | s | Pointer to current se3_session, you must be logged in as admin to issue this command |
[in] | pin | New pin to be set |