stm32l4xx_hal_hash.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_hash.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-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 __STM32L4xx_HAL_HASH_H
  39. #define __STM32L4xx_HAL_HASH_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if defined (STM32L4A6xx)
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32l4xx_hal_def.h"
  46. /** @addtogroup STM32L4xx_HAL_Driver
  47. * @{
  48. */
  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. __IO uint32_t NbWordsAlreadyPushed; /*!< Numbers of words already pushed in FIFO before inputting new block */
  122. } HASH_HandleTypeDef;
  123. /**
  124. * @}
  125. */
  126. /* Exported constants --------------------------------------------------------*/
  127. /** @defgroup HASH_Exported_Constants HASH Exported Constants
  128. * @{
  129. */
  130. /** @defgroup HASH_Algo_Selection HASH algorithm selection
  131. * @{
  132. */
  133. #define HASH_ALGOSELECTION_SHA1 ((uint32_t)0x0000) /*!< HASH function is SHA1 */
  134. #define HASH_ALGOSELECTION_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */
  135. #define HASH_ALGOSELECTION_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */
  136. #define HASH_ALGOSELECTION_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */
  137. /**
  138. * @}
  139. */
  140. /** @defgroup HASH_Algorithm_Mode HASH algorithm mode
  141. * @{
  142. */
  143. #define HASH_ALGOMODE_HASH ((uint32_t)0x00000000) /*!< Algorithm is HASH */
  144. #define HASH_ALGOMODE_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */
  145. /**
  146. * @}
  147. */
  148. /** @defgroup HASH_Data_Type HASH input data type
  149. * @{
  150. */
  151. #define HASH_DATATYPE_32B ((uint32_t)0x0000) /*!< 32-bit data. No swapping */
  152. #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */
  153. #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */
  154. #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode HMAC key length type
  159. * @{
  160. */
  161. #define HASH_HMAC_KEYTYPE_SHORTKEY ((uint32_t)0x00000000) /*!< HMAC Key size is <= 64 bytes */
  162. #define HASH_HMAC_KEYTYPE_LONGKEY HASH_CR_LKEY /*!< HMAC Key size is > 64 bytes */
  163. /**
  164. * @}
  165. */
  166. /** @defgroup HASH_flags_definition HASH flags definitions
  167. * @{
  168. */
  169. #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : a new block can be entered in the IP */
  170. #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */
  171. #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */
  172. #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy, processing a block of data */
  173. #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : the input buffer contains at least one word of data */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup HASH_interrupts_definition HASH interrupts definitions
  178. * @{
  179. */
  180. #define HASH_IT_DINI HASH_IMR_DINIE /*!< A new block can be entered into the input buffer (DIN) */
  181. #define HASH_IT_DCI HASH_IMR_DCIE /*!< Digest calculation complete */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup HASH_alias HASH API alias
  186. * @{
  187. */
  188. #define HAL_HASHEx_IRQHandler HAL_HASH_IRQHandler /*!< HAL_HASHEx_IRQHandler() is re-directed to HAL_HASH_IRQHandler() for compatibility with legacy code */
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @}
  194. */
  195. /* Exported macros -----------------------------------------------------------*/
  196. /** @defgroup HASH_Exported_Macros HASH Exported Macros
  197. * @{
  198. */
  199. /** @brief Check whether or not the specified HASH flag is set.
  200. * @param __FLAG__: specifies the flag to check.
  201. * This parameter can be one of the following values:
  202. * @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
  203. * @arg @ref HASH_FLAG_DCIS Digest calculation complete.
  204. * @arg @ref HASH_FLAG_DMAS DMA interface is enabled (DMAE=1) or a transfer is ongoing.
  205. * @arg @ref HASH_FLAG_BUSY The hash core is Busy : processing a block of data.
  206. * @arg @ref HASH_FLAG_DINNE DIN not empty : the input buffer contains at least one word of data.
  207. * @retval The new state of __FLAG__ (TRUE or FALSE).
  208. */
  209. #define __HAL_HASH_GET_FLAG(__FLAG__) (((__FLAG__) > 8U) ? \
  210. ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
  211. ((HASH->SR & (__FLAG__)) == (__FLAG__)) )
  212. /** @brief Clear the specified HASH flag.
  213. * @param __FLAG__: specifies the flag to clear.
  214. * This parameter can be one of the following values:
  215. * @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
  216. * @arg @ref HASH_FLAG_DCIS Digest calculation complete
  217. * @retval None
  218. */
  219. #define __HAL_HASH_CLEAR_FLAG(__FLAG__) CLEAR_BIT(HASH->SR, (__FLAG__))
  220. /** @brief Enable the specified HASH interrupt.
  221. * @param __INTERRUPT__: specifies the HASH interrupt source to enable.
  222. * This parameter can be one of the following values:
  223. * @arg @ref HASH_IT_DINI A new block can be entered into the input buffer (DIN)
  224. * @arg @ref HASH_IT_DCI Digest calculation complete
  225. * @retval None
  226. */
  227. #define __HAL_HASH_ENABLE_IT(__INTERRUPT__) SET_BIT(HASH->IMR, (__INTERRUPT__))
  228. /** @brief Disable the specified HASH interrupt.
  229. * @param __INTERRUPT__: specifies the HASH interrupt source to disable.
  230. * This parameter can be one of the following values:
  231. * @arg @ref HASH_IT_DINI A new block can be entered into the input buffer (DIN)
  232. * @arg @ref HASH_IT_DCI Digest calculation complete
  233. * @retval None
  234. */
  235. #define __HAL_HASH_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(HASH->IMR, (__INTERRUPT__))
  236. /** @brief Reset HASH handle state.
  237. * @param __HANDLE__: HASH handle.
  238. * @retval None
  239. */
  240. #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
  241. /** @brief Reset HASH handle status.
  242. * @param __HANDLE__: HASH handle.
  243. * @retval None
  244. */
  245. #define __HAL_HASH_RESET_HANDLE_STATUS(__HANDLE__) ((__HANDLE__)->Status = HAL_OK)
  246. /**
  247. * @brief Enable the multi-buffer DMA transfer mode.
  248. * @note This bit is set when hashing large files when multiple DMA transfers are needed.
  249. * @retval None
  250. */
  251. #define __HAL_HASH_SET_MDMAT() SET_BIT(HASH->CR, HASH_CR_MDMAT)
  252. /**
  253. * @brief Disable the multi-buffer DMA transfer mode.
  254. * @retval None
  255. */
  256. #define __HAL_HASH_RESET_MDMAT() CLEAR_BIT(HASH->CR, HASH_CR_MDMAT)
  257. /**
  258. * @brief Start the digest computation.
  259. * @retval None
  260. */
  261. #define __HAL_HASH_START_DIGEST() SET_BIT(HASH->STR, HASH_STR_DCAL)
  262. /**
  263. * @brief Set the number of valid bits in the last word written in data register DIN.
  264. * @param __SIZE__: size in bytes of last data written in Data register.
  265. * @retval None
  266. */
  267. #define __HAL_HASH_SET_NBVALIDBITS(__SIZE__) MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8 * ((__SIZE__) % 4))
  268. /**
  269. * @brief Reset the HASH core.
  270. * @retval None
  271. */
  272. #define __HAL_HASH_INIT() SET_BIT(HASH->CR, HASH_CR_INIT)
  273. /**
  274. * @}
  275. */
  276. /* Private macros --------------------------------------------------------*/
  277. /** @defgroup HASH_Private_Macros HASH Private Macros
  278. * @{
  279. */
  280. /**
  281. * @brief Return digest length in bytes.
  282. * @retval Digest length
  283. */
  284. #define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1) ? 20 : \
  285. ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA224) ? 28 : \
  286. ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA256) ? 32 : 16 ) ) )
  287. /**
  288. * @brief Return number of words already pushed in the FIFO.
  289. * @retval Number of words already pushed in the FIFO
  290. */
  291. #define HASH_NBW_PUSHED() ((READ_BIT(HASH->CR, HASH_CR_NBW)) >> 8)
  292. /**
  293. * @brief Ensure that HASH input data type is valid.
  294. * @param __DATATYPE__: HASH input data type.
  295. * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid)
  296. */
  297. #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
  298. ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
  299. ((__DATATYPE__) == HASH_DATATYPE_8B) || \
  300. ((__DATATYPE__) == HASH_DATATYPE_1B))
  301. /**
  302. * @brief Ensure that input data buffer size is valid for multi-buffer HASH
  303. * processing in polling mode.
  304. * @note This check is valid only for multi-buffer HASH processing in polling mode.
  305. * @param __SIZE__: input data buffer size.
  306. * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
  307. */
  308. #define IS_HASH_POLLING_MULTIBUFFER_SIZE(__SIZE__) (((__SIZE__) % 4) == 0)
  309. /**
  310. * @brief Ensure that input data buffer size is valid for multi-buffer HASH
  311. * processing in DMA mode.
  312. * @note This check is valid only for multi-buffer HASH processing in DMA mode.
  313. * @param __SIZE__: input data buffer size.
  314. * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
  315. */
  316. #define IS_HASH_DMA_MULTIBUFFER_SIZE(__SIZE__) ((READ_BIT(HASH->CR, HASH_CR_MDMAT) == RESET) || (((__SIZE__) % 4) == 0))
  317. /**
  318. * @brief Ensure that input data buffer size is valid for multi-buffer HMAC
  319. * processing in DMA mode.
  320. * @note This check is valid only for multi-buffer HMAC processing in DMA mode.
  321. * @param __HANDLE__: HASH handle.
  322. * @param __SIZE__: input data buffer size.
  323. * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
  324. */
  325. #define IS_HMAC_DMA_MULTIBUFFER_SIZE(__HANDLE__,__SIZE__) ((((__HANDLE__)->DigestCalculationDisable) == RESET) || (((__SIZE__) % 4) == 0))
  326. /**
  327. * @brief Ensure that handle phase is set to HASH processing.
  328. * @param __HANDLE__: HASH handle.
  329. * @retval SET (handle phase is set to HASH processing) or RESET (handle phase is not set to HASH processing)
  330. */
  331. #define IS_HASH_PROCESSING(__HANDLE__) ((__HANDLE__)->Phase == HAL_HASH_PHASE_PROCESS)
  332. /**
  333. * @brief Ensure that handle phase is set to HMAC processing.
  334. * @param __HANDLE__: HASH handle.
  335. * @retval SET (handle phase is set to HMAC processing) or RESET (handle phase is not set to HMAC processing)
  336. */
  337. #define IS_HMAC_PROCESSING(__HANDLE__) (((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_1) || \
  338. ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_2) || \
  339. ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_3))
  340. /**
  341. * @}
  342. */
  343. /* Include HASH HAL Extended module */
  344. #include "stm32l4xx_hal_hash_ex.h"
  345. /* Exported functions --------------------------------------------------------*/
  346. /** @addtogroup HASH_Exported_Functions HASH Exported Functions
  347. * @{
  348. */
  349. /** @addtogroup HASH_Exported_Functions_Group1 Initialization and de-initialization functions
  350. * @{
  351. */
  352. /* Initialization/de-initialization methods **********************************/
  353. HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
  354. HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
  355. void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
  356. void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
  357. void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
  358. void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
  359. void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
  360. /**
  361. * @}
  362. */
  363. /** @addtogroup HASH_Exported_Functions_Group2 HASH processing functions in polling mode
  364. * @{
  365. */
  366. /* HASH processing using polling *********************************************/
  367. HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  368. HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  369. HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  370. HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  371. /**
  372. * @}
  373. */
  374. /** @addtogroup HASH_Exported_Functions_Group3 HASH processing functions in interrupt mode
  375. * @{
  376. */
  377. /* HASH processing using IT **************************************************/
  378. HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  379. HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  380. void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
  381. /**
  382. * @}
  383. */
  384. /** @addtogroup HASH_Exported_Functions_Group4 HASH processing functions in DMA mode
  385. * @{
  386. */
  387. /* HASH processing using DMA *************************************************/
  388. HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  389. HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
  390. HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  391. HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
  392. /**
  393. * @}
  394. */
  395. /** @addtogroup HASH_Exported_Functions_Group5 HMAC processing functions in polling mode
  396. * @{
  397. */
  398. /* HASH-MAC processing using polling *****************************************/
  399. HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  400. HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
  401. /**
  402. * @}
  403. */
  404. /** @addtogroup HASH_Exported_Functions_Group6 HMAC processing functions in interrupt mode
  405. * @{
  406. */
  407. HAL_StatusTypeDef HAL_HMAC_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  408. HAL_StatusTypeDef HAL_HMAC_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
  409. /**
  410. * @}
  411. */
  412. /** @addtogroup HASH_Exported_Functions_Group7 HMAC processing functions in DMA mode
  413. * @{
  414. */
  415. /* HASH-HMAC processing using DMA ********************************************/
  416. HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  417. HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
  418. /**
  419. * @}
  420. */
  421. /** @addtogroup HASH_Exported_Functions_Group8 Peripheral states functions
  422. * @{
  423. */
  424. /* Peripheral State methods **************************************************/
  425. HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
  426. HAL_StatusTypeDef HAL_HASH_GetStatus(HASH_HandleTypeDef *hhash);
  427. void HAL_HASH_ContextSaving(HASH_HandleTypeDef *hhash, uint8_t* pMemBuffer);
  428. void HAL_HASH_ContextRestoring(HASH_HandleTypeDef *hhash, uint8_t* pMemBuffer);
  429. void HAL_HASH_SwFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
  430. HAL_StatusTypeDef HAL_HASH_DMAFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
  431. /**
  432. * @}
  433. */
  434. /**
  435. * @}
  436. */
  437. /* Private functions -----------------------------------------------------------*/
  438. /** @addtogroup HASH_Private_Functions HASH Private Functions
  439. * @{
  440. */
  441. /* Private functions */
  442. HAL_StatusTypeDef HASH_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout, uint32_t Algorithm);
  443. HAL_StatusTypeDef HASH_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
  444. HAL_StatusTypeDef HASH_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Algorithm);
  445. HAL_StatusTypeDef HASH_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
  446. HAL_StatusTypeDef HASH_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
  447. HAL_StatusTypeDef HMAC_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout, uint32_t Algorithm);
  448. HAL_StatusTypeDef HMAC_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Algorithm);
  449. HAL_StatusTypeDef HMAC_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
  450. /**
  451. * @}
  452. */
  453. /**
  454. * @}
  455. */
  456. /**
  457. * @}
  458. */
  459. #endif /* defined (STM32L4A6xx) */
  460. #ifdef __cplusplus
  461. }
  462. #endif
  463. #endif /* __STM32L4xx_HAL_HASH_H */
  464. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/