hal_aes.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file hal_aes.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of AES HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_AES AES
47  * @brief AES HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR5XX_HAL_AES_H__
53 #define __GR5XX_HAL_AES_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "ll_aes.h"
61 #include "ll_misc.h"
62 #include "hal_def.h"
63 
64 /* Exported types ------------------------------------------------------------*/
65 /** @addtogroup HAL_AES_ENUMERATIONS Enumerations
66  * @{
67  */
68 
69 
70 /** @defgroup HAL_AES_state HAL AES State
71  * @{
72  */
73 
74 /**
75  * @brief HAL AES State Enumerations definition
76  */
77 typedef enum
78 {
79  HAL_AES_STATE_RESET = 0x00, /**< Peripheral not initialized */
80  HAL_AES_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
81  HAL_AES_STATE_BUSY = 0x02, /**< Peripheral in indirect mode and busy */
83 
84 /** @} */
85 
86 /** @} */
87 
88 /** @addtogroup HAL_AES_STRUCTURES Structures
89  * @{
90  */
91 
92 /** @defgroup AES_Configuration AES Configuration
93  * @{
94  */
95 
96 /**
97  * @brief AES Init Structure definition
98  */
99 typedef struct _aes_init
100 {
101  uint32_t key_mode; /**< AES key mode.
102  This parameter can be a value of @ref AES_KEY_Mode */
103  uint32_t key_type; /**< AES key type.
104  This parameter can be a value of @ref AES_KEY_TYPE */
105  uint32_t key_size; /**< 128, 192 or 256-bits key length.
106  This parameter can be a value of @ref AES_KEYSIZE */
107  uint32_t *p_key; /**< Encryption/Decryption Key */
108  uint32_t key_addr; /**< Encryption/Decryption Key address */
109  uint32_t key_mask; /**< Keyport Mask */
110  uint32_t key_slot; /**< Keyram Key slot */
111  uint32_t *p_init_vector; /**< Initialization Vector used for CBC modes */
112  uint32_t dpa_mode; /**< DPA Mode.
113  This parameter can be a value of @ref AES_DPA_MODE */
114  uint32_t *p_seed; /**< Random seeds */
115  uint32_t endian_mode; /**< AES Endian Mode.
116  This parameter can be a value of @ref AES_ENDIAN_MODE */
118 
119 /** @} */
120 
121 /** @defgroup AES_handle AES Handle
122  * @{
123  */
124 
125 /**
126  * @brief AES handle Structure definition
127  */
128 typedef struct _aes_handle
129 {
130  aes_regs_t *p_instance; /**< AES registers base address */
131  aes_init_t init; /**< AES init parameters */
132  uint32_t operation_mode; /**< AES operating mode */
133  uint32_t chaining_mode; /**< AES chaining mode */
134  uint32_t *p_cryp_input_buffer; /**< Pointer to CRYP processing (encryption or decryption) input buffer */
135  uint32_t *p_cryp_output_buffer; /**< Pointer to CRYP processing (encryption or decryption) output buffer */
136  uint32_t block_size; /**< Data size in blocks (16 bytes per block) */
137  uint32_t keyram_offset; /**< Keyram offset */
138  __IO hal_aes_state_t state; /**< AES operation state */
139  __IO uint32_t error_code; /**< AES Error code */
141 
142 /** @} */
143 
144 /** @} */
145 
146 /** @addtogroup HAL_AES_CALLBACK_STRUCTURES Callback Structures
147  * @{
148  */
149 
150 /** @defgroup AES_Callback AES Callback
151  * @{
152  */
153 
154 /**
155  * @brief HAL AES Callback function definition
156  */
157 typedef struct _hal_aes_callback
158 {
159  void (*aes_msp_init)(aes_handle_t *p_aes); /**< AES init MSP callback */
160  void (*aes_msp_deinit)(aes_handle_t *p_aes); /**< AES de-init MSP callback */
161  void (*aes_error_callback)(aes_handle_t *p_aes); /**< AES error callback */
162  void (*aes_done_callback)(aes_handle_t *p_aes); /**< AES encrypt or decrypt done callback */
163  void (*aes_abort_cplt_callback)(aes_handle_t *p_aes); /**< AES abort complete callback */
165 
166 /** @} */
167 
168 /** @} */
169 
170 /**
171  * @defgroup HAL_AES_MACRO Defines
172  * @{
173  */
174 
175 /* Exported constants --------------------------------------------------------*/
176 /** @defgroup AES_Exported_Constants AES Exported Constants
177  * @{
178  */
179 
180 /** @defgroup AES_Error_Code AES Error Code
181  * @{
182  */
183 #define HAL_AES_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
184 #define HAL_AES_ERROR_BUSY ((uint32_t)0x00000001) /**< Busy error */
185 #define HAL_AES_ERROR_TIMEOUT ((uint32_t)0x00000002) /**< Timeout error */
186 #define HAL_AES_ERROR_TRANSFER ((uint32_t)0x00000004) /**< Transfer error */
187 #define HAL_AES_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
188 /** @} */
189 
190 /** @defgroup AES_OPERATION_MODE AES Operation Mode
191  * @{
192  */
193 #define AES_OPERATION_MODE_ENCRYPT (1U) /**< Encrypt operation mode */
194 #define AES_OPERATION_MODE_DECRYPT (0U) /**< Decrypt operation mode */
195 /** @} */
196 
197 /** @defgroup AES_CHAININGMODE AES Chaining Mode
198  * @{
199  */
200 #define AES_CHAININGMODE_ECB LL_AES_OPERATION_MODE_ECB /**< ECB chaining mode */
201 #define AES_CHAININGMODE_CBC LL_AES_OPERATION_MODE_CBC /**< CBC chaining mode */
202 /** @} */
203 
204 /** @defgroup AES_ENDIAN_MODE AES Endian Mode
205  * @{
206  */
207 #define AES_ENDIAN_MODE_BIG (1U) /**< Big endian mode */
208 #define AES_ENDIAN_MODE_SMALL (0U) /**< Small endian mode */
209 /** @} */
210 
211 /** @defgroup AES_KEY_TYPE AES Key Type
212  * @{
213  */
214 #define AES_KEY_TYPE_MCU LL_AES_KEYTYPE_MCU /**< Fetch Key from MCU */
215 #define AES_KEY_TYPE_AHB LL_AES_KEYTYPE_AHB /**< Fetch Key from AHB */
216 #define AES_KEY_TYPE_KEYRAM LL_AES_KEYTYPE_KRAM /**< Fetch Key from KEYRAM */
217 /** @} */
218 
219 /** @defgroup AES_KEY_Mode AES Key Mode
220  * @{
221  */
222 #define AES_KEY_MODE_NORMAL LL_AES_KEYMODE_NORMAL /**< Normal Key mode */
223 #define AES_KEY_MODE_KEYWRAP LL_AES_KEYMODE_KEYWRAP /**< Key Wrapping mode */
224 /** @} */
225 
226 /** @defgroup AES_KEYSIZE AES Key Size
227  * @{
228  */
229 #define AES_KEYSIZE_128BITS LL_AES_KEY_SIZE_128 /**< 128 bits */
230 #define AES_KEYSIZE_192BITS LL_AES_KEY_SIZE_192 /**< 192 bits */
231 #define AES_KEYSIZE_256BITS LL_AES_KEY_SIZE_256 /**< 256 bits */
232 /** @} */
233 
234 /** @defgroup AES_DPA_MODE AES DPA Mode
235  * @{
236  */
237 #define AES_DPA_MODE_ENABLE (1U) /**< Enable DPA Mode */
238 #define AES_DPA_MODE_DISABLE (0U) /**< Disable DPA Mode */
239 /** @} */
240 
241 /** @defgroup AES_Block_Size AES Block Size
242  * @{
243  */
244 #define AES_BLOCK_MAX (2048U) /**< Block max size */
245 #define AES_BLOCKSIZE_BITS (128U) /**< Block size in bits */
246 #define AES_BLOCKSIZE_BYTES (AES_BLOCKSIZE_BITS >> 3) /**< Block size in bytes */
247 #define AES_BLOCKSIZE_WORDS (AES_BLOCKSIZE_BYTES >> 2) /**< Block size in words */
248 /** @} */
249 
250 /** @defgroup AES_Flags_definition AES Flags Definition
251  * @{
252  */
253 #define AES_FLAG_DATAREADY LL_AES_FLAG_DATAREADY /**< Data ready flag */
254 #define AES_FLAG_DMA_DONE LL_AES_FLAG_DMA_DONE /**< DMA transfer done flag */
255 #define AES_FLAG_DMA_ERR LL_AES_FLAG_DMA_ERR /**< DMA transfer error flag */
256 #define AES_FLAG_KEY_VALID LL_AES_FLAG_KEY_VALID /**< Key valid flag */
257 /** @} */
258 
259 /** @defgroup AES_Interrupt_definition AES Interrupt definition
260  * @{
261  */
262 #define AES_IT_DONE ((uint32_t)0x00000001) /**< AES Encrypted or Decrypted Data Done Interrupt source */
263 /** @} */
264 
265 /** @} */
266 
267 /* Exported macro ------------------------------------------------------------*/
268 /** @defgroup AES_Exported_Macros AES Exported Macros
269  * @{
270  */
271 
272 /** @brief Check whether the specified AES interrupt flag is set or not.
273  * @param __HANDLE__ Specifies the AES Handle.
274  * @param __FLAG__ Specifies the interrupt flag to check.
275  * This parameter can be the following value:
276  * @arg @ref AES_IT_DONE Encrypted or Decrypted Data Done Interrupt
277  * @retval The new state of __FLAG__ (TRUE or FALSE).
278  */
279 #define __HAL_AES_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INT, (__FLAG__)) == (__FLAG__))
280 
281 /** @brief Clear the specified AES interrupt flag.
282  * @param __HANDLE__ Specifies the AES interrupt Handle.
283  * @param __FLAG__ Specifies the flag to clear.
284  * This parameter can be the following value:
285  * @arg @ref AES_IT_DONE Encrypted or Decrypted Data Done Interrupt
286  * @retval None
287  */
288 #define __HAL_AES_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INT, (__FLAG__))
289 
290 /** @brief Check whether the specified AES flag is set or not.
291  * @param __HANDLE__ Specifies the AES Handle.
292  * @param __FLAG__ Specifies the flag to check.
293  * This parameter can be one of the following values:
294  * @arg @ref AES_FLAG_DATAREADY Data ready flag
295  * @arg @ref AES_FLAG_DMA_DONE DMA transfer done flag
296  * @arg @ref AES_FLAG_DMA_ERR DMA transfer error flag
297  * @arg @ref AES_FLAG_KEY_VALID Key valid flag
298  * @retval The new state of __FLAG__ (TRUE or FALSE).
299  */
300 #define __HAL_AES_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0U) ? SET : RESET)
301 
302 /** @} */
303 
304 /** @} */
305 
306 /* Exported functions --------------------------------------------------------*/
307 /** @addtogroup HAL_AES_DRIVER_FUNCTIONS Functions
308  * @{
309  */
310 
311 /** @addtogroup AES_Exported_Functions_Group1 Initialization and de-initialization functions
312  * @brief Initialization and Configuration functions
313  *
314 @verbatim
315  ===============================================================================
316  ##### Initialization and de-initialization functions #####
317  ===============================================================================
318  [..] This subsection provides a set of functions allowing to initialize and
319  de-initialize the AESx peripheral:
320 
321  (+) User must implement hal_aes_msp_init() function in which he configures
322  all related peripherals resources (GPIO, DMA, IT and NVIC ).
323 
324  (+) Call the function hal_aes_init() to configure the selected device with
325  the selected configuration:
326  (++) Key Type
327  (++) Key Size
328  (++) Key
329  (++) Key Address
330  (++) Key Mask
331  (++) init_vector
332  (++) DPA Mode
333  (++) Seed
334  (++) Endian Mode
335 
336  (+) Call the function hal_aes_deinit() to restore the default configuration
337  of the selected AESx peripheral.
338 
339 @endverbatim
340  * @{
341  */
342 
343 /**
344  ****************************************************************************************
345  * @brief Initialize the AES according to the specified parameters
346  * in the aes_init_t and initialize the associated handle.
347  *
348  * @param[in] p_aes: Pointer to an AES handle which contains the configuration
349  * information for the specified AES module.
350  *
351  * @retval ::HAL_OK: Operation is OK.
352  * @retval ::HAL_ERROR: Parameter error or operation not supported.
353  * @retval ::HAL_BUSY: Driver is busy.
354  * @retval ::HAL_TIMEOUT: Timeout occurred.
355  ****************************************************************************************
356  */
358 
359 /**
360  ****************************************************************************************
361  * @brief De-initialize the AES peripheral.
362  *
363  * @param[in] p_aes: Pointer to an AES handle which contains the configuration
364  * information for the specified AES module.
365  *
366  * @retval ::HAL_OK: Operation is OK.
367  * @retval ::HAL_ERROR: Parameter error or operation not supported.
368  * @retval ::HAL_BUSY: Driver is busy.
369  * @retval ::HAL_TIMEOUT: Timeout occurred.
370  ****************************************************************************************
371  */
373 
374 /**
375  ****************************************************************************************
376  * @brief Initialize the AES MSP.
377  *
378  * @note This function should not be modified. When the callback is needed,
379  * the hal_aes_msp_deinit can be implemented in the user file.
380  *
381  * @param[in] p_aes: Pointer to an AES handle which contains the configuration
382  * information for the specified AES module.
383  ****************************************************************************************
384  */
386 
387 /**
388  ****************************************************************************************
389  * @brief De-initialize the AES MSP.
390  *
391  * @note This function should not be modified. When the callback is needed,
392  * the hal_aes_msp_deinit can be implemented in the user file.
393  *
394  * @param[in] p_aes: Pointer to an AES handle which contains the configuration
395  * information for the specified AES module.
396  ****************************************************************************************
397  */
399 
400 /** @} */
401 
402 /** @addtogroup AES_Exported_Functions_Group2 AES operation functions
403  * @brief AES Encrypt/Decrypt functions
404  *
405 @verbatim
406  ===============================================================================
407  ##### AES operation functions #####
408  ===============================================================================
409  This subsection provides a set of functions allowing to manage the AES encrypt or decrypt.
410 
411  (#) There are two mode of transfer:
412  (++) Blocking mode: The communication is performed in polling mode.
413  The HAL status of all data processing are returned by the same function
414  after finishing transfer.
415  (++) Non-Blocking mode: The communication is performed using Interrupts
416  or DMA. These API return the HAL status.
417  The end of the data processing will be indicated through the
418  dedicated AES IRQ when using Interrupt mode or the DMA IRQ when
419  using DMA mode.
420  The hal_aes_done_callback() user callbacks will be executed respectively
421  at the end of the encrypt or decrypt process
422  The hal_aes_error_callback() user callback will be executed when a error is detected
423 
424  (#) Blocking mode API's are :
425  (++) hal_aes_ecb_encrypt()
426  (++) hal_aes_ecb_decrypt()
427  (++) hal_aes_cbc_encrypt()
428  (++) hal_aes_cbc_decrypt()
429 
430  (#) Non-Blocking mode API's with Interrupt are :
431  (++) hal_aes_ecb_encrypt_it()
432  (++) hal_aes_ecb_decrypt_it()
433  (++) hal_aes_cbc_encrypt_it()
434  (++) hal_aes_cbc_decrypt_it()
435 
436  (#) Non-Blocking mode API's with DMA are :
437  (++) hal_aes_ecb_encrypt_dma()
438  (++) hal_aes_ecb_decrypt_dma()
439  (++) hal_aes_cbc_encrypt_dma()
440  (++) hal_aes_cbc_decrypt_dma()
441 
442  (#) A set of encrypt or decrypt Callbacks are provided in Non_Blocking mode:
443  (++) hal_aes_done_callback()
444  (++) hal_aes_error_callback()
445 
446 @endverbatim
447  * @{
448  */
449 
450 /**
451  ****************************************************************************************
452  * @brief Encrypted an amount of data in blocking mode in ECB mode.
453  *
454  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
455  * the specified AES module.
456  * @param[in] p_plain_data: Pointer to plain data buffer
457  * @param[in] number: Amount of data to be decrypted in bytes
458  * @param[out] p_cypher_data: Pointer to cypher data buffer
459  * @param[in] timeout: Timeout duration
460  *
461  * @retval ::HAL_OK: Operation is OK.
462  * @retval ::HAL_ERROR: Parameter error or operation not supported.
463  * @retval ::HAL_BUSY: Driver is busy.
464  * @retval ::HAL_TIMEOUT: Timeout occurred.
465  ****************************************************************************************
466  */
467 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);
468 
469 /**
470  ****************************************************************************************
471  * @brief Decrypted an amount of data in blocking mode in ECB mode.
472  *
473  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
474  * the specified AES module.
475  * @param[in] p_cypher_data: Pointer to cypher data buffer
476  * @param[in] number: Amount of data to be decrypted in bytes
477  * @param[out] p_plain_data: Pointer to plain data buffer
478  * @param[in] timeout: Timeout duration
479  *
480  * @retval ::HAL_OK: Operation is OK.
481  * @retval ::HAL_ERROR: Parameter error or operation not supported.
482  * @retval ::HAL_BUSY: Driver is busy.
483  * @retval ::HAL_TIMEOUT: Timeout occurred.
484  ****************************************************************************************
485  */
486 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);
487 
488 /**
489  ****************************************************************************************
490  * @brief Encrypted an amount of data in blocking mode in CBC mode.
491  *
492  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
493  * the specified AES module.
494  * @param[in] p_plain_data: Pointer to plain data buffer
495  * @param[in] number: Amount of data to be decrypted in bytes
496  * @param[out] p_cypher_data: Pointer to cypher data buffer
497  * @param[in] timeout: Timeout duration
498  *
499  * @retval ::HAL_OK: Operation is OK.
500  * @retval ::HAL_ERROR: Parameter error or operation not supported.
501  * @retval ::HAL_BUSY: Driver is busy.
502  * @retval ::HAL_TIMEOUT: Timeout occurred.
503  ****************************************************************************************
504  */
505 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);
506 
507 /**
508  ****************************************************************************************
509  * @brief Decrypted an amount of data in blocking mode in CBC mode.
510  *
511  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
512  * the specified AES module.
513  * @param[in] p_cypher_data: Pointer to cypher data buffer
514  * @param[in] number: Amount of data to be decrypted in bytes
515  * @param[out] p_plain_data: Pointer to plain data buffer
516  * @param[in] timeout: Timeout duration
517  *
518  * @retval ::HAL_OK: Operation is OK.
519  * @retval ::HAL_ERROR: Parameter error or operation not supported.
520  * @retval ::HAL_BUSY: Driver is busy.
521  * @retval ::HAL_TIMEOUT: Timeout occurred.
522  ****************************************************************************************
523  */
524 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);
525 
526 /**
527  ****************************************************************************************
528  * @brief Encrypted an amount of data in non-blocking mode with Interrupt in ECB mode.
529  *
530  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
531  * the specified AES module.
532  * @param[in] p_plain_data: Pointer to plain data buffer
533  * @param[in] number: Amount of data to be decrypted in bytes
534  * @param[out] p_cypher_data: Pointer to cypher data buffer
535  *
536  * @retval ::HAL_OK: Operation is OK.
537  * @retval ::HAL_ERROR: Parameter error or operation not supported.
538  * @retval ::HAL_BUSY: Driver is busy.
539  * @retval ::HAL_TIMEOUT: Timeout occurred.
540  ****************************************************************************************
541  */
542 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);
543 
544 /**
545  ****************************************************************************************
546  * @brief Decrypted an amount of data in non-blocking mode with Interrupt in ECB mode.
547  *
548  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
549  * the specified AES module.
550  * @param[in] p_cypher_data: Pointer to cypher data buffer
551  * @param[in] number: Amount of data to be decrypted in bytes
552  * @param[out] p_plain_data: Pointer to plain data buffer
553  *
554  * @retval ::HAL_OK: Operation is OK.
555  * @retval ::HAL_ERROR: Parameter error or operation not supported.
556  * @retval ::HAL_BUSY: Driver is busy.
557  * @retval ::HAL_TIMEOUT: Timeout occurred.
558  ****************************************************************************************
559  */
560 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);
561 
562 /**
563  ****************************************************************************************
564  * @brief Encrypted an amount of data in non-blocking mode with Interrupt in CBC mode.
565  *
566  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
567  * the specified AES module.
568  * @param[in] p_plain_data: Pointer to plain data buffer
569  * @param[in] number: Amount of data to be decrypted in bytes
570  * @param[out] p_cypher_data: Pointer to cypher data buffer
571  *
572  * @retval ::HAL_OK: Operation is OK.
573  * @retval ::HAL_ERROR: Parameter error or operation not supported.
574  * @retval ::HAL_BUSY: Driver is busy.
575  * @retval ::HAL_TIMEOUT: Timeout occurred.
576  ****************************************************************************************
577  */
578 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);
579 
580 /**
581  ****************************************************************************************
582  * @brief Decrypted an amount of data in non-blocking mode with Interrupt in CBC mode.
583  *
584  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
585  * the specified AES module.
586  * @param[in] p_cypher_data: Pointer to cypher data buffer
587  * @param[in] number: Amount of data to be decrypted in bytes
588  * @param[out] p_plain_data: Pointer to plain data buffer
589  *
590  * @retval ::HAL_OK: Operation is OK.
591  * @retval ::HAL_ERROR: Parameter error or operation not supported.
592  * @retval ::HAL_BUSY: Driver is busy.
593  * @retval ::HAL_TIMEOUT: Timeout occurred.
594  ****************************************************************************************
595  */
596 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);
597 
598 /**
599  ****************************************************************************************
600  * @brief Encrypted an amount of data in non-blocking mode with DMA in ECB mode.
601  *
602  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
603  * the specified AES module.
604  * @param[in] p_plain_data: Pointer to plain data buffer
605  * @param[in] number: Amount of data to be decrypted in bytes
606  * @param[out] p_cypher_data: Pointer to cypher data buffer
607  *
608  * @retval ::HAL_OK: Operation is OK.
609  * @retval ::HAL_ERROR: Parameter error or operation not supported.
610  * @retval ::HAL_BUSY: Driver is busy.
611  * @retval ::HAL_TIMEOUT: Timeout occurred.
612  ****************************************************************************************
613  */
614 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);
615 
616 /**
617  ****************************************************************************************
618  * @brief Decrypted an amount of data in non-blocking mode with DMA in ECB mode.
619  *
620  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
621  * the specified AES module.
622  * @param[in] p_cypher_data: Pointer to cypher data buffer
623  * @param[in] number: Amount of data to be decrypted in bytes
624  * @param[out] p_plain_data: Pointer to plain data buffer
625  *
626  * @retval ::HAL_OK: Operation is OK.
627  * @retval ::HAL_ERROR: Parameter error or operation not supported.
628  * @retval ::HAL_BUSY: Driver is busy.
629  * @retval ::HAL_TIMEOUT: Timeout occurred.
630  ****************************************************************************************
631  */
632 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);
633 
634 /**
635  ****************************************************************************************
636  * @brief Encrypted an amount of data in non-blocking mode with DMA in CBC mode.
637  *
638  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
639  * the specified AES module.
640  * @param[in] p_plain_data: Pointer to plain data buffer
641  * @param[in] number: Amount of data to be decrypted in bytes
642  * @param[out] p_cypher_data: Pointer to cypher data buffer
643  *
644  * @retval ::HAL_OK: Operation is OK.
645  * @retval ::HAL_ERROR: Parameter error or operation not supported.
646  * @retval ::HAL_BUSY: Driver is busy.
647  * @retval ::HAL_TIMEOUT: Timeout occurred.
648  ****************************************************************************************
649  */
650 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);
651 
652 /**
653  ****************************************************************************************
654  * @brief Decrypted an amount of data in non-blocking mode with DMA in CBC mode.
655  *
656  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
657  * the specified AES module.
658  * @param[in] p_cypher_data: Pointer to cypher data buffer
659  * @param[in] number: Amount of data to be decrypted in bytes
660  * @param[out] p_plain_data: Pointer to plain data buffer
661  *
662  * @retval ::HAL_OK: Operation is OK.
663  * @retval ::HAL_ERROR: Parameter error or operation not supported.
664  * @retval ::HAL_BUSY: Driver is busy.
665  * @retval ::HAL_TIMEOUT: Timeout occurred.
666  ****************************************************************************************
667  */
668 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);
669 
670 /** @} */
671 
672 /** @addtogroup AES_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
673  * @brief IRQ Handler and Callbacks functions
674  * @{
675  */
676 
677 /**
678  ****************************************************************************************
679  * @brief Handle AES interrupt request.
680  *
681  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
682  * the specified the specified AES module.
683  ****************************************************************************************
684  */
686 
687 /**
688  ****************************************************************************************
689  * @brief Encrypt or decrypt Done callback.
690  *
691  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
692  * the specified AES module.
693  ****************************************************************************************
694  */
696 
697 /**
698  ****************************************************************************************
699  * @brief AES error callback.
700  *
701  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
702  * the specified AES module.
703  ****************************************************************************************
704  */
706 
707 /** @} */
708 
709 /** @defgroup AES_Exported_Functions_Group3 Peripheral State and Errors functions
710  * @brief AES State and Errors functions
711  *
712 @verbatim
713  ===============================================================================
714  ##### Peripheral State and Errors functions #####
715  ===============================================================================
716  [..]
717  This subsection provides a set of functions allowing to control the AES.
718  (+) hal_aes_get_state() API can be helpful to check in run-time the state of the AES peripheral.
719  (+) hal_aes_get_error() check in run-time Errors occurring during communication.
720 @endverbatim
721  * @{
722  */
723 
724 /**
725  ****************************************************************************************
726  * @brief Return the AES handle state.
727  *
728  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
729  * the specified AES module.
730  *
731  * @retval ::HAL_AES_STATE_RESET: Peripheral not initialized.
732  * @retval ::HAL_AES_STATE_READY: Peripheral initialized and ready for use.
733  * @retval ::HAL_AES_STATE_BUSY: Peripheral in indirect mode and busy.
734  ****************************************************************************************
735  */
737 
738 /**
739  ****************************************************************************************
740  * @brief Return the AES error code.
741  *
742  * @param[in] p_aes: Pointer to an AES handle which contains the configuration information for
743  * the specified AES module.
744  *
745  * @return AES error code in bitmap format
746  ****************************************************************************************
747  */
749 
750 /** @} */
751 
752 /** @} */
753 
754 #ifdef __cplusplus
755 }
756 #endif
757 
758 #endif /* __GR5XX_HAL_AES_H__ */
759 
760 /** @} */
761 
762 /** @} */
763 
764 /** @} */
_aes_handle::operation_mode
uint32_t operation_mode
Definition: hal_aes.h:132
hal_aes_msp_deinit
void hal_aes_msp_deinit(aes_handle_t *p_aes)
De-initialize the AES MSP.
ll_misc.h
Header file containing functions prototypes of MISC LL library.
_hal_aes_callback::aes_msp_deinit
void(* aes_msp_deinit)(aes_handle_t *p_aes)
Definition: hal_aes.h:160
HAL_AES_STATE_RESET
@ HAL_AES_STATE_RESET
Definition: hal_aes.h:79
_hal_aes_callback::aes_msp_init
void(* aes_msp_init)(aes_handle_t *p_aes)
Definition: hal_aes.h:159
_hal_aes_callback::aes_done_callback
void(* aes_done_callback)(aes_handle_t *p_aes)
Definition: hal_aes.h:162
hal_aes_ecb_encrypt_it
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.
_aes_init::p_seed
uint32_t * p_seed
Definition: hal_aes.h:114
_aes_init::p_key
uint32_t * p_key
Definition: hal_aes.h:107
hal_aes_get_error
uint32_t hal_aes_get_error(aes_handle_t *p_aes)
Return the AES error code.
aes_handle_t
struct _aes_handle aes_handle_t
AES handle Structure definition.
hal_aes_callback_t
struct _hal_aes_callback hal_aes_callback_t
HAL AES Callback function definition.
hal_aes_ecb_encrypt
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.
hal_aes_msp_init
void hal_aes_msp_init(aes_handle_t *p_aes)
Initialize the AES MSP.
_aes_handle::error_code
__IO uint32_t error_code
Definition: hal_aes.h:139
hal_aes_cbc_encrypt_dma
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.
hal_aes_init
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...
hal_aes_irq_handler
void hal_aes_irq_handler(aes_handle_t *p_aes)
Handle AES interrupt request.
_aes_init::key_mask
uint32_t key_mask
Definition: hal_aes.h:109
hal_aes_cbc_encrypt_it
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.
_aes_handle::chaining_mode
uint32_t chaining_mode
Definition: hal_aes.h:133
hal_aes_get_state
hal_aes_state_t hal_aes_get_state(aes_handle_t *p_aes)
Return the AES handle state.
HAL_AES_STATE_READY
@ HAL_AES_STATE_READY
Definition: hal_aes.h:80
_aes_init::p_init_vector
uint32_t * p_init_vector
Definition: hal_aes.h:111
_aes_init
AES Init Structure definition.
Definition: hal_aes.h:100
_aes_handle::state
__IO hal_aes_state_t state
Definition: hal_aes.h:138
hal_aes_cbc_decrypt
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.
aes_init_t
struct _aes_init aes_init_t
AES Init Structure definition.
hal_aes_ecb_decrypt
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.
_aes_init::endian_mode
uint32_t endian_mode
Definition: hal_aes.h:115
_aes_init::key_mode
uint32_t key_mode
Definition: hal_aes.h:101
_hal_aes_callback::aes_abort_cplt_callback
void(* aes_abort_cplt_callback)(aes_handle_t *p_aes)
Definition: hal_aes.h:163
hal_aes_ecb_encrypt_dma
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_handle::init
aes_init_t init
Definition: hal_aes.h:131
_hal_aes_callback
HAL AES Callback function definition.
Definition: hal_aes.h:158
_aes_handle::keyram_offset
uint32_t keyram_offset
Definition: hal_aes.h:137
_aes_handle::p_instance
aes_regs_t * p_instance
Definition: hal_aes.h:130
_aes_init::key_addr
uint32_t key_addr
Definition: hal_aes.h:108
_aes_init::key_type
uint32_t key_type
Definition: hal_aes.h:103
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr_common.h:140
hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_aes_handle
AES handle Structure definition.
Definition: hal_aes.h:129
hal_aes_cbc_decrypt_dma
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_aes_deinit
hal_status_t hal_aes_deinit(aes_handle_t *p_aes)
De-initialize the AES peripheral.
_aes_init::dpa_mode
uint32_t dpa_mode
Definition: hal_aes.h:112
_aes_init::key_size
uint32_t key_size
Definition: hal_aes.h:105
_aes_init::key_slot
uint32_t key_slot
Definition: hal_aes.h:110
_aes_handle::block_size
uint32_t block_size
Definition: hal_aes.h:136
hal_aes_ecb_decrypt_dma
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_t
HAL AES State Enumerations definition.
Definition: hal_aes.h:78
hal_aes_cbc_encrypt
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.
_aes_handle::p_cryp_output_buffer
uint32_t * p_cryp_output_buffer
Definition: hal_aes.h:135
hal_aes_ecb_decrypt_it
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.
_hal_aes_callback::aes_error_callback
void(* aes_error_callback)(aes_handle_t *p_aes)
Definition: hal_aes.h:161
HAL_AES_STATE_BUSY
@ HAL_AES_STATE_BUSY
Definition: hal_aes.h:81
hal_aes_error_callback
void hal_aes_error_callback(aes_handle_t *p_aes)
AES error callback.
_aes_handle::p_cryp_input_buffer
uint32_t * p_cryp_input_buffer
Definition: hal_aes.h:134
hal_aes_done_callback
void hal_aes_done_callback(aes_handle_t *p_aes)
Encrypt or decrypt Done callback.
hal_aes_cbc_decrypt_it
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.
ll_aes.h
Header file containing functions prototypes of AES LL library.