lriot  2.1.0.0
lr1110_crypto_engine.h
Go to the documentation of this file.
1 
35 #ifndef LR1110_CRYPTO_ENGINE_H
36 #define LR1110_CRYPTO_ENGINE_H
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * -----------------------------------------------------------------------------
44  * --- DEPENDENCIES ------------------------------------------------------------
45  */
46 
48 #include "common/lr1110_types.h"
49 #include "common/lr1110_hal.h"
50 
51 /*
52  * -----------------------------------------------------------------------------
53  * --- PUBLIC MACROS -----------------------------------------------------------
54  */
55 
56 /*
57  * -----------------------------------------------------------------------------
58  * --- PUBLIC CONSTANTS --------------------------------------------------------
59  */
60 
61 /*
62  * -----------------------------------------------------------------------------
63  * --- PUBLIC TYPES ------------------------------------------------------------
64  */
65 
66 /*
67  * -----------------------------------------------------------------------------
68  * --- PUBLIC FUNCTIONS PROTOTYPES ---------------------------------------------
69  */
70 
83 
96 err_t lr1110_crypto_set_key( lriot_t *ctx, uint8_t* status, uint8_t key_id, lr1110_crypto_key_t key );
97 
112 err_t lr1110_crypto_derive_key( lriot_t *ctx, uint8_t* status, uint8_t src_key_id,
113  uint8_t dest_key_id, lr1110_crypto_nonce_t nonce );
114 
130 err_t lr1110_crypto_process_join_accept( lriot_t *ctx, uint8_t* status, uint8_t dec_key_id, uint8_t ver_key_id,
131  lr1110_crypto_lorawan_version_t lorawan_version, uint8_t* header,
132  uint8_t* data_in, uint8_t length, uint8_t* data_out );
133 
148 err_t lr1110_crypto_compute_aes_cmac( lriot_t *ctx, uint8_t* status, uint8_t key_id, uint8_t* data_buf,
149  uint16_t length, lr1110_crypto_mic_t mic );
150 
165 err_t lr1110_crypto_verify_aes_cmac( lriot_t *ctx, uint8_t* status, uint8_t key_id, uint8_t* data_buf,
166  uint16_t length, lr1110_crypto_mic_t mic );
167 
183 err_t lr1110_crypto_aes_encrypt_01( lriot_t *ctx, uint8_t* status, uint8_t key_id, uint8_t* data_buf,
184  uint16_t length, uint8_t* result );
185 
201 err_t lr1110_crypto_aes_encrypt( lriot_t *ctx, uint8_t* status, uint8_t key_id, uint8_t* data_buf,
202  uint16_t length, uint8_t* result );
203 
219 err_t lr1110_crypto_aes_decrypt( lriot_t *ctx, uint8_t* status, uint8_t key_id, uint8_t* data_buf,
220  uint16_t length, uint8_t* result );
221 
232 err_t lr1110_crypto_store_to_flash( lriot_t *ctx, uint8_t* status );
233 
244 err_t lr1110_crypto_restore_from_flash( lriot_t *ctx, uint8_t* status );
245 
261 err_t lr1110_crypto_set_parameter( lriot_t *ctx, uint8_t* status, uint8_t param_id, lr1110_crypto_param_t parameter );
262 
278 err_t lr1110_crypto_get_parameter( lriot_t *ctx, uint8_t* status, uint8_t param_id, lr1110_crypto_param_t parameter );
279 
280 #ifdef __cplusplus
281 }
282 #endif
283 
284 #endif // LR1110_CRYPTO_ENGINE_H
285 
286 /* --- EOF ------------------------------------------------------------------ */
lriot_t
LR IoT Click context object.
Definition: lriot.h:259
lr1110_crypto_store_to_flash
err_t lr1110_crypto_store_to_flash(lriot_t *ctx, uint8_t *status)
Store the crypto data (keys, parameters) from RAM into the flash memory.
lr1110_crypto_select
err_t lr1110_crypto_select(lriot_t *ctx, lr1110_crypto_element_t element)
Select the crypto element to be used.
lr1110_crypto_process_join_accept
err_t lr1110_crypto_process_join_accept(lriot_t *ctx, uint8_t *status, uint8_t dec_key_id, uint8_t ver_key_id, lr1110_crypto_lorawan_version_t lorawan_version, uint8_t *header, uint8_t *data_in, uint8_t length, uint8_t *data_out)
Perform the needed operations to extract the payload from a join accept message.
lr1110_crypto_aes_encrypt_01
err_t lr1110_crypto_aes_encrypt_01(lriot_t *ctx, uint8_t *status, uint8_t key_id, uint8_t *data_buf, uint16_t length, uint8_t *result)
Compute an AES encryption with a key ID specified in parameter.
lr1110_crypto_derive_key
err_t lr1110_crypto_derive_key(lriot_t *ctx, uint8_t *status, uint8_t src_key_id, uint8_t dest_key_id, lr1110_crypto_nonce_t nonce)
Derive a key previously set.
lr1110_crypto_aes_encrypt
err_t lr1110_crypto_aes_encrypt(lriot_t *ctx, uint8_t *status, uint8_t key_id, uint8_t *data_buf, uint16_t length, uint8_t *result)
Compute an AES encryption with a key ID specified in parameter.
lr1110_hal.h
Hardware Abstraction Layer (HAL) interface for LR1110.
lr1110_crypto_compute_aes_cmac
err_t lr1110_crypto_compute_aes_cmac(lriot_t *ctx, uint8_t *status, uint8_t key_id, uint8_t *data_buf, uint16_t length, lr1110_crypto_mic_t mic)
Compute an AES-CMAC.
lr1110_crypto_key_t
uint8_t lr1110_crypto_key_t[LR1110_CRYPTO_KEY_LENGTH]
Fixed-length array to store a crypto key.
Definition: lr1110_crypto_engine_types.h:112
lr1110_crypto_set_key
err_t lr1110_crypto_set_key(lriot_t *ctx, uint8_t *status, uint8_t key_id, lr1110_crypto_key_t key)
Set a key in the previously selected crypto element.
lr1110_crypto_get_parameter
err_t lr1110_crypto_get_parameter(lriot_t *ctx, uint8_t *status, uint8_t param_id, lr1110_crypto_param_t parameter)
Get a specific parameter identified by paramID from the crypto RAM.
lr1110_crypto_mic_t
uint8_t lr1110_crypto_mic_t[LR1110_CRYPTO_MIC_LENGTH]
Fixed-length array to store an AES CMAC.
Definition: lr1110_crypto_engine_types.h:102
lr1110_crypto_restore_from_flash
err_t lr1110_crypto_restore_from_flash(lriot_t *ctx, uint8_t *status)
Restore the crypto data (keys, parameters) from flash memory into RAM.
lr1110_crypto_verify_aes_cmac
err_t lr1110_crypto_verify_aes_cmac(lriot_t *ctx, uint8_t *status, uint8_t key_id, uint8_t *data_buf, uint16_t length, lr1110_crypto_mic_t mic)
Compute an AES-CMAC and make a comparison with a value given as parameter.
lr1110_crypto_lorawan_version_t
lr1110_crypto_lorawan_version_t
The supported LoRaWAN versions.
Definition: lr1110_crypto_engine_types.h:149
lr1110_crypto_param_t
uint8_t lr1110_crypto_param_t[LR1110_CRYPTO_PARAMETER_LENGTH]
Fixed-length array to store a crypto parameter.
Definition: lr1110_crypto_engine_types.h:122
lr1110_crypto_element_t
lr1110_crypto_element_t
The supported crypto elements.
Definition: lr1110_crypto_engine_types.h:128
lr1110_types.h
Type definitions for LR1110.
lr1110_crypto_set_parameter
err_t lr1110_crypto_set_parameter(lriot_t *ctx, uint8_t *status, uint8_t param_id, lr1110_crypto_param_t parameter)
Set a specific parameter identified by param_id in the crypto RAM.
lr1110_crypto_nonce_t
uint8_t lr1110_crypto_nonce_t[LR1110_CRYPTO_NONCE_LENGTH]
Fixed-length array to store a crypto nonce.
Definition: lr1110_crypto_engine_types.h:117
lr1110_crypto_aes_decrypt
err_t lr1110_crypto_aes_decrypt(lriot_t *ctx, uint8_t *status, uint8_t key_id, uint8_t *data_buf, uint16_t length, uint8_t *result)
Compute an AES decryption with a key ID specified in parameter.
lr1110_crypto_engine_types.h
Cryptographic engine driver types for LR1110.