Provides AES related functionality through nrf_crypto. More...
Data Structures | |
struct | nrf_crypto_aes_info_t |
struct | nrf_crypto_aes_internal_context_t |
struct | nrf_crypto_backend_aes_ctx_t |
struct | nrf_crypto_backend_no_iv_aes_ctx_t |
Macros | |
#define | NRF_CRYPTO_AES_INIT_MAGIC_VALUE (0x53454163) |
#define | NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE (0x63414553) |
#define | NRF_CRYPTO_MBEDTLS_AES_IV_SIZE (16) |
Typedefs | |
typedef nrf_crypto_backend_aes_context_t | nrf_crypto_aes_context_t |
Context type for AES. More... | |
typedef ret_code_t(* | aes_init_fn_t )(void *const p_context, nrf_crypto_operation_t operation) |
typedef ret_code_t(* | aes_uninit_fn_t )(void *const p_context) |
typedef ret_code_t(* | aes_key_set_fn_t )(void *const p_context, uint8_t *p_key) |
typedef ret_code_t(* | aes_iv_set_fn_t )(void *const p_context, uint8_t *p_iv) |
typedef ret_code_t(* | aes_iv_get_fn_t )(void *const p_context, uint8_t *p_iv) |
typedef ret_code_t(* | aes_update_fn_t )(void *const p_context, uint8_t *p_data_in, size_t data_size, uint8_t *p_data_out) |
typedef ret_code_t(* | aes_finalize_fn_t )(void *const p_context, uint8_t *p_data_in, size_t data_size, uint8_t *p_data_out, size_t *p_data_out_size) |
Functions | |
ret_code_t | nrf_crypto_aes_init (nrf_crypto_aes_context_t *const p_context, nrf_crypto_aes_info_t const *const p_info, nrf_crypto_operation_t operation) |
Function for initializing the AES context. More... | |
ret_code_t | nrf_crypto_aes_uninit (nrf_crypto_aes_context_t *const p_context) |
Internal function for uninitializing the AES context. More... | |
ret_code_t | nrf_crypto_aes_key_set (nrf_crypto_aes_context_t *const p_context, uint8_t *p_key) |
Function for setting the AES key. More... | |
ret_code_t | nrf_crypto_aes_iv_set (nrf_crypto_aes_context_t *const p_context, uint8_t *p_iv) |
Function for setting an AES IV or a counter for AES modes which are using it. More... | |
ret_code_t | nrf_crypto_aes_iv_get (nrf_crypto_aes_context_t *const p_context, uint8_t *p_iv) |
Function for getting an AES IV or a counter for mode which is supporting it. More... | |
ret_code_t | nrf_crypto_aes_update (nrf_crypto_aes_context_t *const p_context, uint8_t *p_data_in, size_t data_size, uint8_t *p_data_out) |
AES update function for encryption, decryption and MAC calculation. It can be called once on the whole data block, or as many times as needed, until all the input data is processed. Functions: nrf_crypto_aes_init, nrf_crypto_aes_key_set, and, for some ciphers, nrf_crypto_aes_iv_set, must be called before call to this API with the same context. More... | |
ret_code_t | nrf_crypto_aes_finalize (nrf_crypto_aes_context_t *const p_context, uint8_t *p_data_in, size_t data_size, uint8_t *p_data_out, size_t *p_data_out_size) |
Function processes the last data block if needed and finalizes the AES operation (ie. adds padding) and produces operation results (for MAC operations). Functions: nrf_crypto_aes_init, nrf_crypto_aes_key_set, and, for some ciphers, nrf_crypto_aes_iv_set, must be called before call to this API with the same context. More... | |
ret_code_t | nrf_crypto_aes_crypt (nrf_crypto_aes_context_t *const p_context, nrf_crypto_aes_info_t const *const p_info, nrf_crypto_operation_t operation, uint8_t *p_key, uint8_t *p_iv, uint8_t *p_data_in, size_t data_size, uint8_t *p_data_out, size_t *p_data_out_size) |
AES integrated function for encryption, decryption and MAC calculation. It should be called once on the whole data block. More... | |
ret_code_t | padding_pkcs7_add (uint8_t *p_padding_buff, uint8_t *p_message_buff, uint8_t msg_ending_len) |
ret_code_t | padding_pkcs7_remove (uint8_t *p_padded_message, size_t *p_message_len) |
Variables | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_128_info |
External variable declaration to the info structure for AES CBC mode with a 128-bit key. No padding. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_192_info |
External variable declaration to the info structure for AES CBC mode with a 192-bit key. No padding. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_256_info |
External variable declaration to the info structure for AES CBC mode with a 256-bit key. No padding. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_128_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC mode with a 128-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_192_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC mode with a 192-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_256_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC mode with a 256-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ctr_128_info |
External variable declaration to the info structure for AES CTR mode with a 128-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ctr_192_info |
External variable declaration to the info structure for AES CTR mode with a 192-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ctr_256_info |
External variable declaration to the info structure for AES CTR mode with a 256-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cfb_128_info |
External variable declaration to the info structure for AES CFB mode with a 128-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cfb_192_info |
External variable declaration to the info structure for AES CFB mode with a 192-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cfb_256_info |
External variable declaration to the info structure for AES CFB mode with a 256-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ecb_128_info |
External variable declaration to the info structure for AES ECB mode with a 128-bit key. No padding. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ecb_192_info |
External variable declaration to the info structure for AES ECB mode with a 192-bit key. No padding. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ecb_256_info |
External variable declaration to the info structure for AES ECB mode with a 256-bit key. No padding. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ecb_128_pad_pkcs7_info |
External variable declaration to the info structure for AES ECB mode with a 128-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ecb_192_pad_pkcs7_info |
External variable declaration to the info structure for AES ECB mode with a 192-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_ecb_256_pad_pkcs7_info |
External variable declaration to the info structure for AES ECB mode with a 256-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_mac_128_info |
External variable declaration to the info structure for AES CBC MAC mode with a 128-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_mac_192_info |
External variable declaration to the info structure for AES CBC MAC mode with a 192-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_mac_256_info |
External variable declaration to the info structure for AES CBC MAC mode with a 256-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_mac_128_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC MAC mode with a 128-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_mac_192_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC MAC mode with a 192-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cbc_mac_256_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC MAC mode with a 256-bit key. Padding pkcs7 enabled. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cmac_128_info |
External variable declaration to the info structure for AES CMAC mode with a 128-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cmac_192_info |
External variable declaration to the info structure for AES CMAC mode with a 192-bit key. More... | |
const nrf_crypto_aes_info_t | g_nrf_crypto_aes_cmac_256_info |
External variable declaration to the info structure for AES CMAC mode with a 256-bit key. More... | |
Provides AES related functionality through nrf_crypto.
Context type for AES.
ret_code_t nrf_crypto_aes_crypt | ( | nrf_crypto_aes_context_t *const | p_context, |
nrf_crypto_aes_info_t const *const | p_info, | ||
nrf_crypto_operation_t | operation, | ||
uint8_t * | p_key, | ||
uint8_t * | p_iv, | ||
uint8_t * | p_data_in, | ||
size_t | data_size, | ||
uint8_t * | p_data_out, | ||
size_t * | p_data_out_size | ||
) |
AES integrated function for encryption, decryption and MAC calculation. It should be called once on the whole data block.
[in] | p_context | Context object. If NULL, memory will be dynamically allocated. |
[in] | p_info | Pointer to structure holding information about: selected AES mode, key size, and padding. |
[in] | operation | Parameter indicating whether an encrypt (NRF_CRYPTO_ENCRYPT), a decrypt (NRF_CRYPTO_DECRYPT) or MAC calculation (NRF_CRYPTO_MAC_CALCULATE) operation shall be performed. |
[in] | p_key | Pointer to the AES key. This buffer will be copied and there is no need to keep it by the user. |
[in] | p_iv | Pointer to a buffer of the IV or a counter. This buffer will be copied and there is no need to keep it by the user. Can be NULL for ECB and CMAC. |
[in] | p_data_in | Pointer to the input buffer to the AES. |
[in] | data_size | Size of the data to be processed in bytes. |
[out] | p_data_out | Pointer to the output buffer. When padding is set:
|
[in,out] | p_data_out_size | IN: Size of the p_data_out buffer. OUT: Upon successfull function execution value will be updated with number of signifacnt bytes in p_data_out buffer. On decryption function will result in a value without padded bytes. |
ret_code_t nrf_crypto_aes_finalize | ( | nrf_crypto_aes_context_t *const | p_context, |
uint8_t * | p_data_in, | ||
size_t | data_size, | ||
uint8_t * | p_data_out, | ||
size_t * | p_data_out_size | ||
) |
Function processes the last data block if needed and finalizes the AES operation (ie. adds padding) and produces operation results (for MAC operations). Functions: nrf_crypto_aes_init, nrf_crypto_aes_key_set, and, for some ciphers, nrf_crypto_aes_iv_set, must be called before call to this API with the same context.
Upon successful operation function will deinitialize the context but for some ciphers it will be possible to read IV. In order to fully deinitialize context you must call nrf_crypto_aes_uninit.
[in] | p_context | Context object. Must be initialized before the call. |
[in] | p_data_in | Pointer to the input buffer to the AES. |
[in] | data_size | Size of the data to be processed in bytes. |
[out] | p_data_out | Pointer to the output buffer. When padding is set:
|
[in,out] | p_data_out_size | IN: Size of the p_data_out buffer. OUT: Upon successfull function execution value will be updated with number of signifacnt bytes in p_data_out buffer. On decryption with padding function will result in a value without padded bytes. |
ret_code_t nrf_crypto_aes_init | ( | nrf_crypto_aes_context_t *const | p_context, |
nrf_crypto_aes_info_t const *const | p_info, | ||
nrf_crypto_operation_t | operation | ||
) |
Function for initializing the AES context.
[in] | p_context | Pointer to the context object. It must be a context type associated with the object provided in the p_info parameter or other memory that can hold that context type. |
[in] | p_info | Pointer to structure holding information about: selected AES mode, key size, and padding. |
[in] | operation | Parameter indicating whether an encrypt (NRF_CRYPTO_ENCRYPT), a decrypt (NRF_CRYPTO_DECRYPT) or MAC calculation (NRF_CRYPTO_MAC_CALCULATE) operation shall be performed. |
ret_code_t nrf_crypto_aes_iv_get | ( | nrf_crypto_aes_context_t *const | p_context, |
uint8_t * | p_iv | ||
) |
Function for getting an AES IV or a counter for mode which is supporting it.
[in] | p_context | Context object. Must be initialized before the call. |
[out] | p_iv | Pointer to a buffer of the IV or a counter. |
ret_code_t nrf_crypto_aes_iv_set | ( | nrf_crypto_aes_context_t *const | p_context, |
uint8_t * | p_iv | ||
) |
Function for setting an AES IV or a counter for AES modes which are using it.
[in] | p_context | Context object. Must be initialized before the call. |
[in] | p_iv | Pointer to a buffer of the IV or a counter. This buffer will be copied and there is no need to keep it by the user. |
ret_code_t nrf_crypto_aes_key_set | ( | nrf_crypto_aes_context_t *const | p_context, |
uint8_t * | p_key | ||
) |
Function for setting the AES key.
[in] | p_context | Context object. Must be initialized before the call. |
[in] | p_key | Pointer to the AES key. This buffer will be copied and there is no need to keep it by the user. |
ret_code_t nrf_crypto_aes_uninit | ( | nrf_crypto_aes_context_t *const | p_context | ) |
Internal function for uninitializing the AES context.
[in] | p_context | Context object. Must be initialized before the call. |
ret_code_t nrf_crypto_aes_update | ( | nrf_crypto_aes_context_t *const | p_context, |
uint8_t * | p_data_in, | ||
size_t | data_size, | ||
uint8_t * | p_data_out | ||
) |
AES update function for encryption, decryption and MAC calculation. It can be called once on the whole data block, or as many times as needed, until all the input data is processed. Functions: nrf_crypto_aes_init, nrf_crypto_aes_key_set, and, for some ciphers, nrf_crypto_aes_iv_set, must be called before call to this API with the same context.
[in] | p_context | Context object. Must be initialized before the call. |
[in] | p_data_in | Pointer to the input buffer to the AES. |
[in] | data_size | Size of the data to be processed in bytes. For all modes except CFB it must be multiple of 16 bytes. |
[out] | p_data_out | Pointer to the output buffer. |
const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_128_info |
External variable declaration to the info structure for AES CBC mode with a 128-bit key. No padding.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_128_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC mode with a 128-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_192_info |
External variable declaration to the info structure for AES CBC mode with a 192-bit key. No padding.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_192_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC mode with a 192-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_256_info |
External variable declaration to the info structure for AES CBC mode with a 256-bit key. No padding.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_256_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC mode with a 256-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_128_info |
External variable declaration to the info structure for AES CBC MAC mode with a 128-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_128_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC MAC mode with a 128-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_192_info |
External variable declaration to the info structure for AES CBC MAC mode with a 192-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_192_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC MAC mode with a 192-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_256_info |
External variable declaration to the info structure for AES CBC MAC mode with a 256-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cbc_mac_256_pad_pkcs7_info |
External variable declaration to the info structure for AES CBC MAC mode with a 256-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cfb_128_info |
External variable declaration to the info structure for AES CFB mode with a 128-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cfb_192_info |
External variable declaration to the info structure for AES CFB mode with a 192-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cfb_256_info |
External variable declaration to the info structure for AES CFB mode with a 256-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cmac_128_info |
External variable declaration to the info structure for AES CMAC mode with a 128-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cmac_192_info |
External variable declaration to the info structure for AES CMAC mode with a 192-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_cmac_256_info |
External variable declaration to the info structure for AES CMAC mode with a 256-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ctr_128_info |
External variable declaration to the info structure for AES CTR mode with a 128-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ctr_192_info |
External variable declaration to the info structure for AES CTR mode with a 192-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ctr_256_info |
External variable declaration to the info structure for AES CTR mode with a 256-bit key.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_128_info |
External variable declaration to the info structure for AES ECB mode with a 128-bit key. No padding.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_128_pad_pkcs7_info |
External variable declaration to the info structure for AES ECB mode with a 128-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_192_info |
External variable declaration to the info structure for AES ECB mode with a 192-bit key. No padding.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_192_pad_pkcs7_info |
External variable declaration to the info structure for AES ECB mode with a 192-bit key. Padding pkcs7 enabled.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_256_info |
External variable declaration to the info structure for AES ECB mode with a 256-bit key. No padding.
sdk_config
file. const nrf_crypto_aes_info_t g_nrf_crypto_aes_ecb_256_pad_pkcs7_info |
External variable declaration to the info structure for AES ECB mode with a 256-bit key. Padding pkcs7 enabled.
sdk_config
file.