lriot  2.1.0.0
Functions
lr1110_crypto_engine.h File Reference

Cryptographic engine driver definition for LR1110. More...

#include "transceiver/lr1110_crypto_engine_types.h"
#include "common/lr1110_types.h"
#include "common/lr1110_hal.h"

Go to the source code of this file.

Functions

err_t lr1110_crypto_select (lriot_t *ctx, lr1110_crypto_element_t element)
 Select the crypto element to be used. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
err_t lr1110_crypto_restore_from_flash (lriot_t *ctx, uint8_t *status)
 Restore the crypto data (keys, parameters) from flash memory into RAM. More...
 
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. More...
 
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. More...
 

Detailed Description

Cryptographic engine driver definition for LR1110.

The Clear BSD License Copyright Semtech Corporation 2021. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]key_idThe identifier of the key to be used for the computation
[in]data_bufThe data to decrypt
[in]lengthThe length in bytes of the data to decrypt - this value shall be a multiple of 16
[out]resultA pointer to a data buffer that will be filled with the decrypted data. Values of this buffer are meaningful if and only if the return status is LR1110_CRYPTO_STATUS_SUCCESS
See also
lr1110_crypto_set_key, lr1110_crypto_derive_key
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]key_idThe identifier of the key to be used for the computation
[in]data_bufThe data to encrypt
[in]lengthThe length in bytes of the data to encrypt - this value shall be a multiple of 16
[out]resultA pointer to a data buffer that will be filled with the encrypted data. Values of this buffer are meaningful if and only if the return status is LR1110_CRYPTO_STATUS_SUCCESS
See also
lr1110_crypto_set_key, lr1110_crypto_derive_key
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]key_idThe identifier of the key to be used for the computation
[in]data_bufThe data to encrypt
[in]lengthThe length in bytes of the data to encrypt - this value shall be a multiple of 16
[out]resultA pointer to a data buffer that will be filled with the encrypted data. Values of this buffer are meaningful if and only if the return status is LR1110_CRYPTO_STATUS_SUCCESS
See also
lr1110_crypto_set_key, lr1110_crypto_derive_key
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]key_idThe identifier of the keyused for the computation
[in]data_bufThe data to compute
[in]lengthThe length in bytes of the data to compute
[out]micPlaceholder for the computed MIC (first 4 bytes of the AES-CMAC)
See also
lr1110_crypto_verify_aes_cmac
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]src_key_idThe identifier of the key to be derived
[in]dest_key_idThe identifier where the derived key will be stored after call to lr1110_crypto_store_to_flash
[in]nonceThe nonce to be used to perform the derivation
See also
lr1110_crypto_set_key
Returns
Operation status

◆ 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.

This function does not fetch a parameter from the flash memory. The parameters shall be restored before using lr1110_crypto_restore_from_flash command.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]param_idThe identifier of the parameter to get
[out]parameterThe placeholder to store the parameter
See also
lr1110_crypto_set_parameter
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]dec_key_idThe identifier of the key used for message decryption
[in]ver_key_idThe identifier of the key used for MIC verification
[in]lorawan_versionLoRaWAN version to know the size of the header
[in]headerThe header to compute (length linked to lorawan_version)
[in]data_bufThe data to compute
[in]lengthThe length in bytes of the data to compute
[out]data_outPlaceholder for the decrypted data
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
See also
lr1110_crypto_store_to_flash
Returns
Operation status

◆ lr1110_crypto_select()

err_t lr1110_crypto_select ( lriot_t ctx,
lr1110_crypto_element_t  element 
)

Select the crypto element to be used.

By default, the internal crypto engine is selected. It is not needed to call this command if one plans to use the internal crypto engine.

Parameters
[in]ctxChip implementation context
[in]elementThe type of crypto element to use
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]key_idThe identifier of the key to be set
[in]keyThe key to be set
See also
lr1110_crypto_derive_key
Returns
Operation status

◆ 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.

This function does not store a parameter in the flash memory. The parameters shall be stored after using lr1110_crypto_store_to_flash command.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]param_idThe identifier of the parameter to be set
[in]parameterThe parameter to be set
See also
lr1110_crypto_get_parameter
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
See also
lr1110_crypto_restore_from_flash
Returns
Operation status

◆ 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.

Parameters
[in]ctxChip implementation context
[out]statusThe status returned by the execution of this cryptographic function
[in]key_idThe identifier of the key to be used for the computation
[in]data_bufThe data to compute
[in]lengthThe length in bytes of the data to compute
[in]micThe MIC value (first 4 bytes of the CMAC) use for comparison
See also
lr1110_crypto_compute_aes_cmac
Returns
Operation status