20#ifndef STM32F4xx_HAL_HASH_H
21#define STM32F4xx_HAL_HASH_H
94#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
100 HAL_HASH_MSPINIT_CB_ID = 0x00U,
101 HAL_HASH_MSPDEINIT_CB_ID = 0x01U,
102 HAL_HASH_INPUTCPLT_CB_ID = 0x02U,
103 HAL_HASH_DGSTCPLT_CB_ID = 0x03U,
104 HAL_HASH_ERROR_CB_ID = 0x04U,
105} HAL_HASH_CallbackIDTypeDef;
112#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
113typedef struct __HASH_HandleTypeDef
156#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
157 void (* InCpltCallback)(
struct __HASH_HandleTypeDef *hhash);
159 void (* DgstCpltCallback)(
struct __HASH_HandleTypeDef *hhash);
161 void (* ErrorCallback)(
struct __HASH_HandleTypeDef *hhash);
163 void (* MspInitCallback)(
struct __HASH_HandleTypeDef *hhash);
165 void (* MspDeInitCallback)(
struct __HASH_HandleTypeDef *hhash);
170#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
190#define HASH_ALGOSELECTION_SHA1 0x00000000U
191#define HASH_ALGOSELECTION_MD5 HASH_CR_ALGO_0
192#define HASH_ALGOSELECTION_SHA224 HASH_CR_ALGO_1
193#define HASH_ALGOSELECTION_SHA256 HASH_CR_ALGO
201#define HASH_ALGOMODE_HASH 0x00000000U
202#define HASH_ALGOMODE_HMAC HASH_CR_MODE
210#define HASH_DATATYPE_32B 0x00000000U
211#define HASH_DATATYPE_16B HASH_CR_DATATYPE_0
212#define HASH_DATATYPE_8B HASH_CR_DATATYPE_1
213#define HASH_DATATYPE_1B HASH_CR_DATATYPE
221#define HASH_HMAC_KEYTYPE_SHORTKEY 0x00000000U
222#define HASH_HMAC_KEYTYPE_LONGKEY HASH_CR_LKEY
230#define HASH_FLAG_DINIS HASH_SR_DINIS
231#define HASH_FLAG_DCIS HASH_SR_DCIS
232#define HASH_FLAG_DMAS HASH_SR_DMAS
233#define HASH_FLAG_BUSY HASH_SR_BUSY
234#define HASH_FLAG_DINNE HASH_CR_DINNE
243#define HASH_IT_DINI HASH_IMR_DINIE
244#define HASH_IT_DCI HASH_IMR_DCIE
253#define HAL_HASH_ERROR_NONE 0x00000000U
254#define HAL_HASH_ERROR_IT 0x00000001U
255#define HAL_HASH_ERROR_DMA 0x00000002U
256#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
257#define HAL_HASH_ERROR_INVALID_CALLBACK 0x00000004U
282#define __HAL_HASH_GET_FLAG(__FLAG__) (((__FLAG__) > 8U) ? \
283 ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
284 ((HASH->SR & (__FLAG__)) == (__FLAG__)) )
294#define __HAL_HASH_CLEAR_FLAG(__FLAG__) CLEAR_BIT(HASH->SR, (__FLAG__))
304#define __HAL_HASH_ENABLE_IT(__INTERRUPT__) SET_BIT(HASH->IMR, (__INTERRUPT__))
313#define __HAL_HASH_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(HASH->IMR, (__INTERRUPT__))
320#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
321#define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) do{\
322 (__HANDLE__)->State = HAL_HASH_STATE_RESET;\
323 (__HANDLE__)->MspInitCallback = NULL; \
324 (__HANDLE__)->MspDeInitCallback = NULL; \
327#define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
335#define __HAL_HASH_RESET_HANDLE_STATUS(__HANDLE__) ((__HANDLE__)->Status = HAL_OK)
342#define __HAL_HASH_SET_MDMAT() SET_BIT(HASH->CR, HASH_CR_MDMAT)
348#define __HAL_HASH_RESET_MDMAT() CLEAR_BIT(HASH->CR, HASH_CR_MDMAT)
355#define __HAL_HASH_START_DIGEST() SET_BIT(HASH->STR, HASH_STR_DCAL)
362#define __HAL_HASH_SET_NBVALIDBITS(__SIZE__) MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8U * ((__SIZE__) % 4U))
368#define __HAL_HASH_INIT() SET_BIT(HASH->CR, HASH_CR_INIT)
383#if defined(HASH_CR_MDMAT)
384#define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1) ? 20U : \
385 ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA224) ? 28U : \
386 ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA256) ? 32U : 16U ) ) )
388#define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1) ? 20U : 16)
394#define HASH_NBW_PUSHED() ((READ_BIT(HASH->CR, HASH_CR_NBW)) >> 8U)
401#define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
402 ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
403 ((__DATATYPE__) == HASH_DATATYPE_8B) || \
404 ((__DATATYPE__) == HASH_DATATYPE_1B))
413#define IS_HASH_DMA_MULTIBUFFER_SIZE(__SIZE__) ((READ_BIT(HASH->CR, HASH_CR_MDMAT) == 0U) || (((__SIZE__) % 4U) == 0U))
423#define IS_HMAC_DMA_MULTIBUFFER_SIZE(__HANDLE__,__SIZE__) ((((__HANDLE__)->DigestCalculationDisable) == RESET)\
424 || (((__SIZE__) % 4U) == 0U))
430#define IS_HASH_PROCESSING(__HANDLE__) ((__HANDLE__)->Phase == HAL_HASH_PHASE_PROCESS)
437#define IS_HMAC_PROCESSING(__HANDLE__) (((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_1) || \
438 ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_2) || \
439 ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_3))
466#if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
468 pHASH_CallbackTypeDef pCallback);
490 uint8_t *pOutBuffer, uint32_t Timeout);
492 uint8_t *pOutBuffer, uint32_t Timeout);
505 uint8_t *pOutBuffer);
508 uint8_t *pOutBuffer);
510 uint8_t *pOutBuffer);
513 uint8_t *pOutBuffer);
552 uint8_t *pOutBuffer);
554 uint8_t *pOutBuffer);
602 uint32_t Timeout, uint32_t Algorithm);
610 uint32_t Timeout, uint32_t Algorithm);
void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash)
DeInitialize the HASH MSP.
void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash)
Digest computation complete call back.
HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash)
DeInitialize the HASH peripheral.
void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash)
Input data transfer complete call back.
HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash)
Initialize the HASH according to the specified parameters in the HASH_HandleTypeDef and create the as...
void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash)
Initialize the HASH MSP.
void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash)
Error callback.
HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
Initialize the HASH peripheral in MD5 mode, next process pInBuffer then read the computed digest.
HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
End computation of a single HASH signature after several calls to HAL_HASH_MD5_Accmlt() API.
HAL_StatusTypeDef HAL_HASH_MD5_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
If not already done, initialize the HASH peripheral in MD5 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
End computation of a single HASH signature after several calls to HAL_HASH_SHA1_Accmlt() API.
HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
Initialize the HASH peripheral in SHA1 mode, next process pInBuffer then read the computed digest.
HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
If not already done, initialize the HASH peripheral in SHA1 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
Initialize the HASH peripheral in SHA1 mode, next process pInBuffer then read the computed digest in ...
HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
End computation of a single HASH signature after several calls to HAL_HASH_MD5_Accmlt_IT() API.
HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
If not already done, initialize the HASH peripheral in MD5 mode then processes pInBuffer in interrupt...
HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
End computation of a single HASH signature after several calls to HAL_HASH_SHA1_Accmlt_IT() API.
HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
Initialize the HASH peripheral in MD5 mode, next process pInBuffer then read the computed digest in i...
void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash)
Handle HASH interrupt request.
HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
If not already done, initialize the HASH peripheral in SHA1 mode then processes pInBuffer in interrup...
HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout)
Return the computed digest in MD5 mode.
HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
Initialize the HASH peripheral in MD5 mode then initiate a DMA transfer to feed the input buffer to t...
HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
Initialize the HASH peripheral in SHA1 mode then initiate a DMA transfer to feed the input buffer to ...
HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout)
Return the computed digest in SHA1 mode.
HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
Initialize the HASH peripheral in HMAC MD5 mode, next process pInBuffer then read the computed digest...
HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
Initialize the HASH peripheral in HMAC SHA1 mode, next process pInBuffer then read the computed diges...
HAL_StatusTypeDef HAL_HMAC_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
Initialize the HASH peripheral in HMAC SHA1 mode, next process pInBuffer then read the computed diges...
HAL_StatusTypeDef HAL_HMAC_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
Initialize the HASH peripheral in HMAC MD5 mode, next process pInBuffer then read the computed digest...
HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
Initialize the HASH peripheral in HMAC MD5 mode then initiate the required DMA transfers to feed the ...
HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
Initialize the HASH peripheral in HMAC SHA1 mode then initiate the required DMA transfers to feed the...
void HAL_HASH_ContextSaving(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer)
Save the HASH context in case of processing suspension.
HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash)
Return the HASH handle state.
HAL_StatusTypeDef HAL_HASH_GetStatus(HASH_HandleTypeDef *hhash)
Return the HASH HAL status.
uint32_t HAL_HASH_GetError(HASH_HandleTypeDef *hhash)
Return the HASH handle error code.
void HAL_HASH_ContextRestoring(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer)
Restore the HASH context in case of processing resumption.
void HAL_HASH_SwFeed_ProcessSuspend(HASH_HandleTypeDef *hhash)
Initiate HASH processing suspension when in polling or interruption mode.
HAL_StatusTypeDef HAL_HASH_DMAFeed_ProcessSuspend(HASH_HandleTypeDef *hhash)
Suspend the HASH processing when in DMA mode.
HAL_HASH_PhaseTypeDef
HAL phase structures definition.
HAL_HASH_SuspendTypeDef
HAL HASH mode suspend definitions.
HAL_HASH_StateTypeDef
HAL State structures definition.
@ HAL_HASH_PHASE_HMAC_STEP_1
@ HAL_HASH_PHASE_HMAC_STEP_3
@ HAL_HASH_PHASE_HMAC_STEP_2
@ HAL_HASH_STATE_SUSPENDED
HAL_StatusTypeDef HMAC_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout, uint32_t Algorithm)
Initialize the HASH peripheral in HMAC mode, next process pInBuffer then read the computed digest.
HAL_StatusTypeDef HASH_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm)
If not already done, initialize the HASH peripheral then processes pInBuffer.
HAL_StatusTypeDef HASH_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm)
Initialize the HASH peripheral then initiate a DMA transfer to feed the input buffer to the Periphera...
HAL_StatusTypeDef HASH_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout, uint32_t Algorithm)
Initialize the HASH peripheral, next process pInBuffer then read the computed digest.
HAL_StatusTypeDef HASH_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout)
Return the computed digest.
HAL_StatusTypeDef HASH_Accumulate_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm)
If not already done, initialize the HASH peripheral then processes pInBuffer in interruption mode.
HAL_StatusTypeDef HASH_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Algorithm)
Initialize the HASH peripheral, next process pInBuffer then read the computed digest in interruption ...
HAL_StatusTypeDef HMAC_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm)
Initialize the HASH peripheral in HMAC mode then initiate the required DMA transfers to feed the key ...
HAL_StatusTypeDef HMAC_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Algorithm)
Initialize the HASH peripheral in HMAC mode, next process pInBuffer then read the computed digest in ...
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition
HAL_LockTypeDef
HAL Lock structures definition
Header file of HASH HAL module.
HASH Handle Structure definition.
__IO uint32_t NbWordsAlreadyPushed
HAL_HASH_PhaseTypeDef Phase
uint8_t * pHashOutBuffPtr
__IO HAL_HASH_StateTypeDef State
__IO uint32_t HashInCount
FlagStatus DigestCalculationDisable
uint8_t * pHashMsgBuffPtr
__IO uint32_t HashITCounter
__IO uint32_t HashKeyCount
DMA_HandleTypeDef * hdmain
uint8_t * pHashKeyBuffPtr
HAL_HASH_SuspendTypeDef SuspendRequest
__IO uint32_t Accumulation
HASH Configuration Structure definition.
DMA handle Structure definition.