hal_hmac.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file 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 __GR5xx_HAL_HMAC_H__
53 #define __GR5xx_HAL_HMAC_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "ll_hmac.h"
61 #include "ll_misc.h"
62 #include "hal_def.h"
63 
64 /* Exported types ------------------------------------------------------------*/
65 /** @addtogroup HAL_HMAC_ENUMERATIONS Enumerations
66  * @{
67  */
68 
69 /** @defgroup HAL_HMAC_state HAL HMAC state
70  * @{
71  */
72 
73 /**
74  * @brief HAL HMAC State enumerations definition
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 */
82 
83 /** @} */
84 
85 /** @} */
86 
87 /** @addtogroup HAL_HMAC_STRUCTURES Structures
88  * @{
89  */
90 
91 /** @defgroup HMAC_Configuration HMAC Configuration
92  * @{
93  */
94 
95 /**
96  * @brief HMAC init Structure definition
97  */
98 typedef struct _hmac_init
99 {
100  uint32_t mode; /**< Operating mode
101  This parameter can be a value of @ref HMAC_MODE */
102  uint32_t key_type; /**< Operating mode
103  This parameter can be a value of @ref HAL_HMAC_KEYTYPE */
104  uint32_t *p_key; /**< HMAC Key */
105  uint32_t key_addr; /**< HMAC Key address */
106  uint32_t key_mask; /**< HMAC Key Keyport Mask */
107  uint32_t *p_user_hash; /**< Initialization HASH value */
108  uint32_t dpa_mode; /**< DPA Mode
109  This parameter can be a value of @ref HAL_HMAC_DPA_MODE */
110 #ifdef HAL_HMAC_MODULE_STREAM_ENABLED
111  uint32_t strm_dma_en; /**< DMA enabled in stream mode
112  This parameter can be a value of @ref HAL_HMAC_STRM_DMA */
113 #endif
115 
116 /** @} */
117 
118 
119 /** @defgroup HMAC_handle HMAC handle
120  * @{
121  */
122 
123 /**
124  * @brief HMAC handle Structure definition
125  */
126 typedef struct _hmac_handle
127 {
128  hmac_regs_t *p_instance; /**< HMAC registers base address */
129  hmac_init_t init; /**< HMAC operation parameters */
130  uint32_t *p_message; /**< Pointer to message input buffer */
131  uint32_t *p_digest; /**< Pointer to digest output buffer */
132  uint32_t block_size; /**< Data size in blocks (64 bytes per block) */
133  uint32_t is_last_trans; /**< Flag for last transfer */
134  __IO uint32_t it_flag; /**< Flag for Non-last block transfer */
135  __IO hal_hmac_state_t state; /**< HMAC operation state */
136  __IO uint32_t error_code; /**< HMAC Error code */
137 #ifdef HAL_HMAC_MODULE_STREAM_ENABLED
138  uint32_t total; /**< Data total size in bytes */
139  uint32_t hmac_buf[16]; /**< HMAC block buffer */
140  __IO uint32_t strm_done_flag; /**< Flag for done transfer in stream mode */
141 #endif
143 
144 /** @} */
145 
146 /** @} */
147 
148 /** @addtogroup HAL_HMAC_CALLBACK_STRUCTURES Callback Structures
149  * @{
150  */
151 
152 /** @defgroup HAL_HMAC_Callback Callback
153  * @{
154  */
155 
156 /**
157  * @brief HAL_HMAC Callback function definition
158  */
159 
160 typedef struct _hal_hmac_callback
161 {
162  void (*hmac_msp_init)(hmac_handle_t *p_hmac); /**< HMAC init MSP callback */
163  void (*hmac_msp_deinit)(hmac_handle_t *p_hmac); /**< HMAC de-init MSP callback */
164  void (*hmac_done_callback)(hmac_handle_t *p_hmac); /**< HMAC digest done callback */
165  void (*hmac_error_callback)(hmac_handle_t *p_hmac); /**< HMAC error callback */
167 
168 /** @} */
169 
170 /** @} */
171 
172 /**
173  * @defgroup HAL_HMAC_MACRO Defines
174  * @{
175  */
176 
177 /* Exported constants --------------------------------------------------------*/
178 /** @defgroup HMAC_Exported_Constants HMAC Exported Constants
179  * @{
180  */
181 
182 /** @defgroup HAL_HMAC_ERROR HMAC Error Code
183  * @{
184  */
185 #define HAL_HMAC_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
186 #define HAL_HMAC_ERROR_BUSY ((uint32_t)0x00000001) /**< Busy error */
187 #define HAL_HMAC_ERROR_TIMEOUT ((uint32_t)0x00000002) /**< Timeout error */
188 #define HAL_HMAC_ERROR_TRANSFER ((uint32_t)0x00000004) /**< Transfer error */
189 #define HAL_HMAC_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
190 /** @} */
191 
192 /** @defgroup HMAC_MODE HMAC Mode
193  * @{
194  */
195 #define HMAC_MODE_SHA LL_HMAC_CALCULATETYPE_SHA /**< SHA mode */
196 #define HMAC_MODE_HMAC LL_HMAC_CALCULATETYPE_HMAC /**< HMAC mode */
197 /** @} */
198 
199 /** @defgroup HAL_HMAC_KEYTYPE Key Type
200  * @{
201  */
202 #define HAL_HMAC_KEYTYPE_MCU LL_HMAC_KEYTYPE_MCU /**< Key from MCU */
203 #define HAL_HMAC_KEYTYPE_AHB LL_HMAC_KEYTYPE_AHB /**< Key from AHB master */
204 #define HAL_HMAC_KEYTYPE_KRAM LL_HMAC_KEYTYPE_KRAM /**< Key from Key Port */
205 /** @} */
206 
207 /** @defgroup HAL_HMAC_DPA_MODE DPA Mode
208  * @{
209  */
210 #define HAL_HMAC_DPA_MODE_ENABLE (1U) /**< Enable DPA Mode */
211 #define HAL_HMAC_DPA_MODE_DISABLE (0U) /**< Disable DPA Mode */
212 /** @} */
213 
214 #ifdef HAL_HMAC_MODULE_STREAM_ENABLED
215 /** @defgroup HAL_HMAC_STRM_DMA Stream DMA Mode
216  * @{
217  */
218 #define HAL_HMAC_STRM_DMA_ENABLE (1U) /**< Enable DMA in Stream Mode */
219 #define HAL_HMAC_STRM_DMA_DISABLE (0U) /**< Disable DMA in Stream Mode */
220 /** @} */
221 #endif
222 
223 /** @defgroup HMAC_BLOCKSIZE HAMC Block Size
224  * @{
225  */
226 #define HMAC_BLOCKSIZE_BITS (512U) /**< Block size in bits */
227 #define HMAC_BLOCKSIZE_BYTES (HMAC_BLOCKSIZE_BITS >> 3) /**< Block size in bytes */
228 #define HMAC_BLOCKSIZE_WORDS (HMAC_BLOCKSIZE_BYTES >> 2) /**< Block size in words */
229 #define HMAC_DIGESTSIZE_BITS (256U) /**< Digest size in bits */
230 #define HMAC_DIGESTSIZE_BYTES (HMAC_DIGESTSIZE_BITS >> 3) /**< Digest size in bytes */
231 #define HMAC_DIGESTSIZE_WORDS (HMAC_DIGESTSIZE_BYTES >> 2) /**< Digest size in words */
232 #define HMAC_DMA_BLOCK_MAX (512U) /**< DMA Block max size */
233 /** @} */
234 
235 /** @defgroup HMAC_Flags_definition HAMC Flags Definition
236  * @{
237  */
238 #define HMAC_FLAG_DATAREADY_SHA LL_HMAC_FLAG_DATAREADY_SHA /**< HMAC data ready (SHA mode) */
239 #define HMAC_FLAG_DATAREADY_HMAC LL_HMAC_FLAG_DATAREADY_HMAC /**< HMAC data ready (HAMC mode) */
240 #define HMAC_FLAG_DMA_MESSAGEDONE LL_HMAC_FLAG_DMA_MESSAGEDONE /**< HMAC DMA message done */
241 #define HMAC_FLAG_DMA_DONE LL_HMAC_FLAG_DMA_DONE /**< HMAC DMA transfer done */
242 #define HMAC_FLAG_DMA_ERR LL_HMAC_FLAG_DMA_ERR /**< HMAC DMA transfer error */
243 #define HMAC_FLAG_KEY_VALID LL_HMAC_FLAG_KEY_VALID /**< HMAC has fetched key */
244 /** @} */
245 
246 /** @defgroup HMAC_Interrupt_definition HMAC Interrupt_definition
247  * @{
248  */
249 #define HMAC_IT_DONE ((uint32_t)0x00000001) /**< Operation Done Interrupt source */
250 /** @} */
251 
252 /** @defgroup HMAC_Timeout_definition HMAC Timeout_definition
253  * @{
254  */
255 #define HAL_HMAC_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
256 /** @} */
257 
258 /** @} */
259 
260 /* Exported macro ------------------------------------------------------------*/
261 /** @defgroup HMAC_Exported_Macros HMAC Exported Macros
262  * @{
263  */
264 
265 /** @brief Start DMA Last block transfer.
266  * @param __HANDLE__ Specifies the HMAC interrupt Handle.
267  * @retval None
268  */
269 #define __HAL_HMAC_DMA_START_LAST_TRF(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, (HMAC_CTRL_LST_TX | HMAC_CTRL_DMA_START))
270 
271 /** @brief Clear the specified HMAC interrupt flag.
272  * @param __HANDLE__ Specifies the HMAC interrupt Handle.
273  * @param __FLAG__ Specifies the flag to clear.
274  * This parameter can be one of the following values:
275  * @arg @ref HMAC_IT_DONE Encrypted or Decrypted Data Done Interrupt
276  * @retval None
277  */
278 #define __HAL_HMAC_CLEAR_FLAG_IT(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INT, (__FLAG__))
279 
280 /** @brief Check whether the specified HMAC flag is set or not.
281  * @param __HANDLE__ Specifies the HMAC Handle.
282  * @param __FLAG__ Specifies the flag to check.
283  * This parameter can be one of the following values:
284  * @arg @ref HMAC_FLAG_DATAREADY_SHA Data ready (SHA mode) flag
285  * @arg @ref HMAC_FLAG_DATAREADY_HMAC Data ready (HMAC mode) flag
286  * @arg @ref HMAC_FLAG_DMA_DONE DMA transfer done flag
287  * @arg @ref HMAC_FLAG_DMA_ERR DMA transfer error flag
288  * @arg @ref HMAC_FLAG_KEY_VALID Key valid flag
289  * @retval The new state of __FLAG__ (TRUE or FALSE).
290  */
291 #define __HAL_HMAC_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0U) ? SET : RESET)
292 
293 /** @} */
294 
295 /** @} */
296 
297 /* Exported functions --------------------------------------------------------*/
298 /** @addtogroup HAL_HMAC_DRIVER_FUNCTIONS Functions
299  * @{
300  */
301 
302 /** @addtogroup HMAC_Exported_Functions_Group1 Initialization and de-initialization functions
303  * @brief Initialization and de-initialization functions
304  *
305 @verbatim
306  ===============================================================================
307  ##### Initialization and de-initialization functions #####
308  ===============================================================================
309  [..] This subsection provides a set of functions allowing to initialize and
310  de-initialize the HMACx peripheral:
311 
312  (+) User must implement hal_hmac_msp_init() function in which he configures
313  all related peripherals resources (GPIO, DMA, IT and NVIC ).
314 
315  (+) Call the function hal_hmac_init() to configure the selected device with
316  the selected configuration:
317  (++) mode
318  (++) key_type
319  (++) key
320  (++) key_addr
321  (++) key_mask
322  (++) user_hash
323  (++) dpa_mode
324 
325  (+) Call the function hal_hmac_deinit() to restore the default configuration
326  of the selected HMACx peripheral.
327 
328 @endverbatim
329  * @{
330  */
331 
332 /**
333  ****************************************************************************************
334  * @brief Initialize the HMAC according to the specified parameters
335  * in the hmac_init_t and initialize the associated handle.
336  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
337  * @retval ::HAL_OK: Operation is OK.
338  * @retval ::HAL_ERROR: Parameter error or operation not supported.
339  * @retval ::HAL_BUSY: Driver is busy.
340  * @retval ::HAL_TIMEOUT: Timeout occurred.
341  ****************************************************************************************
342  */
344 
345 /**
346  ****************************************************************************************
347  * @brief De-initialize the HMAC peripheral.
348  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
349  * @retval ::HAL_OK: Operation is OK.
350  * @retval ::HAL_ERROR: Parameter error or operation not supported.
351  * @retval ::HAL_BUSY: Driver is busy.
352  * @retval ::HAL_TIMEOUT: Timeout occurred.
353  ****************************************************************************************
354  */
356 
357 /**
358  ****************************************************************************************
359  * @brief Initialize the HMAC MSP.
360  * @note This function should not be modified. When the callback is needed,
361  the hal_hmac_msp_deinit can be implemented in the user file.
362  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
363  ****************************************************************************************
364  */
366 
367 /**
368  ****************************************************************************************
369  * @brief De-initialize the HMAC MSP.
370  * @note This function should not be modified. When the callback is needed,
371  the HAL_HMAC_MspDeInit can be implemented in the user file.
372  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
373  ****************************************************************************************
374  */
376 
377 /** @} */
378 
379 /** @addtogroup HMAC_Exported_Functions_Group2 HMAC operation functions
380  * @brief HMAC operation functions
381  *
382 @verbatim
383  ===============================================================================
384  ##### HMAC operation functions #####
385  ===============================================================================
386  This subsection provides a set of functions allowing to manage the HMAC operation.
387 
388  (#) There are two mode of transfer:
389  (++) Blocking mode: The communication is performed in polling mode.
390  The HAL status of all data processing is returned by the same function
391  after finishing transfer.
392  (++) Non-Blocking mode: The communication is performed using Interrupts
393  or DMA, These API's return the HAL status.
394  The end of the data processing will be indicated through the
395  dedicated HMAC IRQ when using Interrupt mode or the DMA IRQ when
396  using DMA mode.
397  The hal_hmac_done_callback() user callbacks will be executed respectively
398  at the end of the encrypt or decrypt process
399  The hal_hmac_error_callback() user callback will be executed when a error is detected
400 
401  (#) Blocking mode API's are :
402  (++) hal_hmac_sha256_digest()
403 
404  (#) Non-Blocking mode API's with Interrupt are :
405  (++) hal_hmac_sha256_digest_it()
406 
407  (#) Non-Blocking mode API's with DMA are :
408  (++) hal_hmac_sha256_digest_dma()
409 
410  (#) A set of encrypt or decrypt Callbacks are provided in Non_Blocking mode:
411  (++) hal_hmac_done_callback()
412  (++) hal_hmac_error_callback()
413 
414  (#) Stream mode API's are :
415  (++) hal_hmac_sha256_start()
416  (++) hal_hmac_sha256_update()
417  (++) hal_hmac_sha256_finish()
418 
419 @endverbatim
420  * @{
421  */
422 
423 /**
424  ****************************************************************************************
425  * @brief xxx in blocking mode in HMAC/SHA mode.
426  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
427  * @param[in] p_message: Pointer to message buffer
428  * @param[in] number: Amount of data
429  * @param[out] p_digest: Pointer to digest buffer
430  * @param[in] timeout: Timeout duration
431  * @retval ::HAL_OK: Operation is OK.
432  * @retval ::HAL_ERROR: Parameter error or operation not supported.
433  * @retval ::HAL_BUSY: Driver is busy.
434  * @retval ::HAL_TIMEOUT: Timeout occurred.
435  ****************************************************************************************
436  */
437 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);
438 
439 /**
440  ****************************************************************************************
441  * @brief xxx in non-blocking mode with interrupt in HMAC/SHA mode.
442  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
443  * @param[in] p_message: Pointer to message buffer
444  * @param[in] number: Amount of data
445  * @param[out] p_digest: Pointer to digest buffer
446  * @retval ::HAL_OK: Operation is OK.
447  * @retval ::HAL_ERROR: Parameter error or operation not supported.
448  * @retval ::HAL_BUSY: Driver is busy.
449  * @retval ::HAL_TIMEOUT: Timeout occurred.
450  ****************************************************************************************
451  */
452 hal_status_t hal_hmac_sha256_digest_it(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
453 
454 /**
455  ****************************************************************************************
456  * @brief xxx in non-blocking mode with DMA in HMAC/SHA mode.
457  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
458  * @param[in] p_message: Pointer to message buffer
459  * @param[in] number: Amount of data
460  * @param[out] p_digest: Pointer to digest buffer
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_hmac_sha256_digest_dma(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number, uint32_t *p_digest);
468 
469 #ifdef HAL_HMAC_MODULE_STREAM_ENABLED
470 /**
471  ****************************************************************************************
472  * @brief Start processing in HMAC/SHA stream mode.
473  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
474  * @retval ::HAL_OK: Operation is OK.
475  * @retval ::HAL_ERROR: Parameter error or operation not supported.
476  * @retval ::HAL_BUSY: Driver is busy.
477  * @retval ::HAL_TIMEOUT: Timeout occurred.
478  ****************************************************************************************
479  */
480 hal_status_t hal_hmac_sha256_start(hmac_handle_t *p_hmac);
481 
482 /**
483  ****************************************************************************************
484  * @brief Update input data in HMAC/SHA stream mode.
485  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
486  * @param[in] p_message: Pointer to message buffer
487  * @param[in] number: Amount of data
488  * @retval ::HAL_OK: Operation is OK.
489  * @retval ::HAL_ERROR: Parameter error or operation not supported.
490  * @retval ::HAL_BUSY: Driver is busy.
491  * @retval ::HAL_TIMEOUT: Timeout occurred.
492  ****************************************************************************************
493  */
494 hal_status_t hal_hmac_sha256_update(hmac_handle_t *p_hmac, uint32_t *p_message, uint32_t number);
495 
496 /**
497  ****************************************************************************************
498  * @brief Get final result in HMAC/SHA stream mode.
499  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
500  * @param[out] p_digest: Pointer to digest buffer
501  * @retval ::HAL_OK: Operation is OK.
502  * @retval ::HAL_ERROR: Parameter error or operation not supported.
503  * @retval ::HAL_BUSY: Driver is busy.
504  * @retval ::HAL_TIMEOUT: Timeout occurred.
505  ****************************************************************************************
506  */
507 hal_status_t hal_hmac_sha256_finish(hmac_handle_t *p_hmac, uint32_t *p_digest);
508 #endif /* HAL_HMAC_MODULE_STREAM_ENABLED */
509 
510 /** @} */
511 
512 /** @addtogroup HMAC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
513  * @brief IRQ Handler and Callbacks functions
514  * @{
515  */
516 
517 /**
518  ****************************************************************************************
519  * @brief Handle HMAC interrupt request.
520  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
521  ****************************************************************************************
522  */
524 
525 /**
526  ****************************************************************************************
527  * @brief Digest Done callback.
528  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
529  ****************************************************************************************
530  */
532 
533 /**
534  ****************************************************************************************
535  * @brief HMAC error callback.
536  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
537  ****************************************************************************************
538  */
540 
541 /** @} */
542 
543 /** @defgroup HMAC_Exported_Functions_Group3 HMAC State and Errors functions
544  * @brief HMAC control functions
545  *
546 @verbatim
547  ===============================================================================
548  ##### HMAC State and Errors functions #####
549  ===============================================================================
550  [..]
551  This subsection provides a set of functions allowing to control the HMAC.
552  (+) hal_hmac_get_state() API can be helpful to check in run-time the state of the HMAC peripheral.
553  (+) hal_hmac_get_error() check in run-time Errors occurring during communication.
554 @endverbatim
555  * @{
556  */
557 
558 /**
559  ****************************************************************************************
560  * @brief Return the HMAC handle state.
561  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
562  * @retval ::HAL_HMAC_STATE_RESET: Peripheral not initialized.
563  * @retval ::HAL_HMAC_STATE_READY: Peripheral initialized and ready for use.
564  * @retval ::HAL_HMAC_STATE_BUSY: Peripheral in indirect mode and busy.
565  ****************************************************************************************
566  */
568 
569 /**
570  ****************************************************************************************
571  * @brief Return the HMAC error code.
572  * @param[in] p_hmac: Pointer to a HMAC handle which contains the configuration information for the specified HMAC module.
573  * @return HMAC error code in bitmap format
574  ****************************************************************************************
575  */
577 
578 /** @} */
579 
580 /** @} */
581 
582 #ifdef __cplusplus
583 }
584 #endif
585 
586 #endif /* __GR5xx_HAL_HMAC_H__ */
587 
588 /** @} */
589 
590 /** @} */
591 
592 /** @} */
_hmac_init::p_user_hash
uint32_t * p_user_hash
Definition: hal_hmac.h:107
ll_misc.h
Header file containing functions prototypes of MISC LL library.
hal_hmac_get_error
uint32_t hal_hmac_get_error(hmac_handle_t *p_hmac)
Return the HMAC error code.
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: hal_hmac.h:99
_hal_hmac_callback::hmac_msp_init
void(* hmac_msp_init)(hmac_handle_t *p_hmac)
Definition: hal_hmac.h:162
_hmac_handle::p_message
uint32_t * p_message
Definition: hal_hmac.h:130
hmac_handle_t
struct _hmac_handle hmac_handle_t
HMAC handle Structure definition.
_hmac_handle::state
__IO hal_hmac_state_t state
Definition: hal_hmac.h:135
_hmac_init::key_type
uint32_t key_type
Definition: hal_hmac.h:102
ll_hmac.h
Header file containing functions prototypes of HMAC LL library.
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: hal_hmac.h:136
_hmac_handle::init
hmac_init_t init
Definition: 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: hal_hmac.h:165
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: hal_hmac.h:128
HAL_HMAC_STATE_RESET
@ HAL_HMAC_STATE_RESET
Definition: 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_error_callback
void hal_hmac_error_callback(hmac_handle_t *p_hmac)
HMAC error callback.
_hmac_init::dpa_mode
uint32_t dpa_mode
Definition: hal_hmac.h:108
_hmac_init::p_key
uint32_t * p_key
Definition: hal_hmac.h:104
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: hal_hmac.h:127
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr_common.h:140
_hmac_init::key_addr
uint32_t key_addr
Definition: hal_hmac.h:105
hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_hal_hmac_callback::hmac_msp_deinit
void(* hmac_msp_deinit)(hmac_handle_t *p_hmac)
Definition: hal_hmac.h:163
_hal_hmac_callback::hmac_done_callback
void(* hmac_done_callback)(hmac_handle_t *p_hmac)
Definition: hal_hmac.h:164
_hmac_init::key_mask
uint32_t key_mask
Definition: hal_hmac.h:106
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: hal_hmac.h:79
_hmac_init::mode
uint32_t mode
Definition: hal_hmac.h:100
_hmac_handle::is_last_trans
uint32_t is_last_trans
Definition: hal_hmac.h:133
hal_hmac_state_t
hal_hmac_state_t
HAL HMAC State enumerations definition.
Definition: hal_hmac.h:77
_hmac_handle::block_size
uint32_t block_size
Definition: hal_hmac.h:132
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: hal_hmac.h:131
_hal_hmac_callback
HAL_HMAC Callback function definition.
Definition: hal_hmac.h:161
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.
_hmac_handle::it_flag
__IO uint32_t it_flag
Definition: hal_hmac.h:134
HAL_HMAC_STATE_BUSY
@ HAL_HMAC_STATE_BUSY
Definition: hal_hmac.h:80