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
39extern "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
96err_t lr1110_crypto_set_key( lriot_t *ctx, uint8_t* status, uint8_t key_id, lr1110_crypto_key_t key );
97
112err_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
130err_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
148err_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
165err_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
183err_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
201err_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
219err_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
232err_t lr1110_crypto_store_to_flash( lriot_t *ctx, uint8_t* status );
233
244err_t lr1110_crypto_restore_from_flash( lriot_t *ctx, uint8_t* status );
245
261err_t lr1110_crypto_set_parameter( lriot_t *ctx, uint8_t* status, uint8_t param_id, lr1110_crypto_param_t parameter );
262
278err_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 ------------------------------------------------------------------ */
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.
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.
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.
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.
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.
err_t lr1110_crypto_select(lriot_t *ctx, lr1110_crypto_element_t element)
Select the crypto element to be used.
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.
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.
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.
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.
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.
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.
err_t lr1110_crypto_restore_from_flash(lriot_t *ctx, uint8_t *status)
Restore the crypto data (keys, parameters) from flash memory into RAM.
Cryptographic engine driver types for LR1110.
lr1110_crypto_lorawan_version_t
The supported LoRaWAN versions.
Definition lr1110_crypto_engine_types.h:149
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
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
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
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_element_t
The supported crypto elements.
Definition lr1110_crypto_engine_types.h:128
Hardware Abstraction Layer (HAL) interface for LR1110.
Type definitions for LR1110.
LR IoT Click context object.
Definition lriot.h:273