stm32h7xx_hal_hash.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_hash.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 21-April-2017
  7. * @brief Header file of HASH HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without 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 ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32H7xx_HAL_HASH_H
  39. #define __STM32H7xx_HAL_HASH_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32h7xx_hal_def.h"
  45. /** @addtogroup STM32H7xx_HAL_Driver
  46. * @{
  47. */
  48. #if defined (HASH)
  49. /** @addtogroup HASH
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup HASH_Exported_Types HASH Exported Types
  54. * @{
  55. */
  56. /**
  57. * @brief HASH Configuration Structure definition
  58. */
  59. typedef struct
  60. {
  61. uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit data.
  62. This parameter can be a value of @ref HASH_Data_Type. */
  63. uint32_t KeySize; /*!< The key size is used only in HMAC operation. */
  64. uint8_t* pKey; /*!< The key is used only in HMAC operation. */
  65. } HASH_InitTypeDef;
  66. /**
  67. * @brief HAL State structures definition
  68. */
  69. typedef enum
  70. {
  71. HAL_HASH_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
  72. HAL_HASH_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
  73. HAL_HASH_STATE_BUSY = 0x02, /*!< Processing (hashing) is ongoing */
  74. HAL_HASH_STATE_TIMEOUT = 0x06, /*!< Timeout state */
  75. HAL_HASH_STATE_ERROR = 0x07, /*!< Error state */
  76. HAL_HASH_STATE_SUSPENDED = 0x08 /*!< Suspended state */
  77. }HAL_HASH_StateTypeDef;
  78. /**
  79. * @brief HAL phase structures definition
  80. */
  81. typedef enum
  82. {
  83. HAL_HASH_PHASE_READY = 0x01, /*!< HASH peripheral is ready to start */
  84. HAL_HASH_PHASE_PROCESS = 0x02, /*!< HASH peripheral is in HASH processing phase */
  85. HAL_HASH_PHASE_HMAC_STEP_1 = 0x03, /*!< HASH peripheral is in HMAC step 1 processing phase
  86. (step 1 consists in entering the inner hash function key) */
  87. HAL_HASH_PHASE_HMAC_STEP_2 = 0x04, /*!< HASH peripheral is in HMAC step 2 processing phase
  88. (step 2 consists in entering the message text) */
  89. HAL_HASH_PHASE_HMAC_STEP_3 = 0x05 /*!< HASH peripheral is in HMAC step 3 processing phase
  90. (step 3 consists in entering the outer hash function key) */
  91. }HAL_HASH_PhaseTypeDef;
  92. /**
  93. * @brief HAL HASH mode suspend definitions
  94. */
  95. typedef enum
  96. {
  97. HAL_HASH_SUSPEND_NONE = 0x00, /*!< HASH peripheral suspension not requested */
  98. HAL_HASH_SUSPEND = 0x01 /*!< HASH peripheral suspension is requested */
  99. }HAL_HASH_SuspendTypeDef;
  100. /**
  101. * @brief HASH Handle Structure definition
  102. */
  103. typedef struct
  104. {
  105. HASH_InitTypeDef Init; /*!< HASH required parameters */
  106. uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */
  107. uint8_t *pHashOutBuffPtr; /*!< Pointer to output buffer (digest) */
  108. uint8_t *pHashKeyBuffPtr; /*!< Pointer to key buffer (HMAC only) */
  109. uint8_t *pHashMsgBuffPtr; /*!< Pointer to message buffer (HMAC only) */
  110. uint32_t HashBuffSize; /*!< Size of buffer to be processed */
  111. __IO uint32_t HashInCount; /*!< Counter of inputted data */
  112. __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */
  113. __IO uint32_t HashKeyCount; /*!< Counter for Key inputted data (HMAC only) */
  114. HAL_StatusTypeDef Status; /*!< HASH peripheral status */
  115. HAL_HASH_PhaseTypeDef Phase; /*!< HASH peripheral phase */
  116. DMA_HandleTypeDef *hdmain; /*!< HASH In DMA Handle parameters */
  117. HAL_LockTypeDef Lock; /*!< Locking object */
  118. __IO HAL_HASH_StateTypeDef State; /*!< HASH peripheral state */
  119. HAL_HASH_SuspendTypeDef SuspendRequest; /*!< HASH peripheral suspension request flag */
  120. FlagStatus DigestCalculationDisable; /*!< Digest calculation phase skip (MDMAT bit control) for multi-buffers DMA-based HMAC computation */
  121. } HASH_HandleTypeDef;
  122. /**
  123. * @}
  124. */
  125. /* Exported constants --------------------------------------------------------*/
  126. /** @defgroup HASH_Exported_Constants HASH Exported Constants
  127. * @{
  128. */
  129. /** @defgroup HASH_Algo_Selection HASH algorithm selection
  130. * @{
  131. */
  132. #define HASH_ALGOSELECTION_SHA1 ((uint32_t)0x0000) /*!< HASH function is SHA1 */
  133. #define HASH_ALGOSELECTION_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */
  134. #define HASH_ALGOSELECTION_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */
  135. #define HASH_ALGOSELECTION_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */
  136. /**
  137. * @}
  138. */
  139. /** @defgroup HASH_Algorithm_Mode HASH algorithm mode
  140. * @{
  141. */
  142. #define HASH_ALGOMODE_HASH ((uint32_t)0x00000000) /*!< Algorithm is HASH */
  143. #define HASH_ALGOMODE_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */
  144. /**
  145. * @}
  146. */
  147. /** @defgroup HASH_Data_Type HASH input data type
  148. * @{
  149. */
  150. #define HASH_DATATYPE_32B ((uint32_t)0x0000) /*!< 32-bit data. No swapping */
  151. #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */
  152. #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */
  153. #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */
  154. /**
  155. * @}
  156. */
  157. /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode HMAC key length type
  158. * @{
  159. */
  160. #define HASH_HMAC_KEYTYPE_SHORTKEY ((uint32_t)0x00000000) /*!< HMAC Key size is <= 64 bytes */
  161. #define HASH_HMAC_KEYTYPE_LONGKEY HASH_CR_LKEY /*!< HMAC Key size is > 64 bytes */
  162. /**
  163. * @}
  164. */
  165. /** @defgroup HASH_flags_definition HASH flags definitions
  166. * @{
  167. */
  168. #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : a new block can be entered in the IP */
  169. #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */
  170. #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */
  171. #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy, processing a block of data */
  172. #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : the input buffer contains at least one word of data */
  173. /**
  174. * @}
  175. */
  176. /** @defgroup HASH_interrupts_definition HASH interrupts definitions
  177. * @{
  178. */
  179. #define HASH_IT_DINI HASH_IMR_DINIE /*!< A new block can be entered into the input buffer (DIN) */
  180. #define HASH_IT_DCI HASH_IMR_DCIE /*!< Digest calculation complete */
  181. /**
  182. * @}
  183. */
  184. /** @defgroup HASH_alias HASH API alias
  185. * @{
  186. */
  187. #define HAL_HASHEx_IRQHandler HAL_HASH_IRQHandler /*!< HAL_HASHEx_IRQHandler() is re-directed to HAL_HASH_IRQHandler() for compatibility with legacy code */
  188. /**
  189. * @}
  190. */
  191. /**
  192. * @}
  193. */
  194. /* Exported macros -----------------------------------------------------------*/
  195. /** @defgroup HASH_Exported_Macros HASH Exported Macros
  196. * @{
  197. */
  198. /** @brief Check whether or not the specified HASH flag is set.
  199. * @param __FLAG__: specifies the flag to check.
  200. * This parameter can be one of the following values:
  201. * @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
  202. * @arg @ref HASH_FLAG_DCIS Digest calculation complete.
  203. * @arg @ref HASH_FLAG_DMAS DMA interface is enabled (DMAE=1) or a transfer is ongoing.
  204. * @arg @ref HASH_FLAG_BUSY The hash core is Busy : processing a block of data.
  205. * @arg @ref HASH_FLAG_DINNE DIN not empty : the input buffer contains at least one word of data.
  206. * @retval The new state of __FLAG__ (TRUE or FALSE).
  207. */
  208. #define __HAL_HASH_GET_FLAG(__FLAG__) (((__FLAG__) > 8U) ? \
  209. ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
  210. ((HASH->SR & (__FLAG__)) == (__FLAG__)) )
  211. /** @brief Clear the specified HASH flag.
  212. * @param __FLAG__: specifies the flag to clear.
  213. * This parameter can be one of the following values:
  214. * @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
  215. * @arg @ref HASH_FLAG_DCIS Digest calculation complete
  216. * @retval None
  217. */
  218. #define __HAL_HASH_CLEAR_FLAG(__FLAG__) CLEAR_BIT(HASH->SR, (__FLAG__))
  219. /** @brief Enable the specified HASH interrupt.
  220. * @param __INTERRUPT__: specifies the HASH interrupt source to enable.
  221. * This parameter can be one of the following values:
  222. * @arg @ref HASH_IT_DINI A new block can be entered into the input buffer (DIN)
  223. * @arg @ref HASH_IT_DCI Digest calculation complete
  224. * @retval None
  225. */
  226. #define __HAL_HASH_ENABLE_IT(__INTERRUPT__) SET_BIT(HASH->IMR, (__INTERRUPT__))
  227. /** @brief Disable the specified HASH interrupt.
  228. * @param __INTERRUPT__: specifies the HASH interrupt source to disable.
  229. * This parameter can be one of the following values:
  230. * @arg @ref HASH_IT_DINI A new block can be entered into the input buffer (DIN)
  231. * @arg @ref HASH_IT_DCI Digest calculation complete
  232. * @retval None
  233. */
  234. #define __HAL_HASH_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(HASH->IMR, (__INTERRUPT__))
  235. /** @brief Reset HASH handle state.
  236. * @param __HANDLE__: HASH handle.
  237. * @retval None
  238. */
  239. #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
  240. /** @brief Reset HASH handle status.
  241. * @param __HANDLE__: HASH handle.
  242. * @retval None
  243. */
  244. #define __HAL_HASH_RESET_HANDLE_STATUS(__HANDLE__) ((__HANDLE__)->Status = HAL_OK)
  245. /**
  246. * @brief Enable the multi-buffer DMA transfer mode.
  247. * @note This bit is set when hashing large files when multiple DMA transfers are needed.
  248. * @retval None
  249. */
  250. #define __HAL_HASH_SET_MDMAT() SET_BIT(HASH->CR, HASH_CR_MDMAT)
  251. /**
  252. * @brief Disable the multi-buffer DMA transfer mode.
  253. * @retval None
  254. */
  255. #define __HAL_HASH_RESET_MDMAT() CLEAR_BIT(HASH->CR, HASH_CR_MDMAT)
  256. /**
  257. * @brief Start the digest computation.
  258. * @retval None
  259. */
  260. #define __HAL_HASH_START_DIGEST() SET_BIT(HASH->STR, HASH_STR_DCAL)
  261. /**
  262. * @brief Set the number of valid bits in the last word written in data register DIN.
  263. * @param __SIZE__: size in bytes of last data written in Data register.
  264. * @retval None
  265. */
  266. #define __HAL_HASH_SET_NBVALIDBITS(__SIZE__) MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8 * ((__SIZE__) % 4))
  267. /**
  268. * @brief Reset the HASH core.
  269. * @retval None
  270. */
  271. #define __HAL_HASH_INIT() SET_BIT(HASH->CR, HASH_CR_INIT)
  272. /**
  273. * @}
  274. */
  275. /* Private macros --------------------------------------------------------*/
  276. /** @defgroup HASH_Private_Macros HASH Private Macros
  277. * @{
  278. */
  279. /**
  280. * @brief Return digest length in bytes.
  281. * @retval Digest length
  282. */
  283. #define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1) ? 20 : \
  284. ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA224) ? 28 : \
  285. ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA256) ? 32 : 16 ) ) )
  286. /**
  287. * @brief Return number of words already pushed in the FIFO.
  288. * @retval Number of words already pushed in the FIFO
  289. */
  290. #define HASH_NBW_PUSHED() ((READ_BIT(HASH->CR, HASH_CR_NBW)) >> 8)
  291. /**
  292. * @brief Ensure that HASH input data type is valid.
  293. * @param __DATATYPE__: HASH input data type.
  294. * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid)
  295. */
  296. #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
  297. ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
  298. ((__DATATYPE__) == HASH_DATATYPE_8B) || \
  299. ((__DATATYPE__) == HASH_DATATYPE_1B))
  300. /**
  301. * @brief Ensure that input data buffer size is valid for multi-buffer HASH
  302. * processing in polling mode.
  303. * @note This check is valid only for multi-buffer HASH processing in polling mode.
  304. * @param __SIZE__: input data buffer size.
  305. * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
  306. */
  307. #define IS_HASH_POLLING_MULTIBUFFER_SIZE(__SIZE__) (((__SIZE__) % 4) == 0)
  308. /**
  309. * @brief Ensure that input data buffer size is valid for multi-buffer HASH
  310. * processing in DMA mode.
  311. * @note This check is valid only for multi-buffer HASH processing in DMA mode.
  312. * @param __SIZE__: input data buffer size.
  313. * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
  314. */
  315. #define IS_HASH_DMA_MULTIBUFFER_SIZE(__SIZE__) ((READ_BIT(HASH->CR, HASH_CR_MDMAT) == RESET) || (((__SIZE__) % 4) == 0))
  316. /**
  317. * @brief Ensure that input data buffer size is valid for multi-buffer HMAC
  318. * processing in DMA mode.
  319. * @note This check is valid only for multi-buffer HMAC processing in DMA mode.
  320. * @param __HANDLE__: HASH handle.
  321. * @param __SIZE__: input data buffer size.
  322. * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
  323. */
  324. #define IS_HMAC_DMA_MULTIBUFFER_SIZE(__HANDLE__,__SIZE__) ((((__HANDLE__)->DigestCalculationDisable) == RESET) || (((__SIZE__) % 4) == 0))
  325. /**
  326. * @brief Ensure that handle phase is set to HASH processing.
  327. * @param __HANDLE__: HASH handle.
  328. * @retval SET (handle phase is set to HASH processing) or RESET (handle phase is not set to HASH processing)
  329. */
  330. #define IS_HASH_PROCESSING(__HANDLE__) ((__HANDLE__)->Phase == HAL_HASH_PHASE_PROCESS)
  331. /**
  332. * @brief Ensure that handle phase is set to HMAC processing.
  333. * @param __HANDLE__: HASH handle.
  334. * @retval SET (handle phase is set to HMAC processing) or RESET (handle phase is not set to HMAC processing)
  335. */
  336. #define IS_HMAC_PROCESSING(__HANDLE__) (((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_1) || \
  337. ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_2) || \
  338. ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_3))
  339. /**
  340. * @}
  341. */
  342. /* Include HASH HAL Extended module */
  343. #include "stm32h7xx_hal_hash_ex.h"
  344. /* Exported functions --------------------------------------------------------*/
  345. /** @addtogroup HASH_Exported_Functions HASH Exported Functions
  346. * @{
  347. */
  348. /** @addtogroup HASH_Exported_Functions_Group1 Initialization and de-initialization functions
  349. * @{
  350. */
  351. /* Initialization/de-initialization methods **********************************/
  352. HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
  353. HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
  354. void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
  355. void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
  356. void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
  357. void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
  358. void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
  359. /**
  360. * @}
  361. */
  362. /** @addtogroup HASH_Exported_Functions_Group2 HASH processing functions in polling mode
  363. * @{
  364. */
  365. /* HASH processing using polling *********************************************/
  366. HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  367. HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  368. HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  369. HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  370. /**
  371. * @}
  372. */
  373. /** @addtogroup HASH_Exported_Functions_Group3 HASH processing functions in interrupt mode
  374. * @{
  375. */
  376. /* HASH processing using IT **************************************************/
  377. HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  378. HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  379. void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
  380. /**
  381. * @}
  382. */
  383. /** @addtogroup HASH_Exported_Functions_Group4 HASH processing functions in DMA mode
  384. * @{
  385. */
  386. /* HASH processing using DMA *************************************************/
  387. HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  388. HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
  389. HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  390. HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
  391. /**
  392. * @}
  393. */
  394. /** @addtogroup HASH_Exported_Functions_Group5 HMAC processing functions in polling mode
  395. * @{
  396. */
  397. /* HASH-MAC processing using polling *****************************************/
  398. HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  399. HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  400. /**
  401. * @}
  402. */
  403. /** @addtogroup HASH_Exported_Functions_Group6 HMAC processing functions in interrupt mode
  404. * @{
  405. */
  406. HAL_StatusTypeDef HAL_HMAC_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  407. HAL_StatusTypeDef HAL_HMAC_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  408. /**
  409. * @}
  410. */
  411. /** @addtogroup HASH_Exported_Functions_Group7 HMAC processing functions in DMA mode
  412. * @{
  413. */
  414. /* HASH-HMAC processing using DMA ********************************************/
  415. HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  416. HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  417. /**
  418. * @}
  419. */
  420. /** @addtogroup HASH_Exported_Functions_Group8 Peripheral states functions
  421. * @{
  422. */
  423. /* Peripheral State methods **************************************************/
  424. HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
  425. HAL_StatusTypeDef HAL_HASH_GetStatus(HASH_HandleTypeDef *hhash);
  426. void HAL_HASH_ContextSaving(HASH_HandleTypeDef *hhash, uint8_t* pMemBuffer);
  427. void HAL_HASH_ContextRestoring(HASH_HandleTypeDef *hhash, uint8_t* pMemBuffer);
  428. void HAL_HASH_SwFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
  429. HAL_StatusTypeDef HAL_HASH_DMAFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
  430. /**
  431. * @}
  432. */
  433. /**
  434. * @}
  435. */
  436. /* Private functions -----------------------------------------------------------*/
  437. /** @addtogroup HASH_Private_Functions HASH Private Functions
  438. * @{
  439. */
  440. /* Private functions */
  441. HAL_StatusTypeDef HASH_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout, uint32_t Algorithm);
  442. HAL_StatusTypeDef HASH_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
  443. HAL_StatusTypeDef HASH_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Algorithm);
  444. HAL_StatusTypeDef HASH_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
  445. HAL_StatusTypeDef HASH_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
  446. HAL_StatusTypeDef HMAC_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout, uint32_t Algorithm);
  447. HAL_StatusTypeDef HMAC_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Algorithm);
  448. HAL_StatusTypeDef HMAC_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
  449. /**
  450. * @}
  451. */
  452. /**
  453. * @}
  454. */
  455. #endif /* HASH */
  456. /**
  457. * @}
  458. */
  459. #ifdef __cplusplus
  460. }
  461. #endif
  462. #endif /* __STM32H7xx_HAL_HASH_H */
  463. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/