You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

637 rivejä
25 KiB

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