stm32l4xx_hal_hash.h 24 KB

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