Goodix
GR551x API Reference  V1_6_06_B5676
gr55xx_hal_hmac.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_hmac.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of HMAC 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_HMAC HMAC
47  * @brief HMAC HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_HMAC_H__
53 #define __GR55xx_HAL_HMAC_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_hmac.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_HMAC_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /** @defgroup HAL_HMAC_state HAL HMAC state
69  * @{
70  */
71 
72 /**
73  * @brief HAL HMAC State enumerations definition
74  * @note HAL HMAC State value is a combination of 2 different substates: gState and RxState.
75  */
76 typedef enum
77 {
78  HAL_HMAC_STATE_RESET = 0x00, /**< Peripheral not initialized */
79  HAL_HMAC_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
80  HAL_HMAC_STATE_BUSY = 0x02, /**< Peripheral in indirect mode and busy */
81  HAL_HMAC_STATE_ERROR = 0x03, /**< Peripheral in error */
82  HAL_HMAC_STATE_TIMEOUT = 0x04, /**< Peripheral in timeout */
83  HAL_HMAC_STATE_SUSPENDED = 0x05, /**< Peripheral in suspended */
84 
86 
87 /** @} */
88 
89 /** @} */
90 
91 /** @addtogroup HAL_HMAC_STRUCTURES Structures
92  * @{
93  */
94 
95 /** @defgroup HMAC_Configuration HMAC Configuration
96  * @{
97  */
98 
99 /**
100  * @brief HMAC init Structure definition
101  */
102 typedef struct _hmac_init
103 {
104  uint32_t mode; /**< Operating mode */
105 
106  uint32_t *p_key; /**< Encryption/Decryption Key */
107 
108  uint32_t *p_user_hash; /**< Initialization HASH value */
109 
110  uint32_t key_fetch_type; /**< @ref HAL_HMAC_KEYTYPE_MCU Fetch key from ram;
111  { Start_private
112  @ref HAL_HMAC_KEYTYPE_AHB Fetch key from AHB;
113  } End_private
114  @ref HAL_HMAC_KEYTYPE_KRAM Fetch key from keyport */
115  uint32_t dpa_mode; /**< DPA Mode */
116  uint32_t enable_irq; /**< Ctrl IRQ when MCU mode */
117  uint32_t enable_dma_mode; /**< Enable mode */
118 
120 /** @} */
121 
122 /** @defgroup HMAC_handle HMAC handle
123  * @{
124  */
125 
126 /**
127  * @brief HMAC handle Structure definition
128  */
129 typedef struct _hmac_handle
130 {
131  hmac_regs_t *p_instance; /**< HMAC registers base address */
132 
133  hmac_init_t init; /**< HMAC operation parameters */
134 
135  uint32_t *p_message; /**< Pointer to message input buffer */
136 
137  uint32_t *p_digest; /**< Pointer to digest output buffer */
138 
139  uint32_t block_size; /**< Data size in blocks (64 bytes per block) */
140 
141  uint32_t block_count; /**< Blocks count */
142 
143  uint32_t is_last_trans; /**< Flag for last transfer */
144 
145  __IO hal_lock_t lock; /**< Locking object */
146 
147  __IO hal_hmac_state_t state; /**< HMAC operation state */
148 
149  __IO uint32_t error_code; /**< HMAC Error code */
150 
151  uint32_t timeout; /**< Timeout for the HMAC operation */
152 
153  uint32_t retention[17]; /**< HMAC important register information. */
154 
156 
157 /** @} */
158 
159 /** @} */
160 
161 /** @addtogroup HAL_HMAC_CALLBACK_STRUCTURES Callback Structures
162  * @{
163  */
164 
165 /** @defgroup HAL_HMAC_Callback Callback
166  * @{
167  */
168 
169 /**
170  * @brief HAL_HMAC Callback function definition
171  */
172 
173 typedef struct _hal_hmac_callback
174 {
175  void (*hmac_msp_init)(hmac_handle_t *p_hmac); /**< HMAC init MSP callback */
176  void (*hmac_msp_deinit)(hmac_handle_t *p_hmac); /**< HMAC de-init MSP callback */
177  void (*hmac_done_callback)(hmac_handle_t *p_hmac); /**< HMAC digest done callback */
178  void (*hmac_error_callback)(hmac_handle_t *p_hmac); /**< HMAC error callback */
180 
181 /** @} */
182 
183 /** @} */
184 
185 /**
186  * @defgroup HAL_HMAC_MACRO Defines
187  * @{
188  */
189 
190 /* Exported constants --------------------------------------------------------*/
191 /** @defgroup HMAC_Exported_Constants HMAC Exported Constants
192  * @{
193  */
194 
195 /** @defgroup HMAC_Error_Code HMAC Error Code
196  * @{
197  */
198 #define HAL_HMAC_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
199 #define HAL_HMAC_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
200 #define HAL_HMAC_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
201 #define HAL_HMAC_ERROR_INVALID_PARAM ((uint32_t)0x00000004) /**< Invalid parameters error */
202 /** @} */
203 
204 /** @defgroup HMAC_Mode HMAC Mode
205  * @{
206  */
207 #define HMAC_MODE_SHA LL_HMAC_CALCULATETYPE_SHA /**< SHA mode */
208 #define HMAC_MODE_HMAC LL_HMAC_CALCULATETYPE_HMAC /**< HMAC mode */
209 /** @} */
210 
211 /** @defgroup HMAC_Block_Size HAMC Block Size
212  * @{
213  */
214 #define HMAC_BLOCK_MAX (512) /**< Block max size */
215 #define HMAC_BLOCKSIZE_BITS (512) /**< Block size in bits */
216 #define HMAC_BLOCKSIZE_BYTES (HMAC_BLOCKSIZE_BITS >> 3) /**< Block size in bytes */
217 #define HMAC_BLOCKSIZE_WORDS (HMAC_BLOCKSIZE_BYTES >> 2) /**< Block size in words */
218 #define HMAC_DIGESTSIZE_BITS (256) /**< Digest size in bits */
219 #define HMAC_DIGESTSIZE_BYTES (HMAC_DIGESTSIZE_BITS >> 3) /**< Digest size in bytes */
220 #define HMAC_DIGESTSIZE_WORDS (HMAC_DIGESTSIZE_BYTES >> 2) /**< Digest size in words */
221 #define HMAC_DMA_BLOCK_MAX (512) /**< DMA Block max size */
222 /** @} */
223 
224 /** @defgroup HMAC_Flags_definition HAMC Flags Definition
225  * @{
226  */
227 #define HMAC_FLAG_DATAREADY_SHA LL_HMAC_FLAG_DATAREADY_SHA /**< HMAC data ready (SHA mode) */
228 #define HMAC_FLAG_DATAREADY_HMAC LL_HMAC_FLAG_DATAREADY_HMAC /**< HMAC data ready (HAMC mode) */
229 #define HMAC_FLAG_DMA_MESSAGEDONE LL_HMAC_FLAG_DMA_MESSAGEDONE /**< HMAC DMA message done */
230 #define HMAC_FLAG_DMA_DONE LL_HMAC_FLAG_DMA_DONE /**< HMAC DMA transfer done */
231 #define HMAC_FLAG_DMA_ERR LL_HMAC_FLAG_DMA_ERR /**< HMAC DMA transfer error */
232 #define HMAC_FLAG_KEY_VALID LL_HMAC_FLAG_KEY_VALID /**< HMAC has fetched key */
233 /** @} */
234 
235 /** @defgroup HMAC_HAL_KEY_TYPE Key Type
236  * @{
237  */
238 #define HAL_HMAC_KEYTYPE_MCU LL_HMAC_KEYTYPE_MCU /**< Key from MCU */
239 /* { Start_private */
240 #define HAL_HMAC_KEYTYPE_AHB LL_HMAC_KEYTYPE_AHB /**< Key from AHB master */
241 /* } End_private */
242 #define HAL_HMAC_KEYTYPE_KRAM LL_HMAC_KEYTYPE_KRAM /**< Key from Key Port */
243 /** @} */
244 
245 /** @defgroup HMAC_HAL_CTRL_IRQ Ctrl Irq
246  * @{
247  */
248 #define HAL_HMAC_ENABLE_IRQ (0x1) /**< Enable IRQ */
249 #define HAL_HMAC_DISABLE_IRQ (0x0) /**< Disable IRQ */
250 /** @} */
251 
252 /** @defgroup HMAC_HAL_CTRL_DMA Ctrl DMA
253  * @{
254  */
255 #define HAL_HMAC_ENABLE_DMA (0x1) /**< Enable DMA */
256 #define HAL_HMAC_DISABLE_DMA (0x0) /**< Enable DMA */
257 /** @} */
258 
259 /** @defgroup HMAC_Interrupt_definition HMAC Interrupt_definition
260  * @{
261  */
262 #define HMAC_IT_DONE ((uint32_t)0x00000001) /**< Operation Done Interrupt source */
263 /** @} */
264 
265 /** @defgroup HMAC_Timeout_definition HMAC Timeout_definition
266  * @{
267  */
268 #define HAL_HMAC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
269 /** @} */
270 
271 /** @} */
272 
273 /* Exported macro ------------------------------------------------------------*/
274 /** @defgroup HMAC_Exported_Macros HMAC Exported Macros
275  * @{
276  */
277 
278 /** @brief Reset HMAC handle states.
279  * @param __HANDLE__ HMAC handle.
280  * @retval None
281  */
282 #define __HAL_HMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_HMAC_STATE_RESET)
283 
284 /** @brief Enable the specified HMAC peripheral.
285  * @param __HANDLE__ Specifies the HMAC Handle.
286  * @retval None
287  */
288 #define __HAL_HMAC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_ENABLE)
289 
290 /** @brief Disable the specified HMAC peripheral.
291  * @param __HANDLE__ Specifies the HMAC Handle.
292  * @retval None
293  */
294 #define __HAL_HMAC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_ENABLE)
295 
296 /** @brief Enable the HMAC interrupt.
297  * @param __HANDLE__ Specifies the HMAC Handle.
298  * @retval None
299  */
300 #define __HAL_HMAC_ENABLE_IT(__HANDLE__) ll_hmac_enable_it_done((__HANDLE__)->p_instance)
301 
302 /** @brief Disable the HMAC interrupt.
303  * @param __HANDLE__ Specifies the HMAC Handle.
304  * @retval None
305  */
306 #define __HAL_HMAC_DISABLE_IT(__HANDLE__) ll_hmac_disable_it_done((__HANDLE__)->p_instance)
307 
308 /** @brief Check whether the specified HMAC interrupt flag is set or not.
309  * @param __HANDLE__ Specifies the HMAC Handle.
310  * @param __FLAG__ Specifies the interrupt flag to check.
311  * This parameter can be one of the following values:
312  * @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
313  * @retval The new state of __FLAG__ (TRUE or FALSE).
314  */
315 #define __HAL_HMAC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__)) == (__FLAG__))
316 
317 /** @brief Clear the specified HMAC interrupt flag.
318  * @param __HANDLE__ Specifies the HMAC interrupt Handle.
319  * @param __FLAG__ Specifies the flag to clear.
320  * This parameter can be one of the following values:
321  * @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
322  * @retval None
323  */
324 #define __HAL_HMAC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INTERRUPT, (__FLAG__))
325 
326 /** @brief Check whether the specified HMAC flag is set or not.
327  * @param __HANDLE__ Specifies the HMAC Handle.
328  * @param __FLAG__ Specifies the flag to check.
329  * This parameter can be one of the following values:
330  * @arg @ref HMAC_FLAG_DATAREADY_SHA Data ready (SHA mode) flag
331  * @arg @ref HMAC_FLAG_DATAREADY_HMAC Data ready (HMAC mode) flag
332  * @arg @ref HMAC_FLAG_DMA_DONE DMA transfer done flag
333  * @arg @ref HMAC_FLAG_DMA_ERR DMA transfer error flag
334  * @arg @ref HMAC_FLAG_KEY_VALID Key valid flag
335  * @retval The new state of __FLAG__ (TRUE or FALSE).
336  */
337 #define __HAL_HMAC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STATUS, (__FLAG__)) != 0) ? SET : RESET)
338 
339 /** @} */
340 
341 /** @} */
342 
343 /* Exported functions --------------------------------------------------------*/
344 /** @addtogroup HAL_HMAC_DRIVER_FUNCTIONS Functions
345  * @{
346  */
347 
348 /** @addtogroup HMAC_Exported_Functions_Group1 Initialization and de-initialization functions
349  * @brief Initialization and de-initialization functions
350  *
351 @verbatim
352  ===============================================================================
353  ##### Initialization and de-initialization functions #####
354  ===============================================================================
355  [..] This subsection provides a set of functions allowing to initialize and
356  de-initialize the HMACx peripheral:
357 
358  (+) User must implement hal_hmac_msp_init() function in which he configures
359  all related peripherals resources (GPIO, DMA, IT and NVIC ).
360 
361  (+) Call the function hal_hmac_init() to configure the selected device with
362  the selected configuration:
363  (++) mode
364  (++) key
365  (++) user_hash
366  (++) dpa_mode
367 
368  (+) Call the function hal_hmac_deinit() to restore the default configuration
369  of the selected HMACx peripheral.
370 
371 @endverbatim
372  * @{
373  */
374 
375 /**
376  ****************************************************************************************
377  * @brief Initialize the HMAC according to the specified parameters
378  * in the hmac_init_t and initialize the associated handle.
379  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
380  * @retval ::HAL_OK: Operation is OK.
381  * @retval ::HAL_ERROR: Parameter error or operation not supported.
382  * @retval ::HAL_BUSY: Driver is busy.
383  * @retval ::HAL_TIMEOUT: Timeout occurred.
384  ****************************************************************************************
385  */
387 
388 /**
389  ****************************************************************************************
390  * @brief De-initialize the HMAC peripheral.
391  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
392  * @retval ::HAL_OK: Operation is OK.
393  * @retval ::HAL_ERROR: Parameter error or operation not supported.
394  * @retval ::HAL_BUSY: Driver is busy.
395  * @retval ::HAL_TIMEOUT: Timeout occurred.
396  ****************************************************************************************
397  */
399 
400 /**
401  ****************************************************************************************
402  * @brief Initialize the HMAC MSP.
403  * @note This function should not be modified. When the callback is needed,
404  the hal_hmac_msp_deinit can be implemented in the user file.
405  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
406  ****************************************************************************************
407  */
409 
410 /**
411  ****************************************************************************************
412  * @brief De-initialize the HMAC MSP.
413  * @note This function should not be modified. When the callback is needed,
414  the HAL_HMAC_MspDeInit can be implemented in the user file.
415  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
416  ****************************************************************************************
417  */
419 
420 /** @} */
421 
422 /** @addtogroup HMAC_Exported_Functions_Group2 IO operation functions
423  * @brief HMAC Encrypt/Decrypt functions
424  *
425 @verbatim
426  ===============================================================================
427  ##### IO operation functions #####
428  ===============================================================================
429  This subsection provides a set of functions allowing to manage the HMAC encrypt or decrypt.
430 
431  (#) There are two mode of transfer:
432  (++) Blocking mode: The communication is performed in polling mode.
433  The HAL status of all data processing is returned by the same function
434  after finishing transfer.
435  (++) Non-Blocking mode: The communication is performed using Interrupts
436  or DMA, These API's return the HAL status.
437  The end of the data processing will be indicated through the
438  dedicated HMAC IRQ when using Interrupt mode or the DMA IRQ when
439  using DMA mode.
440  The hal_hmac_done_callback() user callbacks will be executed respectively
441  at the end of the encrypt or decrypt process
442  The hal_hmac_error_callback() user callback will be executed when a error is detected
443 
444  (#) Blocking mode API's are :
445  (++) hal_sha256_digest()
446  (++) hal_hmac_sha256_digest_start()
447  (++) hal_hmac_sha256_digest_continue()
448  (++) hal_hmac_sha256_digest_finish()
449 
450  (#) Non-Blocking mode API's with Interrupt are :
451  (++) hal_sha256_digest_it()
452  (++) hal_hmac_sha256_digest_start_it()
453  (++) hal_hmac_sha256_digest_continue_it()
454  (++) hal_hmac_sha256_digest_finish_it()
455 
456  (#) Non-Blocking mode API's with DMA are :
457  (++) hal_sha256_digest_dma()
458  (++) hal_hmac_sha256_digest_start_dma()
459  (++) hal_hmac_sha256_digest_continue_dma()
460  (++) hal_hmac_sha256_digest_finish_dma()
461 
462  (#) A set of encrypt or decrypt Callbacks are provided in Non_Blocking mode:
463  (++) hal_hmac_done_callback()
464  (++) hal_hmac_error_callback()
465 
466  (#) Non-Blocking mode transfers could be aborted using Abort API's :
467  (++) hal_hmac_abort()
468  (++) hal_hmac_abort_it()
469 
470  (#) For Abort services based on interrupts (HAL_HMAC_Abortxxx_IT), Abort Complete Callback is provided:
471  (++) hal_hmac_abort_cplt_callback()
472 
473 @endverbatim
474  * @{
475  */
476 
477 /**
478  ****************************************************************************************
479  * @brief xxx in blocking mode in SHA mode.
480  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
481  * @param[in] p_message: Pointer to message buffer
482  * @param[in] number: Amount of data
483  * @param[out] p_digest: Pointer to digest buffer
484  * @param[in] timeout: Timeout duration
485  * @retval ::HAL_OK: Operation is OK.
486  * @retval ::HAL_ERROR: Parameter error or operation not supported.
487  * @retval ::HAL_BUSY: Driver is busy.
488  * @retval ::HAL_TIMEOUT: Timeout occurred.
489  ****************************************************************************************
490  */
491 hal_status_t hal_hmac_sha256_digest(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest, uint32_t timeout);
492 
493 /** @} */
494 
495 /** @addtogroup HMAC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
496  * @brief IRQ Handler and Callbacks functions
497  * @{
498  */
499 
500 /**
501  ****************************************************************************************
502  * @brief Handle HMAC interrupt request.
503  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
504  ****************************************************************************************
505  */
507 
508 /**
509  ****************************************************************************************
510  * @brief Digest Done callback.
511  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
512  ****************************************************************************************
513  */
515 
516 /**
517  ****************************************************************************************
518  * @brief HMAC error callback.
519  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
520  ****************************************************************************************
521  */
523 
524 /** @} */
525 
526 /** @defgroup HMAC_Exported_Functions_Group3 Peripheral State and Errors functions
527  * @brief HMAC control functions
528  *
529 @verbatim
530  ===============================================================================
531  ##### Peripheral State and Errors functions #####
532  ===============================================================================
533  [..]
534  This subsection provides a set of functions allowing to control the HMAC.
535  (+) hal_hmac_get_state() API can be helpful to check in run-time the state of the HMAC peripheral.
536  (+) hal_hmac_get_error() check in run-time Errors occurring during communication.
537  (+) hal_hmac_set_timeout() set the timeout during internal process.
538 @endverbatim
539  * @{
540  */
541 
542 /**
543  ****************************************************************************************
544  * @brief Return the HMAC handle state.
545  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
546  * @retval ::HAL_HMAC_STATE_RESET: Peripheral not initialized.
547  * @retval ::HAL_HMAC_STATE_READY: Peripheral initialized and ready for use.
548  * @retval ::HAL_HMAC_STATE_BUSY: Peripheral in indirect mode and busy.
549  * @retval ::HAL_HMAC_STATE_ERROR: Peripheral in error.
550  * @retval ::HAL_HMAC_STATE_TIMEOUT: Peripheral in timeout.
551  * @retval ::HAL_HMAC_STATE_SUSPENDED: Peripheral in suspended.
552  ****************************************************************************************
553  */
555 
556 /**
557  ****************************************************************************************
558  * @brief Return the HMAC error code.
559  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
560  * @return HMAC error code in bitmap format
561  ****************************************************************************************
562  */
564 
565 /**
566  ****************************************************************************************
567  * @brief Set the HMAC internal process timeout value.
568  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
569  * @param[in] timeout: Internal process timeout value.
570  ****************************************************************************************
571  */
572 void hal_hmac_set_timeout(hmac_handle_t *p_hmac, uint32_t timeout);
573 
574 
575 /**
576  ****************************************************************************************
577  * @brief Suspend some registers related to HMAC configuration before sleep.
578  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration
579  * information for the specified HMAC module.
580  * @retval ::HAL_OK: Operation is OK.
581  * @retval ::HAL_ERROR: Parameter error or operation not supported.
582  * @retval ::HAL_BUSY: Driver is busy.
583  * @retval ::HAL_TIMEOUT: Timeout occurred.
584  ****************************************************************************************
585  */
587 
588 /**
589  ****************************************************************************************
590  * @brief Restore some registers related to HMAC configuration after sleep.
591  * This function must be used in conjunction with the hal_hmac_suspend_reg().
592  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration
593  * information for the specified HMAC module.
594  * @retval ::HAL_OK: Operation is OK.
595  * @retval ::HAL_ERROR: Parameter error or operation not supported.
596  * @retval ::HAL_BUSY: Driver is busy.
597  * @retval ::HAL_TIMEOUT: Timeout occurred.
598  ****************************************************************************************
599  */
601 
602 
603 /** @} */
604 
605 /** @} */
606 
607 #ifdef __cplusplus
608 }
609 #endif
610 
611 #endif /* __GR55xx_HAL_HMAC_H__ */
612 
613 /** @} */
614 
615 /** @} */
616 
617 /** @} */
_hmac_init::key_fetch_type
uint32_t key_fetch_type
HAL_HMAC_KEYTYPE_MCU Fetch key from ram; { Start_private HAL_HMAC_KEYTYPE_AHB Fetch key from AHB; } E...
Definition: gr55xx_hal_hmac.h:110
_hmac_init::p_user_hash
uint32_t * p_user_hash
Initialization HASH value
Definition: gr55xx_hal_hmac.h:108
hal_hmac_get_error
uint32_t hal_hmac_get_error(hmac_handle_t *p_hmac)
Return the HMAC error code.
hal_hmac_resume_reg
hal_status_t hal_hmac_resume_reg(hmac_handle_t *p_hmac)
Restore some registers related to HMAC configuration after sleep.
hal_hmac_irq_handler
void hal_hmac_irq_handler(hmac_handle_t *p_hmac)
Handle HMAC interrupt request.
_hmac_init
HMAC init Structure definition.
Definition: gr55xx_hal_hmac.h:103
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_hal_hmac_callback::hmac_msp_init
void(* hmac_msp_init)(hmac_handle_t *p_hmac)
HMAC init MSP callback
Definition: gr55xx_hal_hmac.h:175
_hmac_handle::p_message
uint32_t * p_message
Pointer to message input buffer
Definition: gr55xx_hal_hmac.h:135
hmac_handle_t
struct _hmac_handle hmac_handle_t
HMAC handle Structure definition.
hal_hmac_suspend_reg
hal_status_t hal_hmac_suspend_reg(hmac_handle_t *p_hmac)
Suspend some registers related to HMAC configuration before sleep.
_hmac_handle::state
__IO hal_hmac_state_t state
HMAC operation state
Definition: gr55xx_hal_hmac.h:147
HAL_HMAC_STATE_TIMEOUT
@ HAL_HMAC_STATE_TIMEOUT
Peripheral in timeout
Definition: gr55xx_hal_hmac.h:82
hal_hmac_msp_init
void hal_hmac_msp_init(hmac_handle_t *p_hmac)
Initialize the HMAC MSP.
_hmac_handle::error_code
__IO uint32_t error_code
HMAC Error code
Definition: gr55xx_hal_hmac.h:149
HAL_HMAC_STATE_SUSPENDED
@ HAL_HMAC_STATE_SUSPENDED
Peripheral in suspended
Definition: gr55xx_hal_hmac.h:83
_hmac_handle::init
hmac_init_t init
HMAC operation parameters
Definition: gr55xx_hal_hmac.h:133
hal_hmac_msp_deinit
void hal_hmac_msp_deinit(hmac_handle_t *p_hmac)
De-initialize the HMAC MSP.
hal_hmac_init
hal_status_t hal_hmac_init(hmac_handle_t *p_hmac)
Initialize the HMAC according to the specified parameters in the hmac_init_t and initialize the assoc...
_hal_hmac_callback::hmac_error_callback
void(* hmac_error_callback)(hmac_handle_t *p_hmac)
HMAC error callback
Definition: gr55xx_hal_hmac.h:178
HAL_HMAC_STATE_ERROR
@ HAL_HMAC_STATE_ERROR
Peripheral in error
Definition: gr55xx_hal_hmac.h:81
hal_hmac_callback_t
struct _hal_hmac_callback hal_hmac_callback_t
HAL_HMAC Callback function definition.
_hmac_handle::p_instance
hmac_regs_t * p_instance
HMAC registers base address
Definition: gr55xx_hal_hmac.h:131
HAL_HMAC_STATE_RESET
@ HAL_HMAC_STATE_RESET
Peripheral not initialized
Definition: gr55xx_hal_hmac.h:78
hmac_init_t
struct _hmac_init hmac_init_t
HMAC init Structure definition.
_hmac_init::enable_dma_mode
uint32_t enable_dma_mode
Enable mode
Definition: gr55xx_hal_hmac.h:117
hal_hmac_set_timeout
void hal_hmac_set_timeout(hmac_handle_t *p_hmac, uint32_t timeout)
Set the HMAC internal process timeout value.
hal_hmac_error_callback
void hal_hmac_error_callback(hmac_handle_t *p_hmac)
HMAC error callback.
_hmac_init::dpa_mode
uint32_t dpa_mode
DPA Mode
Definition: gr55xx_hal_hmac.h:115
_hmac_handle::block_count
uint32_t block_count
Blocks count
Definition: gr55xx_hal_hmac.h:141
_hmac_handle::lock
__IO hal_lock_t lock
Locking object
Definition: gr55xx_hal_hmac.h:145
_hmac_init::p_key
uint32_t * p_key
Encryption/Decryption Key
Definition: gr55xx_hal_hmac.h:106
hal_hmac_get_state
hal_hmac_state_t hal_hmac_get_state(hmac_handle_t *p_hmac)
Return the HMAC handle state.
hal_hmac_sha256_digest
hal_status_t hal_hmac_sha256_digest(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest, uint32_t timeout)
xxx in blocking mode in SHA mode.
_hmac_handle
HMAC handle Structure definition.
Definition: gr55xx_hal_hmac.h:130
_hmac_init::enable_irq
uint32_t enable_irq
Ctrl IRQ when MCU mode
Definition: gr55xx_hal_hmac.h:116
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
_hal_hmac_callback::hmac_msp_deinit
void(* hmac_msp_deinit)(hmac_handle_t *p_hmac)
HMAC de-init MSP callback
Definition: gr55xx_hal_hmac.h:176
_hal_hmac_callback::hmac_done_callback
void(* hmac_done_callback)(hmac_handle_t *p_hmac)
HMAC digest done callback
Definition: gr55xx_hal_hmac.h:177
hal_hmac_done_callback
void hal_hmac_done_callback(hmac_handle_t *p_hmac)
Digest Done callback.
HAL_HMAC_STATE_READY
@ HAL_HMAC_STATE_READY
Peripheral initialized and ready for use
Definition: gr55xx_hal_hmac.h:79
_hmac_init::mode
uint32_t mode
Operating mode
Definition: gr55xx_hal_hmac.h:104
_hmac_handle::is_last_trans
uint32_t is_last_trans
Flag for last transfer
Definition: gr55xx_hal_hmac.h:143
hal_hmac_state_t
hal_hmac_state_t
HAL HMAC State enumerations definition.
Definition: gr55xx_hal_hmac.h:77
_hmac_handle::block_size
uint32_t block_size
Data size in blocks (64 bytes per block)
Definition: gr55xx_hal_hmac.h:139
hal_hmac_deinit
hal_status_t hal_hmac_deinit(hmac_handle_t *p_hmac)
De-initialize the HMAC peripheral.
_hmac_handle::p_digest
uint32_t * p_digest
Pointer to digest output buffer
Definition: gr55xx_hal_hmac.h:137
_hmac_handle::retention
uint32_t retention[17]
HMAC important register information.
Definition: gr55xx_hal_hmac.h:153
_hmac_handle::timeout
uint32_t timeout
Timeout for the HMAC operation
Definition: gr55xx_hal_hmac.h:151
gr55xx_ll_hmac.h
Header file containing functions prototypes of HMAC LL library.
_hal_hmac_callback
HAL_HMAC Callback function definition.
Definition: gr55xx_hal_hmac.h:174
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
HAL_HMAC_STATE_BUSY
@ HAL_HMAC_STATE_BUSY
Peripheral in indirect mode and busy
Definition: gr55xx_hal_hmac.h:80