Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_AES_H__
53 #define __GR55xx_HAL_AES_H__
195 #define HAL_AES_ERROR_NONE ((uint32_t)0x00000000)
196 #define HAL_AES_ERROR_TIMEOUT ((uint32_t)0x00000001)
197 #define HAL_AES_ERROR_TRANSFER ((uint32_t)0x00000002)
198 #define HAL_AES_ERROR_INVALID_PARAM ((uint32_t)0x00000004)
204 #define AES_KEYSIZE_128BITS LL_AES_KEY_SIZE_128
205 #define AES_KEYSIZE_192BITS LL_AES_KEY_SIZE_192
206 #define AES_KEYSIZE_256BITS LL_AES_KEY_SIZE_256
212 #define AES_BLOCK_MAX (2048)
213 #define AES_BLOCKSIZE_BITS (128)
214 #define AES_BLOCKSIZE_BYTES (AES_BLOCKSIZE_BITS >> 3)
215 #define AES_BLOCKSIZE_WORDS (AES_BLOCKSIZE_BYTES >> 2)
221 #define AES_OPERATION_MODE_ENCRYPT (1)
222 #define AES_OPERATION_MODE_DECRYPT (0)
228 #define AES_CHAININGMODE_ECB LL_AES_OPERATION_MODE_ECB
229 #define AES_CHAININGMODE_CBC LL_AES_OPERATION_MODE_CBC
235 #define AES_FLAG_DATAREADY LL_AES_FLAG_DATAREADY
236 #define AES_FLAG_DMA_DONE LL_AES_FLAG_DMA_DONE
237 #define AES_FLAG_DMA_ERR LL_AES_FLAG_DMA_ERR
238 #define AES_FLAG_KEY_VALID LL_AES_FLAG_KEY_VALID
244 #define AES_IT_DONE ((uint32_t)0x00000001)
250 #define HAL_AES_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
264 #define __HAL_AES_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_AES_STATE_RESET)
270 #define __HAL_AES_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, AES_CTRL_ENABLE)
276 #define __HAL_AES_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, AES_CTRL_ENABLE)
282 #define __HAL_AES_ENABLE_IT(__HANDLE__) ll_aes_enable_it_done((__HANDLE__)->p_instance)
288 #define __HAL_AES_DISABLE_IT(__HANDLE__) ll_aes_disable_it_done((__HANDLE__)->p_instance)
297 #define __HAL_AES_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__)) == (__FLAG__))
306 #define __HAL_AES_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__))
318 #define __HAL_AES_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STATUS, (__FLAG__)) != 0) ? SET : RESET)
331 #define IS_AES_KEY_SIZE(__SIZE__) (((__SIZE__) == AES_KEYSIZE_128BITS) || \
332 ((__SIZE__) == AES_KEYSIZE_192BITS) || \
333 ((__SIZE__) == AES_KEYSIZE_256BITS))
339 #define IS_AES_OPERATION_MODE(__MODE__) (((__MODE__) == AES_OPERATION_MODE_ENCRYPT) || \
340 ((__MODE__) == AES_OPERATION_MODE_DECRYPT))
346 #define IS_AES_CHAININGMODE(__MODE__) (((__MODE__) == AES_CHAININGMODE_ECB) || \
347 ((__MODE__) == AES_CHAININGMODE_CBC))
void hal_aes_msp_deinit(aes_handle_t *p_aes)
De-initialize the AES MSP.
void(* aes_msp_deinit)(aes_handle_t *p_aes)
AES de-init MSP callback
hal_lock_t
HAL Lock structures definition.
@ HAL_AES_STATE_RESET
Peripheral not initialized
void(* aes_msp_init)(aes_handle_t *p_aes)
AES init MSP callback
void(* aes_done_callback)(aes_handle_t *p_aes)
AES encrypt or decrypt done callback
hal_status_t hal_aes_ecb_encrypt_it(aes_handle_t *p_aes, uint32_t *p_plain_data, uint32_t number, uint32_t *p_cypher_data)
Encrypted an amount of data in non-blocking mode with Interrupt in ECB mode.
uint32_t * p_seed
Random seeds.
hal_status_t hal_aes_suspend_reg(aes_handle_t *p_aes)
Suspend some registers related to AES configuration before sleep.
uint32_t block_count
Blocks count
uint32_t * p_key
Encryption/Decryption Key.
uint32_t hal_aes_get_error(aes_handle_t *p_aes)
Return the AES error code.
struct _aes_handle aes_handle_t
AES handle Structure definition.
__IO hal_lock_t lock
Locking object
@ HAL_AES_STATE_TIMEOUT
Peripheral in timeout
struct _hal_aes_callback hal_aes_callback_t
HAL AES Callback function definition.
hal_status_t hal_aes_ecb_encrypt(aes_handle_t *p_aes, uint32_t *p_plain_data, uint32_t number, uint32_t *p_cypher_data, uint32_t timeout)
Encrypted an amount of data in blocking mode in ECB mode.
void hal_aes_msp_init(aes_handle_t *p_aes)
Initialize the AES MSP.
__IO uint32_t error_code
AES Error code
hal_status_t hal_aes_cbc_encrypt_dma(aes_handle_t *p_aes, uint32_t *p_plain_data, uint32_t number, uint32_t *p_cypher_data)
Encrypted an amount of data in non-blocking mode with DMA in CBC mode.
void hal_aes_set_timeout(aes_handle_t *p_aes, uint32_t timeout)
Set the AES internal process timeout value.
hal_status_t hal_aes_resume_reg(aes_handle_t *p_aes)
Restore some registers related to AES configuration after sleep.
Header file containing functions prototypes of AES LL library.
hal_status_t hal_aes_init(aes_handle_t *p_aes)
Initialize the AES according to the specified parameters in the aes_init_t and initialize the associa...
void hal_aes_irq_handler(aes_handle_t *p_aes)
Handle AES interrupt request.
uint32_t retention[18]
AES important register information.
hal_status_t hal_aes_cbc_encrypt_it(aes_handle_t *p_aes, uint32_t *p_plain_data, uint32_t number, uint32_t *p_cypher_data)
Encrypted an amount of data in non-blocking mode with Interrupt in CBC mode.
hal_aes_state_t hal_aes_get_state(aes_handle_t *p_aes)
Return the AES handle state.
@ HAL_AES_STATE_READY
Peripheral initialized and ready for use
uint32_t * p_init_vector
Initialization Vector used for CBC modes.
AES Init Structure definition.
__IO hal_aes_state_t state
AES operation state
hal_status_t hal_aes_cbc_decrypt(aes_handle_t *p_aes, uint32_t *p_cypher_data, uint32_t number, uint32_t *p_plain_data, uint32_t timeout)
Decrypted an amount of data in blocking mode in CBC mode.
struct _aes_init aes_init_t
AES Init Structure definition.
hal_status_t hal_aes_ecb_decrypt(aes_handle_t *p_aes, uint32_t *p_cypher_data, uint32_t number, uint32_t *p_plain_data, uint32_t timeout)
Decrypted an amount of data in blocking mode in ECB mode.
hal_status_t hal_aes_ecb_encrypt_dma(aes_handle_t *p_aes, uint32_t *p_plain_data, uint32_t number, uint32_t *p_cypher_data)
Encrypted an amount of data in non-blocking mode with DMA in ECB mode.
aes_init_t init
AES operation parameters
HAL AES Callback function definition.
uint32_t timeout
Timeout for the AES operation
aes_regs_t * p_instance
AES registers base address
@ HAL_AES_STATE_ERROR
Peripheral in error
hal_status_t
HAL Status structures definition.
AES handle Structure definition.
hal_status_t hal_aes_cbc_decrypt_dma(aes_handle_t *p_aes, uint32_t *p_cypher_data, uint32_t number, uint32_t *p_plain_data)
Decrypted an amount of data in non-blocking mode with DMA in CBC mode.
hal_status_t hal_aes_deinit(aes_handle_t *p_aes)
De-initialize the AES peripheral.
uint32_t dpa_mode
DPA Mode.
uint32_t operation_mode
AES operating mode.
uint32_t key_size
128, 192 or 256-bits key length.
uint32_t block_size
Data size in blocks (16 bytes per block)
hal_status_t hal_aes_ecb_decrypt_dma(aes_handle_t *p_aes, uint32_t *p_cypher_data, uint32_t number, uint32_t *p_plain_data)
Decrypted an amount of data in non-blocking mode with DMA in ECB mode.
hal_aes_state_t
HAL AES State Enumerations definition.
hal_status_t hal_aes_cbc_encrypt(aes_handle_t *p_aes, uint32_t *p_plain_data, uint32_t number, uint32_t *p_cypher_data, uint32_t timeout)
Encrypted an amount of data in blocking mode in CBC mode.
@ HAL_AES_STATE_SUSPENDED
Peripheral in suspended
uint32_t * p_cryp_output_buffer
Pointer to CRYP processing (encryption or decryption) output buffer.
hal_status_t hal_aes_ecb_decrypt_it(aes_handle_t *p_aes, uint32_t *p_cypher_data, uint32_t number, uint32_t *p_plain_data)
Decrypted an amount of data in non-blocking mode with Interrupt in ECB mode.
void(* aes_error_callback)(aes_handle_t *p_aes)
AES error callback
@ HAL_AES_STATE_BUSY
Peripheral in indirect mode and busy
void hal_aes_error_callback(aes_handle_t *p_aes)
AES error callback.
uint32_t chaining_mode
AES chaining mode.
uint32_t * p_cryp_input_buffer
Pointer to CRYP processing (encryption or decryption) input buffer
void hal_aes_done_callback(aes_handle_t *p_aes)
Encrypt or decrypt Done callback.
hal_status_t hal_aes_cbc_decrypt_it(aes_handle_t *p_aes, uint32_t *p_cypher_data, uint32_t number, uint32_t *p_plain_data)
Decrypted an amount of data in non-blocking mode with Interrupt in CBC mode.
This file contains HAL common definitions, enumeration, macros and structures definitions.