1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_hash.h
4   * @author  MCD Application Team
5   * @brief   Header file of HASH HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2017 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7xx_HAL_HASH_H
21 #define STM32H7xx_HAL_HASH_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx_hal_def.h"
29 
30 /** @addtogroup STM32H7xx_HAL_Driver
31   * @{
32   */
33 #if defined (HASH)
34 /** @addtogroup HASH
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup HASH_Exported_Types HASH Exported Types
40   * @{
41   */
42 
43 /**
44   * @brief  HASH Configuration Structure definition
45   */
46 typedef struct
47 {
48   uint32_t DataType;    /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit data.
49                               This parameter can be a value of @ref HASH_Data_Type. */
50 
51   uint32_t KeySize;     /*!< The key size is used only in HMAC operation. */
52 
53   uint8_t *pKey;        /*!< The key is used only in HMAC operation. */
54 
55 } HASH_InitTypeDef;
56 
57 /**
58   * @brief HAL State structures definition
59   */
60 typedef enum
61 {
62   HAL_HASH_STATE_RESET             = 0x00U,    /*!< Peripheral is not initialized            */
63   HAL_HASH_STATE_READY             = 0x01U,    /*!< Peripheral Initialized and ready for use */
64   HAL_HASH_STATE_BUSY              = 0x02U,    /*!< Processing (hashing) is ongoing          */
65   HAL_HASH_STATE_TIMEOUT           = 0x06U,    /*!< Timeout state                            */
66   HAL_HASH_STATE_ERROR             = 0x07U,    /*!< Error state                              */
67   HAL_HASH_STATE_SUSPENDED         = 0x08U     /*!< Suspended state                          */
68 } HAL_HASH_StateTypeDef;
69 
70 /**
71   * @brief HAL phase structures definition
72   */
73 typedef enum
74 {
75   HAL_HASH_PHASE_READY             = 0x01U,    /*!< HASH peripheral is ready to start                    */
76   HAL_HASH_PHASE_PROCESS           = 0x02U,    /*!< HASH peripheral is in HASH processing phase          */
77   HAL_HASH_PHASE_HMAC_STEP_1       = 0x03U,    /*!< HASH peripheral is in HMAC step 1 processing phase
78                                               (step 1 consists in entering the inner hash function key) */
79   HAL_HASH_PHASE_HMAC_STEP_2       = 0x04U,    /*!< HASH peripheral is in HMAC step 2 processing phase
80                                               (step 2 consists in entering the message text) */
81   HAL_HASH_PHASE_HMAC_STEP_3       = 0x05U     /*!< HASH peripheral is in HMAC step 3 processing phase
82                                               (step 3 consists in entering the outer hash function key) */
83 } HAL_HASH_PhaseTypeDef;
84 
85 /**
86   * @brief HAL HASH mode suspend definitions
87   */
88 typedef enum
89 {
90   HAL_HASH_SUSPEND_NONE            = 0x00U,    /*!< HASH peripheral suspension not requested */
91   HAL_HASH_SUSPEND                 = 0x01U     /*!< HASH peripheral suspension is requested  */
92 } HAL_HASH_SuspendTypeDef;
93 
94 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
95 /**
96   * @brief  HAL HASH common Callback ID enumeration definition
97   */
98 typedef enum
99 {
100   HAL_HASH_MSPINIT_CB_ID           = 0x00U,    /*!< HASH MspInit callback ID     */
101   HAL_HASH_MSPDEINIT_CB_ID         = 0x01U,    /*!< HASH MspDeInit callback ID   */
102   HAL_HASH_INPUTCPLT_CB_ID         = 0x02U,    /*!< HASH input completion callback ID */
103   HAL_HASH_DGSTCPLT_CB_ID          = 0x03U,    /*!< HASH digest computation completion callback ID */
104   HAL_HASH_ERROR_CB_ID             = 0x04U,    /*!< HASH error callback ID     */
105 } HAL_HASH_CallbackIDTypeDef;
106 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
107 
108 
109 /**
110   * @brief  HASH Handle Structure definition
111   */
112 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
113 typedef struct __HASH_HandleTypeDef
114 #else
115 typedef struct
116 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
117 {
118   HASH_InitTypeDef           Init;             /*!< HASH required parameters */
119 
120   uint8_t                    *pHashInBuffPtr;  /*!< Pointer to input buffer */
121 
122   uint8_t                    *pHashOutBuffPtr; /*!< Pointer to output buffer (digest) */
123 
124   uint8_t                    *pHashKeyBuffPtr; /*!< Pointer to key buffer (HMAC only) */
125 
126   uint8_t                    *pHashMsgBuffPtr; /*!< Pointer to message buffer (HMAC only) */
127 
128   uint32_t                   HashBuffSize;     /*!< Size of buffer to be processed */
129 
130   __IO uint32_t              HashInCount;      /*!< Counter of inputted data */
131 
132   __IO uint32_t              HashITCounter;    /*!< Counter of issued interrupts */
133 
134   __IO uint32_t              HashKeyCount;     /*!< Counter for Key inputted data (HMAC only) */
135 
136   HAL_StatusTypeDef          Status;           /*!< HASH peripheral status   */
137 
138   HAL_HASH_PhaseTypeDef      Phase;            /*!< HASH peripheral phase   */
139 
140   DMA_HandleTypeDef          *hdmain;          /*!< HASH In DMA Handle parameters */
141 
142   HAL_LockTypeDef            Lock;             /*!< Locking object */
143 
144   __IO HAL_HASH_StateTypeDef State;            /*!< HASH peripheral state */
145 
146   HAL_HASH_SuspendTypeDef    SuspendRequest;   /*!< HASH peripheral suspension request flag */
147 
148   FlagStatus                 DigestCalculationDisable;  /*!< Digest calculation phase skip (MDMAT bit control) for multi-buffers DMA-based HMAC computation */
149 
150   __IO uint32_t              NbWordsAlreadyPushed;      /*!< Numbers of words already pushed in FIFO before inputting new block */
151 
152   __IO  uint32_t             ErrorCode;        /*!< HASH Error code */
153 
154   __IO  uint32_t             Accumulation;     /*!< HASH multi buffers accumulation flag */
155 
156 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
157   void (* InCpltCallback)(struct __HASH_HandleTypeDef *hhash);         /*!< HASH input completion callback */
158 
159   void (* DgstCpltCallback)(struct __HASH_HandleTypeDef *hhash);       /*!< HASH digest computation completion callback */
160 
161   void (* ErrorCallback)(struct __HASH_HandleTypeDef *hhash);          /*!< HASH error callback */
162 
163   void (* MspInitCallback)(struct __HASH_HandleTypeDef *hhash);        /*!< HASH Msp Init callback */
164 
165   void (* MspDeInitCallback)(struct __HASH_HandleTypeDef *hhash);      /*!< HASH Msp DeInit callback */
166 
167 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
168 } HASH_HandleTypeDef;
169 
170 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
171 /**
172   * @brief  HAL HASH Callback pointer definition
173   */
174 typedef  void (*pHASH_CallbackTypeDef)(HASH_HandleTypeDef *hhash);  /*!< pointer to a HASH common callback functions */
175 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
176 
177 /**
178   * @}
179   */
180 
181 /* Exported constants --------------------------------------------------------*/
182 
183 /** @defgroup HASH_Exported_Constants  HASH Exported Constants
184   * @{
185   */
186 
187 /** @defgroup HASH_Algo_Selection   HASH algorithm selection
188   * @{
189   */
190 #define HASH_ALGOSELECTION_SHA1      0x00000000U /*!< HASH function is SHA1   */
191 #define HASH_ALGOSELECTION_MD5       HASH_CR_ALGO_0     /*!< HASH function is MD5    */
192 #define HASH_ALGOSELECTION_SHA224    HASH_CR_ALGO_1     /*!< HASH function is SHA224 */
193 #define HASH_ALGOSELECTION_SHA256    HASH_CR_ALGO       /*!< HASH function is SHA256 */
194 /**
195   * @}
196   */
197 
198 /** @defgroup HASH_Algorithm_Mode   HASH algorithm mode
199   * @{
200   */
201 #define HASH_ALGOMODE_HASH         0x00000000U /*!< Algorithm is HASH */
202 #define HASH_ALGOMODE_HMAC         HASH_CR_MODE           /*!< Algorithm is HMAC */
203 /**
204   * @}
205   */
206 
207 /** @defgroup HASH_Data_Type      HASH input data type
208   * @{
209   */
210 #define HASH_DATATYPE_32B          0x00000000U /*!< 32-bit data. No swapping                     */
211 #define HASH_DATATYPE_16B          HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped       */
212 #define HASH_DATATYPE_8B           HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped            */
213 #define HASH_DATATYPE_1B           HASH_CR_DATATYPE   /*!< 1-bit data. In the word all bits are swapped */
214 /**
215   * @}
216   */
217 
218 /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode   HMAC key length type
219   * @{
220   */
221 #define HASH_HMAC_KEYTYPE_SHORTKEY      0x00000000U /*!< HMAC Key size is <= 64 bytes */
222 #define HASH_HMAC_KEYTYPE_LONGKEY       HASH_CR_LKEY           /*!< HMAC Key size is > 64 bytes  */
223 /**
224   * @}
225   */
226 
227 /** @defgroup HASH_flags_definition  HASH flags definitions
228   * @{
229   */
230 #define HASH_FLAG_DINIS            HASH_SR_DINIS  /*!< 16 locations are free in the DIN : a new block can be entered in the Peripheral */
231 #define HASH_FLAG_DCIS             HASH_SR_DCIS   /*!< Digest calculation complete                                                     */
232 #define HASH_FLAG_DMAS             HASH_SR_DMAS   /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing                      */
233 #define HASH_FLAG_BUSY             HASH_SR_BUSY   /*!< The hash core is Busy, processing a block of data                               */
234 #define HASH_FLAG_DINNE            HASH_CR_DINNE  /*!< DIN not empty : the input buffer contains at least one word of data             */
235 
236 /**
237   * @}
238   */
239 
240 /** @defgroup HASH_interrupts_definition   HASH interrupts definitions
241   * @{
242   */
243 #define HASH_IT_DINI               HASH_IMR_DINIE  /*!< A new block can be entered into the input buffer (DIN) */
244 #define HASH_IT_DCI                HASH_IMR_DCIE   /*!< Digest calculation complete                            */
245 
246 /**
247   * @}
248   */
249 
250 /** @defgroup HASH_Error_Definition   HASH Error Definition
251   * @{
252   */
253 #define  HAL_HASH_ERROR_NONE             0x00000000U   /*!< No error                */
254 #define  HAL_HASH_ERROR_IT               0x00000001U   /*!< IT-based process error  */
255 #define  HAL_HASH_ERROR_DMA              0x00000002U   /*!< DMA-based process error */
256 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
257 #define  HAL_HASH_ERROR_INVALID_CALLBACK 0x00000004U   /*!< Invalid Callback error  */
258 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
259 /**
260   * @}
261   */
262 
263 /**
264   * @}
265   */
266 
267 /* Exported macros -----------------------------------------------------------*/
268 /** @defgroup HASH_Exported_Macros HASH Exported Macros
269   * @{
270   */
271 
272 /** @brief  Check whether or not the specified HASH flag is set.
273   * @param  __FLAG__ specifies the flag to check.
274   *        This parameter can be one of the following values:
275   *            @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
276   *            @arg @ref HASH_FLAG_DCIS Digest calculation complete.
277   *            @arg @ref HASH_FLAG_DMAS DMA interface is enabled (DMAE=1) or a transfer is ongoing.
278   *            @arg @ref HASH_FLAG_BUSY The hash core is Busy : processing a block of data.
279   *            @arg @ref HASH_FLAG_DINNE DIN not empty : the input buffer contains at least one word of data.
280   * @retval The new state of __FLAG__ (TRUE or FALSE).
281   */
282 #define __HAL_HASH_GET_FLAG(__FLAG__)  (((__FLAG__) > 8U)  ?                    \
283                                         ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
284                                         ((HASH->SR & (__FLAG__)) == (__FLAG__)) )
285 
286 
287 /** @brief  Clear the specified HASH flag.
288   * @param  __FLAG__ specifies the flag to clear.
289   *        This parameter can be one of the following values:
290   *            @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
291   *            @arg @ref HASH_FLAG_DCIS Digest calculation complete
292   * @retval None
293   */
294 #define __HAL_HASH_CLEAR_FLAG(__FLAG__) CLEAR_BIT(HASH->SR, (__FLAG__))
295 
296 
297 /** @brief  Enable the specified HASH interrupt.
298   * @param  __INTERRUPT__ specifies the HASH interrupt source to enable.
299   *          This parameter can be one of the following values:
300   *            @arg @ref HASH_IT_DINI  A new block can be entered into the input buffer (DIN)
301   *            @arg @ref HASH_IT_DCI   Digest calculation complete
302   * @retval None
303   */
304 #define __HAL_HASH_ENABLE_IT(__INTERRUPT__)   SET_BIT(HASH->IMR, (__INTERRUPT__))
305 
306 /** @brief  Disable the specified HASH interrupt.
307   * @param  __INTERRUPT__ specifies the HASH interrupt source to disable.
308   *          This parameter can be one of the following values:
309   *            @arg @ref HASH_IT_DINI  A new block can be entered into the input buffer (DIN)
310   *            @arg @ref HASH_IT_DCI   Digest calculation complete
311   * @retval None
312   */
313 #define __HAL_HASH_DISABLE_IT(__INTERRUPT__)   CLEAR_BIT(HASH->IMR, (__INTERRUPT__))
314 
315 /** @brief Reset HASH handle state.
316   * @param  __HANDLE__ HASH handle.
317   * @retval None
318   */
319 
320 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
321 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) do{\
322                                                       (__HANDLE__)->State = HAL_HASH_STATE_RESET;\
323                                                       (__HANDLE__)->MspInitCallback = NULL;      \
324                                                       (__HANDLE__)->MspDeInitCallback = NULL;    \
325                                                      }while(0)
326 #else
327 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
328 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
329 
330 
331 /** @brief Reset HASH handle status.
332   * @param  __HANDLE__ HASH handle.
333   * @retval None
334   */
335 #define __HAL_HASH_RESET_HANDLE_STATUS(__HANDLE__) ((__HANDLE__)->Status = HAL_OK)
336 
337 /**
338   * @brief  Enable the multi-buffer DMA transfer mode.
339   * @note   This bit is set when hashing large files when multiple DMA transfers are needed.
340   * @retval None
341   */
342 #define __HAL_HASH_SET_MDMAT()          SET_BIT(HASH->CR, HASH_CR_MDMAT)
343 
344 /**
345   * @brief  Disable the multi-buffer DMA transfer mode.
346   * @retval None
347   */
348 #define __HAL_HASH_RESET_MDMAT()        CLEAR_BIT(HASH->CR, HASH_CR_MDMAT)
349 
350 
351 /**
352   * @brief Start the digest computation.
353   * @retval None
354   */
355 #define __HAL_HASH_START_DIGEST()       SET_BIT(HASH->STR, HASH_STR_DCAL)
356 
357 /**
358   * @brief Set the number of valid bits in the last word written in data register DIN.
359   * @param  __SIZE__ size in bytes of last data written in Data register.
360   * @retval None
361   */
362 #define  __HAL_HASH_SET_NBVALIDBITS(__SIZE__)    MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8U * ((__SIZE__) % 4U))
363 
364 /**
365   * @brief Reset the HASH core.
366   * @retval None
367   */
368 #define __HAL_HASH_INIT()       SET_BIT(HASH->CR, HASH_CR_INIT)
369 
370 /**
371   * @}
372   */
373 
374 
375 /* Private macros --------------------------------------------------------*/
376 /** @defgroup HASH_Private_Macros   HASH Private Macros
377   * @{
378   */
379 /**
380   * @brief  Return digest length in bytes.
381   * @retval Digest length
382   */
383 #define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1)   ?  20U : \
384                               ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA224) ?  28U : \
385                                ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA256) ?  32U : 16U ) ) )
386 /**
387   * @brief  Return number of words already pushed in the FIFO.
388   * @retval Number of words already pushed in the FIFO
389   */
390 #define HASH_NBW_PUSHED() ((READ_BIT(HASH->CR, HASH_CR_NBW)) >> 8U)
391 
392 /**
393   * @brief Ensure that HASH input data type is valid.
394   * @param __DATATYPE__ HASH input data type.
395   * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid)
396   */
397 #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
398                                         ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
399                                         ((__DATATYPE__) == HASH_DATATYPE_8B) || \
400                                         ((__DATATYPE__) == HASH_DATATYPE_1B))
401 
402 /**
403   * @brief Ensure that input data buffer size is valid for multi-buffer HASH
404   *        processing in DMA mode.
405   * @note  This check is valid only for multi-buffer HASH processing in DMA mode.
406   * @param __SIZE__ input data buffer size.
407   * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
408   */
409 #define IS_HASH_DMA_MULTIBUFFER_SIZE(__SIZE__)  ((READ_BIT(HASH->CR, HASH_CR_MDMAT) == 0U) || (((__SIZE__) % 4U) == 0U))
410 
411 /**
412   * @brief Ensure that input data buffer size is valid for multi-buffer HMAC
413   *        processing in DMA mode.
414   * @note  This check is valid only for multi-buffer HMAC processing in DMA mode.
415   * @param __HANDLE__ HASH handle.
416   * @param __SIZE__ input data buffer size.
417   * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
418   */
419 #define IS_HMAC_DMA_MULTIBUFFER_SIZE(__HANDLE__,__SIZE__)  ((((__HANDLE__)->DigestCalculationDisable) == RESET)\
420                                                             || (((__SIZE__) % 4U) == 0U))
421 /**
422   * @brief Ensure that handle phase is set to HASH processing.
423   * @param __HANDLE__ HASH handle.
424   * @retval SET (handle phase is set to HASH processing) or RESET (handle phase is not set to HASH processing)
425   */
426 #define IS_HASH_PROCESSING(__HANDLE__)  ((__HANDLE__)->Phase == HAL_HASH_PHASE_PROCESS)
427 
428 /**
429   * @brief Ensure that handle phase is set to HMAC processing.
430   * @param __HANDLE__ HASH handle.
431   * @retval SET (handle phase is set to HMAC processing) or RESET (handle phase is not set to HMAC processing)
432   */
433 #define IS_HMAC_PROCESSING(__HANDLE__)  (((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_1) || \
434                                          ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_2) || \
435                                          ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_3))
436 
437 /**
438   * @}
439   */
440 
441 /* Include HASH HAL Extended module */
442 #include "stm32h7xx_hal_hash_ex.h"
443 /* Exported functions --------------------------------------------------------*/
444 
445 /** @addtogroup HASH_Exported_Functions HASH Exported Functions
446   * @{
447   */
448 
449 /** @addtogroup HASH_Exported_Functions_Group1 Initialization and de-initialization functions
450   * @{
451   */
452 
453 /* Initialization/de-initialization methods  **********************************/
454 HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
455 HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
456 void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
457 void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
458 void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
459 void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
460 void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
461 /* Callbacks Register/UnRegister functions  ***********************************/
462 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
463 HAL_StatusTypeDef HAL_HASH_RegisterCallback(HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID,
464                                             pHASH_CallbackTypeDef pCallback);
465 HAL_StatusTypeDef HAL_HASH_UnRegisterCallback(HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID);
466 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
467 
468 
469 /**
470   * @}
471   */
472 
473 /** @addtogroup HASH_Exported_Functions_Group2 HASH processing functions in polling mode
474   * @{
475   */
476 
477 
478 /* HASH processing using polling  *********************************************/
479 HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
480                                       uint32_t Timeout);
481 HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
482                                      uint32_t Timeout);
483 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
484 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
485 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
486                                           uint8_t *pOutBuffer, uint32_t Timeout);
487 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
488                                            uint8_t *pOutBuffer, uint32_t Timeout);
489 
490 
491 /**
492   * @}
493   */
494 
495 /** @addtogroup HASH_Exported_Functions_Group3 HASH processing functions in interrupt mode
496   * @{
497   */
498 
499 /* HASH processing using IT  **************************************************/
500 HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
501                                          uint8_t *pOutBuffer);
502 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
503 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
504                                               uint8_t *pOutBuffer);
505 HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
506                                         uint8_t *pOutBuffer);
507 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
508 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
509                                              uint8_t *pOutBuffer);
510 void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
511 /**
512   * @}
513   */
514 
515 /** @addtogroup HASH_Exported_Functions_Group4 HASH processing functions in DMA mode
516   * @{
517   */
518 
519 /* HASH processing using DMA  *************************************************/
520 HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
521 HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
522 HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
523 HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
524 
525 /**
526   * @}
527   */
528 
529 /** @addtogroup HASH_Exported_Functions_Group5 HMAC processing functions in polling mode
530   * @{
531   */
532 
533 /* HASH-MAC processing using polling  *****************************************/
534 HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
535                                       uint32_t Timeout);
536 HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
537                                      uint32_t Timeout);
538 
539 /**
540   * @}
541   */
542 
543 /** @addtogroup HASH_Exported_Functions_Group6 HMAC processing functions in interrupt mode
544   * @{
545   */
546 
547 HAL_StatusTypeDef HAL_HMAC_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
548                                         uint8_t *pOutBuffer);
549 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
550                                          uint8_t *pOutBuffer);
551 
552 /**
553   * @}
554   */
555 
556 /** @addtogroup HASH_Exported_Functions_Group7 HMAC processing functions in DMA mode
557   * @{
558   */
559 
560 /* HASH-HMAC processing using DMA  ********************************************/
561 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
562 HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
563 
564 /**
565   * @}
566   */
567 
568 /** @addtogroup HASH_Exported_Functions_Group8 Peripheral states functions
569   * @{
570   */
571 
572 
573 /* Peripheral State methods  **************************************************/
574 HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
575 HAL_StatusTypeDef HAL_HASH_GetStatus(HASH_HandleTypeDef *hhash);
576 void HAL_HASH_ContextSaving(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer);
577 void HAL_HASH_ContextRestoring(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer);
578 void HAL_HASH_SwFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
579 HAL_StatusTypeDef HAL_HASH_DMAFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
580 uint32_t HAL_HASH_GetError(HASH_HandleTypeDef *hhash);
581 
582 /**
583   * @}
584   */
585 
586 /**
587   * @}
588   */
589 
590 /* Private functions -----------------------------------------------------------*/
591 
592 /** @addtogroup HASH_Private_Functions HASH Private Functions
593   * @{
594   */
595 
596 /* Private functions */
597 HAL_StatusTypeDef HASH_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
598                              uint32_t Timeout, uint32_t Algorithm);
599 HAL_StatusTypeDef HASH_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
600 HAL_StatusTypeDef HASH_Accumulate_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
601 HAL_StatusTypeDef HASH_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
602                                 uint32_t Algorithm);
603 HAL_StatusTypeDef HASH_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
604 HAL_StatusTypeDef HASH_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
605 HAL_StatusTypeDef HMAC_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
606                              uint32_t Timeout, uint32_t Algorithm);
607 HAL_StatusTypeDef HMAC_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
608                                 uint32_t Algorithm);
609 HAL_StatusTypeDef HMAC_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
610 
611 /**
612   * @}
613   */
614 
615 /**
616   * @}
617   */
618 #endif /*  HASH*/
619 /**
620   * @}
621   */
622 
623 
624 #ifdef __cplusplus
625 }
626 #endif
627 
628 
629 #endif /* STM32H7xx_HAL_HASH_H */
630 
631