1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx_hal_hash_ex.c
4   * @author  MCD Application Team
5   * @brief   Extended HASH HAL module driver.
6   *          This file provides firmware functions to manage the following
7   *          functionalities of the HASH peripheral for SHA-224 and SHA-256
8   *          alogrithms:
9   *           + HASH or HMAC processing in polling mode
10   *           + HASH or HMAC processing in interrupt mode
11   *           + HASH or HMAC processing in DMA mode
12   *         Additionally, this file provides functions to manage HMAC
13   *         multi-buffer DMA-based processing for MD-5, SHA-1, SHA-224
14   *         and SHA-256.
15   *
16   *
17   ******************************************************************************
18   * @attention
19   *
20   * Copyright (c) 2019 STMicroelectronics.
21   * All rights reserved.
22   *
23   * This software is licensed under terms that can be found in the LICENSE file
24   * in the root directory of this software component.
25   * If no LICENSE file comes with this software, it is provided AS-IS.
26   *
27   ******************************************************************************
28   @verbatim
29  ===============================================================================
30                      ##### HASH peripheral extended features  #####
31  ===============================================================================
32     [..]
33     The SHA-224 and SHA-256 HASH and HMAC processing can be carried out exactly
34     the same way as for SHA-1 or MD-5 algorithms.
35     (#) Three modes are available.
36         (##) Polling mode: processing APIs are blocking functions
37              i.e. they process the data and wait till the digest computation is finished,
38              e.g. HAL_HASHEx_xxx_Start()
39         (##) Interrupt mode: processing APIs are not blocking functions
40                 i.e. they process the data under interrupt,
41                 e.g. HAL_HASHEx_xxx_Start_IT()
42         (##) DMA mode: processing APIs are not blocking functions and the CPU is
43              not used for data transfer i.e. the data transfer is ensured by DMA,
44                 e.g. HAL_HASHEx_xxx_Start_DMA(). Note that in DMA mode, a call to
45                 HAL_HASHEx_xxx_Finish() is then required to retrieve the digest.
46 
47    (#)Multi-buffer processing is possible in polling and DMA mode.
48         (##) In polling mode, only multi-buffer HASH processing is possible.
49              API HAL_HASHEx_xxx_Accumulate() must be called for each input buffer, except for the last one.
50              User must resort to HAL_HASHEx_xxx_Start() to enter the last one and retrieve as
51              well the computed digest.
52 
53         (##) In DMA mode, multi-buffer HASH and HMAC processing are possible.
54 
55               (+++) HASH processing: once initialization is done, MDMAT bit must be set thru __HAL_HASH_SET_MDMAT() macro.
56              From that point, each buffer can be fed to the IP thru HAL_HASHEx_xxx_Start_DMA() API.
57              Before entering the last buffer, reset the MDMAT bit with __HAL_HASH_RESET_MDMAT()
58              macro then wrap-up the HASH processing in feeding the last input buffer thru the
59              same API HAL_HASHEx_xxx_Start_DMA(). The digest can then be retrieved with a call to
60              API HAL_HASHEx_xxx_Finish().
61 
62              (+++) HMAC processing (MD-5, SHA-1, SHA-224 and SHA-256 must all resort to
63              extended functions): after initialization, the key and the first input buffer are entered
64              in the IP with the API HAL_HMACEx_xxx_Step1_2_DMA(). This carries out HMAC step 1 and
65              starts step 2.
66              The following buffers are next entered with the API  HAL_HMACEx_xxx_Step2_DMA(). At this
67              point, the HMAC processing is still carrying out step 2.
68              Then, step 2 for the last input buffer and step 3 are carried out by a single call
69              to HAL_HMACEx_xxx_Step2_3_DMA().
70 
71              The digest can finally be retrieved with a call to API HAL_HASH_xxx_Finish() for
72              MD-5 and SHA-1, to HAL_HASHEx_xxx_Finish() for SHA-224 and SHA-256.
73 
74 
75   @endverbatim
76   ******************************************************************************
77   */
78 
79 /* Includes ------------------------------------------------------------------*/
80 #include "stm32mp1xx_hal.h"
81 
82 
83 
84 
85 /** @addtogroup STM32MP1xx_HAL_Driver
86   * @{
87   */
88 #if defined (HASH1) || defined (HASH2)
89 
90 /** @defgroup HASHEx HASHEx
91   * @brief HASH HAL extended module driver.
92   * @{
93   */
94 #ifdef HAL_HASH_MODULE_ENABLED
95 /* Private typedef -----------------------------------------------------------*/
96 /* Private define ------------------------------------------------------------*/
97 /* Private functions ---------------------------------------------------------*/
98 
99 
100 /** @defgroup HASHEx_Exported_Functions HASH Extended Exported Functions
101   * @{
102   */
103 
104 /** @defgroup HASHEx_Exported_Functions_Group1 HASH extended processing functions in polling mode
105  *  @brief   HASH extended processing functions using polling mode.
106  *
107 @verbatim
108  ===============================================================================
109                ##### Polling mode HASH extended processing functions #####
110  ===============================================================================
111     [..]  This section provides functions allowing to calculate in polling mode
112           the hash value using one of the following algorithms:
113       (+) SHA224
114          (++) HAL_HASHEx_SHA224_Start()
115          (++) HAL_HASHEx_SHA224_Accumulate()
116       (+) SHA256
117          (++) HAL_HASHEx_SHA256_Start()
118          (++) HAL_HASHEx_SHA256_Accumulate()
119 
120     [..] For a single buffer to be hashed, user can resort to HAL_HASH_xxx_Start().
121 
122     [..]  In case of multi-buffer HASH processing (a single digest is computed while
123           several buffers are fed to the IP), the user can resort to successive calls
124           to HAL_HASHEx_xxx_Accumulate() and wrap-up the digest computation by a call
125           to HAL_HASHEx_xxx_Start().
126 
127 @endverbatim
128   * @{
129   */
130 
131 
132 /**
133   * @brief  Initialize the HASH peripheral in SHA224 mode, next process pInBuffer then
134   *         read the computed digest.
135   * @note   Digest is available in pOutBuffer.
136   * @param  hhash: HASH handle.
137   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
138   * @param  Size: length of the input buffer in bytes.
139   * @param  pOutBuffer: pointer to the computed digest. Digest size is 28 bytes.
140   * @param  Timeout: Timeout value
141   * @retval HAL status
142   */
HAL_HASHEx_SHA224_Start(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer,uint32_t Timeout)143 HAL_StatusTypeDef HAL_HASHEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout)
144 {
145   return HASH_Start(hhash, pInBuffer, Size, pOutBuffer, Timeout, HASH_ALGOSELECTION_SHA224);
146 }
147 
148 /**
149   * @brief  If not already done, initialize the HASH peripheral in SHA224 mode then
150   *         processes pInBuffer.
151   * @note   Consecutive calls to HAL_HASHEx_SHA224_Accumulate() can be used to feed
152   *         several input buffers back-to-back to the IP that will yield a single
153   *         HASH signature once all buffers have been entered. Wrap-up of input
154   *         buffers feeding and retrieval of digest is done by a call to
155   *         HAL_HASHEx_SHA224_Start().
156   * @note   Field hhash->Phase of HASH handle is tested to check whether or not
157   *         the IP has already been initialized.
158   * @note   Digest is not retrieved by this API, user must resort to HAL_HASHEx_SHA224_Start()
159   *         to read it, feeding at the same time the last input buffer to the IP.
160   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
161   *         HASH digest computation is corrupted. Only HAL_HASHEx_SHA224_Start() is able
162   *         to manage the ending buffer with a length in bytes not a multiple of 4.
163   * @param  hhash: HASH handle.
164   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
165   * @param  Size: length of the input buffer in bytes, must be a multiple of 4.
166   * @retval HAL status
167   */
HAL_HASHEx_SHA224_Accumulate(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)168 HAL_StatusTypeDef HAL_HASHEx_SHA224_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
169 {
170   return  HASH_Accumulate(hhash, pInBuffer, Size,HASH_ALGOSELECTION_SHA224);
171 }
172 
173 /**
174   * @brief  Initialize the HASH peripheral in SHA256 mode, next process pInBuffer then
175   *         read the computed digest.
176   * @note   Digest is available in pOutBuffer.
177   * @param  hhash: HASH handle.
178   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
179   * @param  Size: length of the input buffer in bytes.
180   * @param  pOutBuffer: pointer to the computed digest. Digest size is 32 bytes.
181   * @param  Timeout: Timeout value
182   * @retval HAL status
183   */
HAL_HASHEx_SHA256_Start(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer,uint32_t Timeout)184 HAL_StatusTypeDef HAL_HASHEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout)
185 {
186   return HASH_Start(hhash, pInBuffer, Size, pOutBuffer, Timeout, HASH_ALGOSELECTION_SHA256);
187 }
188 
189 /**
190   * @brief  If not already done, initialize the HASH peripheral in SHA256 mode then
191   *         processes pInBuffer.
192   * @note   Consecutive calls to HAL_HASHEx_SHA256_Accumulate() can be used to feed
193   *         several input buffers back-to-back to the IP that will yield a single
194   *         HASH signature once all buffers have been entered. Wrap-up of input
195   *         buffers feeding and retrieval of digest is done by a call to
196   *         HAL_HASHEx_SHA256_Start().
197   * @note   Field hhash->Phase of HASH handle is tested to check whether or not
198   *         the IP has already been initialized.
199   * @note   Digest is not retrieved by this API, user must resort to HAL_HASHEx_SHA256_Start()
200   *         to read it, feeding at the same time the last input buffer to the IP.
201   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
202   *         HASH digest computation is corrupted. Only HAL_HASHEx_SHA256_Start() is able
203   *         to manage the ending buffer with a length in bytes not a multiple of 4.
204   * @param  hhash: HASH handle.
205   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
206   * @param  Size: length of the input buffer in bytes, must be a multiple of 4.
207   * @retval HAL status
208   */
HAL_HASHEx_SHA256_Accumulate(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)209 HAL_StatusTypeDef HAL_HASHEx_SHA256_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
210 {
211   return  HASH_Accumulate(hhash, pInBuffer, Size,HASH_ALGOSELECTION_SHA256);
212 }
213 
214 
215 /**
216   * @}
217   */
218 
219 /** @defgroup HASHEx_Exported_Functions_Group2 HASH extended processing functions in interrupt mode
220  *  @brief   HASH extended processing functions using interrupt mode.
221  *
222 @verbatim
223  ===============================================================================
224           ##### Interruption mode HASH extended processing functions #####
225  ===============================================================================
226     [..]  This section provides functions allowing to calculate in interrupt mode
227           the hash value using one of the following algorithms:
228       (+) SHA224
229          (++) HAL_HASHEx_SHA224_Start_IT()
230       (+) SHA256
231          (++) HAL_HASHEx_SHA256_Start_IT()
232 
233 @endverbatim
234   * @{
235   */
236 
237 
238 /**
239   * @brief  Initialize the HASH peripheral in SHA224 mode, next process pInBuffer then
240   *         read the computed digest in interruption mode.
241   * @note   Digest is available in pOutBuffer.
242   * @param  hhash: HASH handle.
243   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
244   * @param  Size: length of the input buffer in bytes.
245   * @param  pOutBuffer: pointer to the computed digest. Digest size is 28 bytes.
246   * @retval HAL status
247   */
HAL_HASHEx_SHA224_Start_IT(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer)248 HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer)
249 {
250   return HASH_Start_IT(hhash, pInBuffer, Size, pOutBuffer,HASH_ALGOSELECTION_SHA224);
251 }
252 
253 /**
254   * @brief  Initialize the HASH peripheral in SHA256 mode, next process pInBuffer then
255   *         read the computed digest in interruption mode.
256   * @note   Digest is available in pOutBuffer.
257   * @param  hhash: HASH handle.
258   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
259   * @param  Size: length of the input buffer in bytes.
260   * @param  pOutBuffer: pointer to the computed digest. Digest size is 32 bytes.
261   * @retval HAL status
262   */
HAL_HASHEx_SHA256_Start_IT(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer)263 HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer)
264 {
265   return HASH_Start_IT(hhash, pInBuffer, Size, pOutBuffer,HASH_ALGOSELECTION_SHA256);
266 }
267 
268 /**
269   * @}
270   */
271 
272 /** @defgroup HASHEx_Exported_Functions_Group3 HASH extended processing functions in DMA mode
273  *  @brief   HASH extended processing functions using DMA mode.
274  *
275 @verbatim
276  ===============================================================================
277                 ##### DMA mode HASH extended  processing functionss #####
278  ===============================================================================
279     [..]  This section provides functions allowing to calculate in DMA mode
280           the hash value using one of the following algorithms:
281       (+) SHA224
282          (++) HAL_HASHEx_SHA224_Start_DMA()
283          (++) HAL_HASHEx_SHA224_Finish()
284       (+) SHA256
285          (++) HAL_HASHEx_SHA256_Start_DMA()
286          (++) HAL_HASHEx_SHA256_Finish()
287 
288     [..]  When resorting to DMA mode to enter the data in the IP, user must resort
289           to  HAL_HASHEx_xxx_Start_DMA() then read the resulting digest with
290           HAL_HASHEx_xxx_Finish().
291 
292     [..]  In case of multi-buffer HASH processing, MDMAT bit must first be set before
293           the successive calls to HAL_HASHEx_xxx_Start_DMA(). Then, MDMAT bit needs to be
294           reset before the last call to HAL_HASHEx_xxx_Start_DMA(). Digest is finally
295           retrieved thanks to HAL_HASHEx_xxx_Finish().
296 
297 @endverbatim
298   * @{
299   */
300 
301 
302 
303 
304 /**
305   * @brief  Initialize the HASH peripheral in SHA224 mode then initiate a DMA transfer
306   *         to feed the input buffer to the IP.
307   * @note   Once the DMA transfer is finished, HAL_HASHEx_SHA224_Finish() API must
308   *         be called to retrieve the computed digest.
309   * @param  hhash: HASH handle.
310   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
311   * @param  Size: length of the input buffer in bytes.
312   * @retval HAL status
313   */
HAL_HASHEx_SHA224_Start_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)314 HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
315 {
316   return HASH_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA224);
317 }
318 
319 /**
320   * @brief  Return the computed digest in SHA224 mode.
321   * @note   The API waits for DCIS to be set then reads the computed digest.
322   * @note   HAL_HASHEx_SHA224_Finish() can be used as well to retrieve the digest in
323   *         HMAC SHA224 mode.
324   * @param  hhash: HASH handle.
325   * @param  pOutBuffer: pointer to the computed digest. Digest size is 28 bytes.
326   * @param  Timeout: Timeout value.
327   * @retval HAL status
328   */
HAL_HASHEx_SHA224_Finish(HASH_HandleTypeDef * hhash,uint8_t * pOutBuffer,uint32_t Timeout)329 HAL_StatusTypeDef HAL_HASHEx_SHA224_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout)
330 {
331    return HASH_Finish(hhash, pOutBuffer, Timeout);
332 }
333 
334 /**
335   * @brief  Initialize the HASH peripheral in SHA256 mode then initiate a DMA transfer
336   *         to feed the input buffer to the IP.
337   * @note   Once the DMA transfer is finished, HAL_HASHEx_SHA256_Finish() API must
338   *         be called to retrieve the computed digest.
339   * @param  hhash: HASH handle.
340   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
341   * @param  Size: length of the input buffer in bytes.
342   * @retval HAL status
343   */
HAL_HASHEx_SHA256_Start_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)344 HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
345 {
346   return HASH_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA256);
347 }
348 
349 /**
350   * @brief  Return the computed digest in SHA256 mode.
351   * @note   The API waits for DCIS to be set then reads the computed digest.
352   * @note   HAL_HASHEx_SHA256_Finish() can be used as well to retrieve the digest in
353   *         HMAC SHA256 mode.
354   * @param  hhash: HASH handle.
355   * @param  pOutBuffer: pointer to the computed digest. Digest size is 32 bytes.
356   * @param  Timeout: Timeout value.
357   * @retval HAL status
358   */
HAL_HASHEx_SHA256_Finish(HASH_HandleTypeDef * hhash,uint8_t * pOutBuffer,uint32_t Timeout)359 HAL_StatusTypeDef HAL_HASHEx_SHA256_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout)
360 {
361    return HASH_Finish(hhash, pOutBuffer, Timeout);
362 }
363 
364 /**
365   * @}
366   */
367 
368 /** @defgroup HASHEx_Exported_Functions_Group4 HMAC extended processing functions in polling mode
369  *  @brief   HMAC extended processing functions using polling mode.
370  *
371 @verbatim
372  ===============================================================================
373              ##### Polling mode HMAC extended processing functions #####
374  ===============================================================================
375     [..]  This section provides functions allowing to calculate in polling mode
376           the HMAC value using one of the following algorithms:
377       (+) SHA224
378          (++) HAL_HMACEx_SHA224_Start()
379       (+) SHA256
380          (++) HAL_HMACEx_SHA256_Start()
381 
382 @endverbatim
383   * @{
384   */
385 
386 
387 
388 /**
389   * @brief  Initialize the HASH peripheral in HMAC SHA224 mode, next process pInBuffer then
390   *         read the computed digest.
391   * @note   Digest is available in pOutBuffer.
392   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
393   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
394   * @param  hhash: HASH handle.
395   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
396   * @param  Size: length of the input buffer in bytes.
397   * @param  pOutBuffer: pointer to the computed digest. Digest size is 28 bytes.
398   * @param  Timeout: Timeout value.
399   * @retval HAL status
400   */
HAL_HMACEx_SHA224_Start(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer,uint32_t Timeout)401 HAL_StatusTypeDef HAL_HMACEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout)
402 {
403   return HMAC_Start(hhash, pInBuffer, Size, pOutBuffer, Timeout, HASH_ALGOSELECTION_SHA224);
404 }
405 
406 /**
407   * @brief  Initialize the HASH peripheral in HMAC SHA256 mode, next process pInBuffer then
408   *         read the computed digest.
409   * @note   Digest is available in pOutBuffer.
410   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
411   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
412   * @param  hhash: HASH handle.
413   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
414   * @param  Size: length of the input buffer in bytes.
415   * @param  pOutBuffer: pointer to the computed digest. Digest size is 32 bytes.
416   * @param  Timeout: Timeout value.
417   * @retval HAL status
418   */
HAL_HMACEx_SHA256_Start(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer,uint32_t Timeout)419 HAL_StatusTypeDef HAL_HMACEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout)
420 {
421   return HMAC_Start(hhash, pInBuffer, Size, pOutBuffer, Timeout, HASH_ALGOSELECTION_SHA256);
422 }
423 
424 /**
425   * @}
426   */
427 
428 
429 /** @defgroup HASHEx_Exported_Functions_Group5 HMAC extended processing functions in interrupt mode
430  *  @brief   HMAC extended processing functions using interruption mode.
431  *
432 @verbatim
433  ===============================================================================
434              ##### Interrupt mode HMAC extended processing functions #####
435  ===============================================================================
436     [..]  This section provides functions allowing to calculate in interrupt mode
437           the HMAC value using one of the following algorithms:
438       (+) SHA224
439          (++) HAL_HMACEx_SHA224_Start_IT()
440       (+) SHA256
441          (++) HAL_HMACEx_SHA256_Start_IT()
442 
443 @endverbatim
444   * @{
445   */
446 
447 
448 
449 /**
450   * @brief  Initialize the HASH peripheral in HMAC SHA224 mode, next process pInBuffer then
451   *         read the computed digest in interrupt mode.
452   * @note   Digest is available in pOutBuffer.
453   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
454   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
455   * @param  hhash: HASH handle.
456   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
457   * @param  Size: length of the input buffer in bytes.
458   * @param  pOutBuffer: pointer to the computed digest. Digest size is 28 bytes.
459   * @retval HAL status
460   */
HAL_HMACEx_SHA224_Start_IT(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer)461 HAL_StatusTypeDef HAL_HMACEx_SHA224_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer)
462 {
463   return  HMAC_Start_IT(hhash, pInBuffer, Size, pOutBuffer, HASH_ALGOSELECTION_SHA224);
464 }
465 
466 /**
467   * @brief  Initialize the HASH peripheral in HMAC SHA256 mode, next process pInBuffer then
468   *         read the computed digest in interrupt mode.
469   * @note   Digest is available in pOutBuffer.
470   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
471   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
472   * @param  hhash: HASH handle.
473   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
474   * @param  Size: length of the input buffer in bytes.
475   * @param  pOutBuffer: pointer to the computed digest. Digest size is 32 bytes.
476   * @retval HAL status
477   */
HAL_HMACEx_SHA256_Start_IT(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size,uint8_t * pOutBuffer)478 HAL_StatusTypeDef HAL_HMACEx_SHA256_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer)
479 {
480   return  HMAC_Start_IT(hhash, pInBuffer, Size, pOutBuffer, HASH_ALGOSELECTION_SHA256);
481 }
482 
483 
484 
485 
486 /**
487   * @}
488   */
489 
490 
491 /** @defgroup HASHEx_Exported_Functions_Group6 HMAC extended processing functions in DMA mode
492  *  @brief   HMAC extended processing functions using DMA mode.
493  *
494 @verbatim
495  ===============================================================================
496               ##### DMA mode HMAC extended processing functions #####
497  ===============================================================================
498     [..]  This section provides functions allowing to calculate in DMA mode
499           the HMAC value using one of the following algorithms:
500       (+) SHA224
501          (++) HAL_HMACEx_SHA224_Start_DMA()
502       (+) SHA256
503          (++) HAL_HMACEx_SHA256_Start_DMA()
504 
505     [..]  When resorting to DMA mode to enter the data in the IP for HMAC processing,
506           user must resort to  HAL_HMACEx_xxx_Start_DMA() then read the resulting digest
507           with HAL_HASHEx_xxx_Finish().
508 
509 
510 @endverbatim
511   * @{
512   */
513 
514 
515 
516 /**
517   * @brief  Initialize the HASH peripheral in HMAC SHA224 mode then initiate the required
518   *         DMA transfers to feed the key and the input buffer to the IP.
519   * @note   Once the DMA transfers are finished (indicated by hhash->State set back
520   *         to HAL_HASH_STATE_READY), HAL_HASHEx_SHA224_Finish() API must be called to retrieve
521   *         the computed digest.
522   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
523   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
524   * @note   If MDMAT bit is set before calling this function (multi-buffer
525   *          HASH processing case), the input buffer size (in bytes) must be
526   *          a multiple of 4 otherwise, the HASH digest computation is corrupted.
527   *          For the processing of the last buffer of the thread, MDMAT bit must
528   *          be reset and the buffer length (in bytes) doesn't have to be a
529   *          multiple of 4.
530   * @param  hhash: HASH handle.
531   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
532   * @param  Size: length of the input buffer in bytes.
533   * @retval HAL status
534   */
HAL_HMACEx_SHA224_Start_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)535 HAL_StatusTypeDef HAL_HMACEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
536 {
537   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA224);
538 }
539 
540 /**
541   * @brief  Initialize the HASH peripheral in HMAC SHA224 mode then initiate the required
542   *         DMA transfers to feed the key and the input buffer to the IP.
543   * @note   Once the DMA transfers are finished (indicated by hhash->State set back
544   *         to HAL_HASH_STATE_READY), HAL_HASHEx_SHA256_Finish() API must be called to retrieve
545   *         the computed digest.
546   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
547   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
548   * @note   If MDMAT bit is set before calling this function (multi-buffer
549   *          HASH processing case), the input buffer size (in bytes) must be
550   *          a multiple of 4 otherwise, the HASH digest computation is corrupted.
551   *          For the processing of the last buffer of the thread, MDMAT bit must
552   *          be reset and the buffer length (in bytes) doesn't have to be a
553   *          multiple of 4.
554   * @param  hhash: HASH handle.
555   * @param  pInBuffer: pointer to the input buffer (buffer to be hashed).
556   * @param  Size: length of the input buffer in bytes.
557   * @retval HAL status
558   */
HAL_HMACEx_SHA256_Start_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)559 HAL_StatusTypeDef HAL_HMACEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
560 {
561   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA256);
562 }
563 
564 
565 /**
566   * @}
567   */
568 
569 /** @defgroup HASHEx_Exported_Functions_Group7 Multi-buffer HMAC extended processing functions in DMA mode
570  *  @brief   HMAC extended processing functions in multi-buffer DMA mode.
571  *
572 @verbatim
573  ===============================================================================
574       ##### Multi-buffer DMA mode HMAC extended processing functions #####
575  ===============================================================================
576     [..]  This section provides functions to manage HMAC multi-buffer
577           DMA-based processing for MD5, SHA1, SHA224 and SHA256 algorithms.
578       (+) MD5
579          (++) HAL_HMACEx_MD5_Step1_2_DMA()
580          (++) HAL_HMACEx_MD5_Step2_DMA()
581          (++) HAL_HMACEx_MD5_Step2_3_DMA()
582       (+) SHA1
583          (++) HAL_HMACEx_SHA1_Step1_2_DMA()
584          (++) HAL_HMACEx_SHA1_Step2_DMA()
585          (++) HAL_HMACEx_SHA1_Step2_3_DMA()
586 
587       (+) SHA256
588          (++) HAL_HMACEx_SHA224_Step1_2_DMA()
589          (++) HAL_HMACEx_SHA224_Step2_DMA()
590          (++) HAL_HMACEx_SHA224_Step2_3_DMA()
591       (+) SHA256
592          (++) HAL_HMACEx_SHA256_Step1_2_DMA()
593          (++) HAL_HMACEx_SHA256_Step2_DMA()
594          (++) HAL_HMACEx_SHA256_Step2_3_DMA()
595 
596     [..]  User must first start-up the multi-buffer DMA-based HMAC computation in
597           calling HAL_HMACEx_xxx_Step1_2_DMA(). This carries out HMAC step 1 and
598           intiates step 2 with the first input buffer.
599 
600     [..]  The following buffers are next fed to the IP with a call to the API
601           HAL_HMACEx_xxx_Step2_DMA(). There may be several consecutive calls
602           to this API.
603 
604     [..]  Multi-buffer DMA-based HMAC computation is wrapped up by a call to
605           HAL_HMACEx_xxx_Step2_3_DMA(). This finishes step 2 in feeding the last input
606           buffer to the IP then carries out step 3.
607 
608     [..]  Digest is retrieved by a call to HAL_HASH_xxx_Finish() for MD-5 or
609           SHA-1, to HAL_HASHEx_xxx_Finish() for SHA-224 or SHA-256.
610 
611     [..]  If only two buffers need to be consecutively processed, a call to
612           HAL_HMACEx_xxx_Step1_2_DMA() followed by a call to HAL_HMACEx_xxx_Step2_3_DMA()
613           is sufficient.
614 
615 @endverbatim
616   * @{
617   */
618 
619 /**
620   * @brief  MD5 HMAC step 1 completion and step 2 start in multi-buffer DMA mode.
621   * @note   Step 1 consists in writing the inner hash function key in the IP,
622   *         step 2 consists in writing the message text.
623   * @note   The API carries out the HMAC step 1 then starts step 2 with
624   *         the first buffer entered to the IP. DCAL bit is not automatically set after
625   *         the message buffer feeding, allowing other messages DMA transfers to occur.
626   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
627   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
628   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
629   *         HASH digest computation is corrupted.
630   * @param  hhash: HASH handle.
631   * @param  pInBuffer: pointer to the input buffer (message buffer).
632   * @param  Size: length of the input buffer in bytes.
633   * @retval HAL status
634   */
HAL_HMACEx_MD5_Step1_2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)635 HAL_StatusTypeDef HAL_HMACEx_MD5_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
636 {
637   hhash->DigestCalculationDisable = SET;
638   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_MD5);
639 }
640 
641 /**
642   * @brief  MD5 HMAC step 2 in multi-buffer DMA mode.
643   * @note   Step 2 consists in writing the message text in the IP.
644   * @note   The API carries on the HMAC step 2, applied to the buffer entered as input
645   *         parameter. DCAL bit is not automatically set after the message buffer feeding,
646   *         allowing other messages DMA transfers to occur.
647   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
648   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
649   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
650   *         HASH digest computation is corrupted.
651   * @param  hhash: HASH handle.
652   * @param  pInBuffer: pointer to the input buffer (message buffer).
653   * @param  Size: length of the input buffer in bytes.
654   * @retval HAL status
655   */
HAL_HMACEx_MD5_Step2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)656 HAL_StatusTypeDef HAL_HMACEx_MD5_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
657 {
658   if (hhash->DigestCalculationDisable != SET)
659   {
660     return HAL_ERROR;
661   }
662   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_MD5);
663 }
664 
665 /**
666   * @brief  MD5 HMAC step 2 wrap-up and step 3 completion in multi-buffer DMA mode.
667   * @note   Step 2 consists in writing the message text in the IP,
668   *         step 3 consists in writing the outer hash function key.
669   * @note   The API wraps up the HMAC step 2 in processing the buffer entered as input
670   *         parameter (the input buffer must be the last one of the multi-buffer thread)
671   *         then carries out HMAC step 3.
672   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
673   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
674   * @note   Once the DMA transfers are finished (indicated by hhash->State set back
675   *         to HAL_HASH_STATE_READY), HAL_HASHEx_SHA256_Finish() API must be called to retrieve
676   *         the computed digest.
677   * @param  hhash: HASH handle.
678   * @param  pInBuffer: pointer to the input buffer (message buffer).
679   * @param  Size: length of the input buffer in bytes.
680   * @retval HAL status
681   */
HAL_HMACEx_MD5_Step2_3_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)682 HAL_StatusTypeDef HAL_HMACEx_MD5_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
683 {
684   hhash->DigestCalculationDisable = RESET;
685   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_MD5);
686 }
687 
688 
689 /**
690   * @brief  SHA1 HMAC step 1 completion and step 2 start in multi-buffer DMA mode.
691   * @note   Step 1 consists in writing the inner hash function key in the IP,
692   *         step 2 consists in writing the message text.
693   * @note   The API carries out the HMAC step 1 then starts step 2 with
694   *         the first buffer entered to the IP. DCAL bit is not automatically set after
695   *         the message buffer feeding, allowing other messages DMA transfers to occur.
696   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
697   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
698   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
699   *         HASH digest computation is corrupted.
700   * @param  hhash: HASH handle.
701   * @param  pInBuffer: pointer to the input buffer (message buffer).
702   * @param  Size: length of the input buffer in bytes.
703   * @retval HAL status
704   */
HAL_HMACEx_SHA1_Step1_2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)705 HAL_StatusTypeDef HAL_HMACEx_SHA1_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
706 {
707   hhash->DigestCalculationDisable = SET;
708   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA1);
709 }
710 
711 /**
712   * @brief  SHA1 HMAC step 2 in multi-buffer DMA mode.
713   * @note   Step 2 consists in writing the message text in the IP.
714   * @note   The API carries on the HMAC step 2, applied to the buffer entered as input
715   *         parameter. DCAL bit is not automatically set after the message buffer feeding,
716   *         allowing other messages DMA transfers to occur.
717   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
718   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
719   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
720   *         HASH digest computation is corrupted.
721   * @param  hhash: HASH handle.
722   * @param  pInBuffer: pointer to the input buffer (message buffer).
723   * @param  Size: length of the input buffer in bytes.
724   * @retval HAL status
725   */
HAL_HMACEx_SHA1_Step2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)726 HAL_StatusTypeDef HAL_HMACEx_SHA1_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
727 {
728   if (hhash->DigestCalculationDisable != SET)
729   {
730     return HAL_ERROR;
731   }
732   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA1);
733 }
734 
735 /**
736   * @brief  SHA1 HMAC step 2 wrap-up and step 3 completion in multi-buffer DMA mode.
737   * @note   Step 2 consists in writing the message text in the IP,
738   *         step 3 consists in writing the outer hash function key.
739   * @note   The API wraps up the HMAC step 2 in processing the buffer entered as input
740   *         parameter (the input buffer must be the last one of the multi-buffer thread)
741   *         then carries out HMAC step 3.
742   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
743   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
744   * @note   Once the DMA transfers are finished (indicated by hhash->State set back
745   *         to HAL_HASH_STATE_READY), HAL_HASHEx_SHA256_Finish() API must be called to retrieve
746   *         the computed digest.
747   * @param  hhash: HASH handle.
748   * @param  pInBuffer: pointer to the input buffer (message buffer).
749   * @param  Size: length of the input buffer in bytes.
750   * @retval HAL status
751   */
HAL_HMACEx_SHA1_Step2_3_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)752 HAL_StatusTypeDef HAL_HMACEx_SHA1_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
753 {
754   hhash->DigestCalculationDisable = RESET;
755   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA1);
756 }
757 
758 /**
759   * @brief  SHA224 HMAC step 1 completion and step 2 start in multi-buffer DMA mode.
760   * @note   Step 1 consists in writing the inner hash function key in the IP,
761   *         step 2 consists in writing the message text.
762   * @note   The API carries out the HMAC step 1 then starts step 2 with
763   *         the first buffer entered to the IP. DCAL bit is not automatically set after
764   *         the message buffer feeding, allowing other messages DMA transfers to occur.
765   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
766   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
767   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
768   *         HASH digest computation is corrupted.
769   * @param  hhash: HASH handle.
770   * @param  pInBuffer: pointer to the input buffer (message buffer).
771   * @param  Size: length of the input buffer in bytes.
772   * @retval HAL status
773   */
HAL_HMACEx_SHA224_Step1_2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)774 HAL_StatusTypeDef HAL_HMACEx_SHA224_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
775 {
776   hhash->DigestCalculationDisable = SET;
777   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA224);
778 }
779 
780 /**
781   * @brief  SHA224 HMAC step 2 in multi-buffer DMA mode.
782   * @note   Step 2 consists in writing the message text in the IP.
783   * @note   The API carries on the HMAC step 2, applied to the buffer entered as input
784   *         parameter. DCAL bit is not automatically set after the message buffer feeding,
785   *         allowing other messages DMA transfers to occur.
786   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
787   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
788   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
789   *         HASH digest computation is corrupted.
790   * @param  hhash: HASH handle.
791   * @param  pInBuffer: pointer to the input buffer (message buffer).
792   * @param  Size: length of the input buffer in bytes.
793   * @retval HAL status
794   */
HAL_HMACEx_SHA224_Step2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)795 HAL_StatusTypeDef HAL_HMACEx_SHA224_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
796 {
797   if (hhash->DigestCalculationDisable != SET)
798   {
799     return HAL_ERROR;
800   }
801   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA224);
802 }
803 
804 /**
805   * @brief  SHA224 HMAC step 2 wrap-up and step 3 completion in multi-buffer DMA mode.
806   * @note   Step 2 consists in writing the message text in the IP,
807   *         step 3 consists in writing the outer hash function key.
808   * @note   The API wraps up the HMAC step 2 in processing the buffer entered as input
809   *         parameter (the input buffer must be the last one of the multi-buffer thread)
810   *         then carries out HMAC step 3.
811   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
812   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
813   * @note   Once the DMA transfers are finished (indicated by hhash->State set back
814   *         to HAL_HASH_STATE_READY), HAL_HASHEx_SHA256_Finish() API must be called to retrieve
815   *         the computed digest.
816   * @param  hhash: HASH handle.
817   * @param  pInBuffer: pointer to the input buffer (message buffer).
818   * @param  Size: length of the input buffer in bytes.
819   * @retval HAL status
820   */
HAL_HMACEx_SHA224_Step2_3_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)821 HAL_StatusTypeDef HAL_HMACEx_SHA224_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
822 {
823   hhash->DigestCalculationDisable = RESET;
824   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA224);
825 }
826 
827 /**
828   * @brief  SHA256 HMAC step 1 completion and step 2 start in multi-buffer DMA mode.
829   * @note   Step 1 consists in writing the inner hash function key in the IP,
830   *         step 2 consists in writing the message text.
831   * @note   The API carries out the HMAC step 1 then starts step 2 with
832   *         the first buffer entered to the IP. DCAL bit is not automatically set after
833   *         the message buffer feeding, allowing other messages DMA transfers to occur.
834   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
835   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
836   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
837   *         HASH digest computation is corrupted.
838   * @param  hhash: HASH handle.
839   * @param  pInBuffer: pointer to the input buffer (message buffer).
840   * @param  Size: length of the input buffer in bytes.
841   * @retval HAL status
842   */
HAL_HMACEx_SHA256_Step1_2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)843 HAL_StatusTypeDef HAL_HMACEx_SHA256_Step1_2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
844 {
845   hhash->DigestCalculationDisable = SET;
846   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA256);
847 }
848 
849 /**
850   * @brief  SHA256 HMAC step 2 in multi-buffer DMA mode.
851   * @note   Step 2 consists in writing the message text in the IP.
852   * @note   The API carries on the HMAC step 2, applied to the buffer entered as input
853   *         parameter. DCAL bit is not automatically set after the message buffer feeding,
854   *         allowing other messages DMA transfers to occur.
855   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
856   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
857   * @note   The input buffer size (in bytes) must be a multiple of 4 otherwise, the
858   *         HASH digest computation is corrupted.
859   * @param  hhash: HASH handle.
860   * @param  pInBuffer: pointer to the input buffer (message buffer).
861   * @param  Size: length of the input buffer in bytes.
862   * @retval HAL status
863   */
HAL_HMACEx_SHA256_Step2_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)864 HAL_StatusTypeDef HAL_HMACEx_SHA256_Step2_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
865 {
866   if (hhash->DigestCalculationDisable != SET)
867   {
868     return HAL_ERROR;
869   }
870   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA256);
871 }
872 
873 /**
874   * @brief  SHA256 HMAC step 2 wrap-up and step 3 completion in multi-buffer DMA mode.
875   * @note   Step 2 consists in writing the message text in the IP,
876   *         step 3 consists in writing the outer hash function key.
877   * @note   The API wraps up the HMAC step 2 in processing the buffer entered as input
878   *         parameter (the input buffer must be the last one of the multi-buffer thread)
879   *         then carries out HMAC step 3.
880   * @note   Same key is used for the inner and the outer hash functions; pointer to key and
881   *         key size are respectively stored in hhash->Init.pKey and hhash->Init.KeySize.
882   * @note   Once the DMA transfers are finished (indicated by hhash->State set back
883   *         to HAL_HASH_STATE_READY), HAL_HASHEx_SHA256_Finish() API must be called to retrieve
884   *         the computed digest.
885   * @param  hhash: HASH handle.
886   * @param  pInBuffer: pointer to the input buffer (message buffer).
887   * @param  Size: length of the input buffer in bytes.
888   * @retval HAL status
889   */
HAL_HMACEx_SHA256_Step2_3_DMA(HASH_HandleTypeDef * hhash,uint8_t * pInBuffer,uint32_t Size)890 HAL_StatusTypeDef HAL_HMACEx_SHA256_Step2_3_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
891 {
892   hhash->DigestCalculationDisable = RESET;
893   return  HMAC_Start_DMA(hhash, pInBuffer, Size, HASH_ALGOSELECTION_SHA256);
894 }
895 
896 /**
897   * @}
898   */
899 
900 
901 /**
902   * @}
903   */
904 #endif /* HAL_HASH_MODULE_ENABLED */
905 
906 /**
907   * @}
908   */
909 #endif /* HASH1 || HASH2*/
910 /**
911   * @}
912   */
913