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
85 } hal_hmac_state_t;
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; /**< Fetch key type.
111 This parameter can be a value of @ref HMAC_HAL_KEY_TYPE */
112
113 uint32_t dpa_mode; /**< DPA Mode */
114
115 } hmac_init_t;
116 /** @} */
117
118 /** @defgroup HMAC_handle HMAC handle
119 * @{
120 */
121
122 /**
123 * @brief HMAC handle Structure definition
124 */
125 typedef struct _hmac_handle
126 {
127 hmac_regs_t *p_instance; /**< HMAC registers base address */
128
129 hmac_init_t init; /**< HMAC operation parameters */
130
131 uint32_t *p_message; /**< Pointer to message input buffer */
132
133 uint32_t *p_digest; /**< Pointer to digest output buffer */
134
135 uint32_t block_size; /**< Data size in blocks (64 bytes per block) */
136
137 uint32_t block_count; /**< Blocks count */
138
139 uint32_t is_last_trans; /**< Flag for last transfer */
140
141 __IO hal_lock_t lock; /**< Locking object */
142
143 __IO hal_hmac_state_t state; /**< HMAC operation state */
144
145 __IO uint32_t error_code; /**< HMAC Error code */
146
147 uint32_t timeout; /**< Timeout for the HMAC operation */
148
149 uint32_t retention[17]; /**< HMAC important register information. */
150
151 } hmac_handle_t;
152
153 /** @} */
154
155 /** @} */
156
157 /** @addtogroup HAL_HMAC_CALLBACK_STRUCTURES Callback Structures
158 * @{
159 */
160
161 /** @defgroup HAL_HMAC_Callback Callback
162 * @{
163 */
164
165 /**
166 * @brief HAL_HMAC Callback function definition
167 */
168
169 typedef struct _hal_hmac_callback
170 {
171 void (*hmac_msp_init)(hmac_handle_t *p_hmac); /**< HMAC init MSP callback */
172 void (*hmac_msp_deinit)(hmac_handle_t *p_hmac); /**< HMAC de-init MSP callback */
173 void (*hmac_done_callback)(hmac_handle_t *p_hmac); /**< HMAC digest done callback */
174 void (*hmac_error_callback)(hmac_handle_t *p_hmac); /**< HMAC error callback */
175 } hal_hmac_callback_t;
176
177 /** @} */
178
179 /** @} */
180
181 /**
182 * @defgroup HAL_HMAC_MACRO Defines
183 * @{
184 */
185
186 /* Exported constants --------------------------------------------------------*/
187 /** @defgroup HMAC_Exported_Constants HMAC Exported Constants
188 * @{
189 */
190
191 /** @defgroup HMAC_Error_Code HMAC Error Code
192 * @{
193 */
194 #define HAL_HMAC_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
195 #define HAL_HMAC_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
196 #define HAL_HMAC_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
197 #define HAL_HMAC_ERROR_INVALID_PARAM ((uint32_t)0x00000004) /**< Invalid parameters error */
198 /** @} */
199
200 /** @defgroup HMAC_Mode HMAC Mode
201 * @{
202 */
203 #define HMAC_MODE_SHA LL_HMAC_CALCULATETYPE_SHA /**< SHA mode */
204 #define HMAC_MODE_HMAC LL_HMAC_CALCULATETYPE_HMAC /**< HMAC mode */
205 /** @} */
206
207 /** @defgroup HMAC_Block_Size HAMC Block Size
208 * @{
209 */
210 #define HMAC_BLOCK_MAX (512) /**< Block max size */
211 #define HMAC_BLOCKSIZE_BITS (512) /**< Block size in bits */
212 #define HMAC_BLOCKSIZE_BYTES (HMAC_BLOCKSIZE_BITS >> 3) /**< Block size in bytes */
213 #define HMAC_BLOCKSIZE_WORDS (HMAC_BLOCKSIZE_BYTES >> 2) /**< Block size in words */
214 #define HMAC_DIGESTSIZE_BITS (256) /**< Digest size in bits */
215 #define HMAC_DIGESTSIZE_BYTES (HMAC_DIGESTSIZE_BITS >> 3) /**< Digest size in bytes */
216 #define HMAC_DIGESTSIZE_WORDS (HMAC_DIGESTSIZE_BYTES >> 2) /**< Digest size in words */
217 #define HMAC_DMA_BLOCK_MAX (512) /**< DMA Block max size */
218 /** @} */
219
220 /** @defgroup HMAC_Flags_definition HAMC Flags Definition
221 * @{
222 */
223 #define HMAC_FLAG_DATAREADY_SHA LL_HMAC_FLAG_DATAREADY_SHA /**< HMAC data ready (SHA mode) */
224 #define HMAC_FLAG_DATAREADY_HMAC LL_HMAC_FLAG_DATAREADY_HMAC /**< HMAC data ready (HAMC mode) */
225 #define HMAC_FLAG_DMA_MESSAGEDONE LL_HMAC_FLAG_DMA_MESSAGEDONE /**< HMAC DMA message done */
226 #define HMAC_FLAG_DMA_DONE LL_HMAC_FLAG_DMA_DONE /**< HMAC DMA transfer done */
227 #define HMAC_FLAG_DMA_ERR LL_HMAC_FLAG_DMA_ERR /**< HMAC DMA transfer error */
228 #define HMAC_FLAG_KEY_VALID LL_HMAC_FLAG_KEY_VALID /**< HMAC has fetched key */
229 /** @} */
230
231 /** @defgroup HMAC_HAL_KEY_TYPE Key Type
232 * @{
233 */
234 #define HAL_HMAC_KEYTYPE_MCU LL_HMAC_KEYTYPE_MCU /**< Key from MCU */
235 /* { Start_private */
236 #define HAL_HMAC_KEYTYPE_AHB LL_HMAC_KEYTYPE_AHB /**< Key from AHB master */
237 /* } End_private */
238 #define HAL_HMAC_KEYTYPE_KRAM LL_HMAC_KEYTYPE_KRAM /**< Key from Key Port */
239 /** @} */
240
241 /** @defgroup HMAC_Interrupt_definition HMAC Interrupt_definition
242 * @{
243 */
244 #define HMAC_IT_DONE ((uint32_t)0x00000001) /**< Operation Done Interrupt source */
245 /** @} */
246
247 /** @defgroup HMAC_Timeout_definition HMAC Timeout_definition
248 * @{
249 */
250 #define HAL_HMAC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
251 /** @} */
252
253 /** @} */
254
255 /* Exported macro ------------------------------------------------------------*/
256 /** @defgroup HMAC_Exported_Macros HMAC Exported Macros
257 * @{
258 */
259
260 /** @brief Reset HMAC handle states.
261 * @param __HANDLE__ HMAC handle.
262 * @retval None
263 */
264 #define __HAL_HMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_HMAC_STATE_RESET)
265
266 /** @brief Enable the specified HMAC peripheral.
267 * @param __HANDLE__ Specifies the HMAC Handle.
268 * @retval None
269 */
270
271 #define __HAL_HMAC_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_EN)
272 /** @brief Disable the specified HMAC peripheral.
273 * @param __HANDLE__ Specifies the HMAC Handle.
274 * @retval None
275 */
276
277 #define __HAL_HMAC_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, HMAC_CTRL_EN)
278
279 /** @brief Enable the HMAC interrupt.
280 * @param __HANDLE__ Specifies the HMAC Handle.
281 * @retval None
282 */
283 #define __HAL_HMAC_ENABLE_IT(__HANDLE__) ll_hmac_enable_it_done((__HANDLE__)->p_instance)
284
285 /** @brief Disable the HMAC interrupt.
286 * @param __HANDLE__ Specifies the HMAC Handle.
287 * @retval None
288 */
289 #define __HAL_HMAC_DISABLE_IT(__HANDLE__) ll_hmac_disable_it_done((__HANDLE__)->p_instance)
290
291 /** @brief Check whether the specified HMAC interrupt flag is set or not.
292 * @param __HANDLE__ Specifies the HMAC Handle.
293 * @param __FLAG__ Specifies the interrupt flag to check.
294 * This parameter can be one of the following values:
295 * @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
296 * @retval The new state of __FLAG__ (TRUE or FALSE).
297 */
298
299 #define __HAL_HMAC_GET_FLAG_IT(__HANDLE__, __FLAG__) (READ_BITS((__HANDLE__)->p_instance->INT, (__FLAG__)) == (__FLAG__))
300
301 /** @brief Clear the specified HMAC interrupt flag.
302 * @param __HANDLE__ Specifies the HMAC interrupt Handle.
303 * @param __FLAG__ Specifies the flag to clear.
304 * This parameter can be one of the following values:
305 * @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
306 * @retval None
307 */
308
309 #define __HAL_HMAC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INT, (__FLAG__))
310
311 /** @brief Check whether the specified HMAC flag is set or not.
312 * @param __HANDLE__ Specifies the HMAC Handle.
313 * @param __FLAG__ Specifies the flag to check.
314 * This parameter can be one of the following values:
315 * @arg @ref HMAC_FLAG_DATAREADY_SHA Data ready (SHA mode) flag
316 * @arg @ref HMAC_FLAG_DATAREADY_HMAC Data ready (HMAC mode) flag
317 * @arg @ref HMAC_FLAG_DMA_DONE DMA transfer done flag
318 * @arg @ref HMAC_FLAG_DMA_ERR DMA transfer error flag
319 * @arg @ref HMAC_FLAG_KEY_VALID Key valid flag
320 * @retval The new state of __FLAG__ (TRUE or FALSE).
321 */
322
323 #define __HAL_HMAC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
324
325 /** @} */
326
327 /** @} */
328
329 /* Exported functions --------------------------------------------------------*/
330 /** @addtogroup HAL_HMAC_DRIVER_FUNCTIONS Functions
331 * @{
332 */
333
334 /** @addtogroup HMAC_Exported_Functions_Group1 Initialization and de-initialization functions
335 * @brief Initialization and de-initialization functions
336 *
337 @verbatim
338 ===============================================================================
339 ##### Initialization and de-initialization functions #####
340 ===============================================================================
341 [..] This subsection provides a set of functions allowing to initialize and
342 de-initialize the HMACx peripheral:
343
344 (+) User must implement hal_hmac_msp_init() function in which he configures
345 all related peripherals resources (GPIO, DMA, IT and NVIC ).
346
347 (+) Call the function hal_hmac_init() to configure the selected device with
348 the selected configuration:
349 (++) mode
350 (++) key
351 (++) user_hash
352 (++) dpa_mode
353
354 (+) Call the function hal_hmac_deinit() to restore the default configuration
355 of the selected HMACx peripheral.
356
357 @endverbatim
358 * @{
359 */
360
361 /**
362 ****************************************************************************************
363 * @brief Initialize the HMAC according to the specified parameters
364 * in the hmac_init_t and initialize the associated handle.
365 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
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 */
372 hal_status_t hal_hmac_init(hmac_handle_t *p_hmac);
373
374 /**
375 ****************************************************************************************
376 * @brief De-initialize the HMAC peripheral.
377 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
378 * @retval ::HAL_OK: Operation is OK.
379 * @retval ::HAL_ERROR: Parameter error or operation not supported.
380 * @retval ::HAL_BUSY: Driver is busy.
381 * @retval ::HAL_TIMEOUT: Timeout occurred.
382 ****************************************************************************************
383 */
384 hal_status_t hal_hmac_deinit(hmac_handle_t *p_hmac);
385
386 /**
387 ****************************************************************************************
388 * @brief Initialize the HMAC MSP.
389 * @note This function should not be modified. When the callback is needed,
390 the hal_hmac_msp_deinit can be implemented in the user file.
391 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
392 ****************************************************************************************
393 */
394 void hal_hmac_msp_init(hmac_handle_t *p_hmac);
395
396 /**
397 ****************************************************************************************
398 * @brief De-initialize the HMAC MSP.
399 * @note This function should not be modified. When the callback is needed,
400 the HAL_HMAC_MspDeInit can be implemented in the user file.
401 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
402 ****************************************************************************************
403 */
404 void hal_hmac_msp_deinit(hmac_handle_t *p_hmac);
405
406 /** @} */
407
408 /** @addtogroup HMAC_Exported_Functions_Group2 IO operation functions
409 * @brief HMAC Encrypt/Decrypt functions
410 *
411 @verbatim
412 ===============================================================================
413 ##### IO operation functions #####
414 ===============================================================================
415 This subsection provides a set of functions allowing to manage the HMAC encrypt or decrypt.
416
417 (#) There are two mode of transfer:
418 (++) Blocking mode: The communication is performed in polling mode.
419 The HAL status of all data processing is returned by the same function
420 after finishing transfer.
421 (++) Non-Blocking mode: The communication is performed using Interrupts
422 or DMA, These API's return the HAL status.
423 The end of the data processing will be indicated through the
424 dedicated HMAC IRQ when using Interrupt mode or the DMA IRQ when
425 using DMA mode.
426 The hal_hmac_done_callback() user callbacks will be executed respectively
427 at the end of the encrypt or decrypt process
428 The hal_hmac_error_callback() user callback will be executed when a error is detected
429
430 (#) Blocking mode API's are :
431 (++) hal_hmac_sha256_digest()
432
433 (#) Non-Blocking mode API's with Interrupt are :
434 (++) hal_hmac_sha256_digest_it()
435
436 (#) Non-Blocking mode API's with DMA are :
437 (++) hal_hmac_sha256_digest_dma()
438
439 (#) A set of encrypt or decrypt Callbacks are provided in Non_Blocking mode:
440 (++) hal_hmac_done_callback()
441 (++) hal_hmac_error_callback()
442
443 @endverbatim
444 * @{
445 */
446
447 /**
448 ****************************************************************************************
449 * @brief xxx in blocking mode in HMAC/SHA mode.
450 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
451 * @param[in] p_message: Pointer to message buffer
452 * @param[in] number: Amount of data
453 * @param[out] p_digest: Pointer to digest buffer
454 * @param[in] timeout: Timeout duration
455 * @retval ::HAL_OK: Operation is OK.
456 * @retval ::HAL_ERROR: Parameter error or operation not supported.
457 * @retval ::HAL_BUSY: Driver is busy.
458 * @retval ::HAL_TIMEOUT: Timeout occurred.
459 ****************************************************************************************
460 */
461 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);
462
463 /**
464 ****************************************************************************************
465 * @brief xxx in non-blocking mode with interrupt in HMAC/SHA mode.
466 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
467 * @param[in] p_message: Pointer to message buffer
468 * @param[in] number: Amount of data
469 * @param[out] p_digest: Pointer to digest buffer
470 * @retval ::HAL_OK: Operation is OK.
471 * @retval ::HAL_ERROR: Parameter error or operation not supported.
472 * @retval ::HAL_BUSY: Driver is busy.
473 * @retval ::HAL_TIMEOUT: Timeout occurred.
474 ****************************************************************************************
475 */
476 hal_status_t hal_hmac_sha256_digest_it(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
477
478 /**
479 ****************************************************************************************
480 * @brief xxx in non-blocking mode with DMA in HMAC/SHA mode.
481 * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
482 * @param[in] p_message: Pointer to message buffer
483 * @param[in] number: Amount of data
484 * @param[out] p_digest: Pointer to digest buffer
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_dma(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
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 */
506 void hal_hmac_irq_handler(hmac_handle_t *p_hmac);
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 */
514 void hal_hmac_done_callback(hmac_handle_t *p_hmac);
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 */
522 void hal_hmac_error_callback(hmac_handle_t *p_hmac);
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 */
554 hal_hmac_state_t hal_hmac_get_state(hmac_handle_t *p_hmac);
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 */
563 uint32_t hal_hmac_get_error(hmac_handle_t *p_hmac);
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 */
586 hal_status_t hal_hmac_suspend_reg(hmac_handle_t *p_hmac);
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 */
600 hal_status_t hal_hmac_resume_reg(hmac_handle_t *p_hmac);
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
Definition: gr55xx_hal_hmac.h:110
_hmac_init::p_user_hash
uint32_t * p_user_hash
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. This function must be used in conju...
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)
Definition: gr55xx_hal_hmac.h:171
_hmac_handle::p_message
uint32_t * p_message
Definition: gr55xx_hal_hmac.h:131
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
Definition: gr55xx_hal_hmac.h:143
HAL_HMAC_STATE_TIMEOUT
@ HAL_HMAC_STATE_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
Definition: gr55xx_hal_hmac.h:145
HAL_HMAC_STATE_SUSPENDED
@ HAL_HMAC_STATE_SUSPENDED
Definition: gr55xx_hal_hmac.h:83
_hmac_handle::init
hmac_init_t init
Definition: gr55xx_hal_hmac.h:129
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)
Definition: gr55xx_hal_hmac.h:174
HAL_HMAC_STATE_ERROR
@ HAL_HMAC_STATE_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
Definition: gr55xx_hal_hmac.h:127
HAL_HMAC_STATE_RESET
@ HAL_HMAC_STATE_RESET
Definition: gr55xx_hal_hmac.h:78
hmac_init_t
struct _hmac_init hmac_init_t
HMAC init Structure definition.
hal_hmac_sha256_digest_it
hal_status_t hal_hmac_sha256_digest_it(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest)
xxx in non-blocking mode with interrupt in HMAC/SHA mode.
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
Definition: gr55xx_hal_hmac.h:113
_hmac_handle::block_count
uint32_t block_count
Definition: gr55xx_hal_hmac.h:137
_hmac_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_hmac.h:141
_hmac_init::p_key
uint32_t * p_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 HMAC/SHA mode.
_hmac_handle
HMAC handle Structure definition.
Definition: gr55xx_hal_hmac.h:126
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)
Definition: gr55xx_hal_hmac.h:172
_hal_hmac_callback::hmac_done_callback
void(* hmac_done_callback)(hmac_handle_t *p_hmac)
Definition: gr55xx_hal_hmac.h:173
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
Definition: gr55xx_hal_hmac.h:79
_hmac_init::mode
uint32_t mode
Definition: gr55xx_hal_hmac.h:104
_hmac_handle::is_last_trans
uint32_t is_last_trans
Definition: gr55xx_hal_hmac.h:139
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
Definition: gr55xx_hal_hmac.h:135
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
Definition: gr55xx_hal_hmac.h:133
_hmac_handle::retention
uint32_t retention[17]
Definition: gr55xx_hal_hmac.h:149
_hmac_handle::timeout
uint32_t timeout
Definition: gr55xx_hal_hmac.h:147
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:170
hal_hmac_sha256_digest_dma
hal_status_t hal_hmac_sha256_digest_dma(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest)
xxx in non-blocking mode with DMA in HMAC/SHA mode.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
HAL_HMAC_STATE_BUSY
@ HAL_HMAC_STATE_BUSY
Definition: gr55xx_hal_hmac.h:80