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