Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:35

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_hash.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of HASH HAL module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Define to prevent recursive inclusion -------------------------------------*/
0020 #ifndef STM32H7xx_HAL_HASH_H
0021 #define STM32H7xx_HAL_HASH_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx_hal_def.h"
0029 
0030 /** @addtogroup STM32H7xx_HAL_Driver
0031   * @{
0032   */
0033 #if defined (HASH)
0034 /** @addtogroup HASH
0035   * @{
0036   */
0037 
0038 /* Exported types ------------------------------------------------------------*/
0039 /** @defgroup HASH_Exported_Types HASH Exported Types
0040   * @ingroup RTEMSBSPsARMSTM32H7
0041   * @{
0042   */
0043 
0044 /**
0045   * @brief  HASH Configuration Structure definition
0046   */
0047 typedef struct
0048 {
0049   uint32_t DataType;    /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit data.
0050                               This parameter can be a value of @ref HASH_Data_Type. */
0051 
0052   uint32_t KeySize;     /*!< The key size is used only in HMAC operation. */
0053 
0054   uint8_t *pKey;        /*!< The key is used only in HMAC operation. */
0055 
0056 } HASH_InitTypeDef;
0057 
0058 /**
0059   * @brief HAL State structures definition
0060   */
0061 typedef enum
0062 {
0063   HAL_HASH_STATE_RESET             = 0x00U,    /*!< Peripheral is not initialized            */
0064   HAL_HASH_STATE_READY             = 0x01U,    /*!< Peripheral Initialized and ready for use */
0065   HAL_HASH_STATE_BUSY              = 0x02U,    /*!< Processing (hashing) is ongoing          */
0066   HAL_HASH_STATE_TIMEOUT           = 0x06U,    /*!< Timeout state                            */
0067   HAL_HASH_STATE_ERROR             = 0x07U,    /*!< Error state                              */
0068   HAL_HASH_STATE_SUSPENDED         = 0x08U     /*!< Suspended state                          */
0069 } HAL_HASH_StateTypeDef;
0070 
0071 /**
0072   * @brief HAL phase structures definition
0073   */
0074 typedef enum
0075 {
0076   HAL_HASH_PHASE_READY             = 0x01U,    /*!< HASH peripheral is ready to start                    */
0077   HAL_HASH_PHASE_PROCESS           = 0x02U,    /*!< HASH peripheral is in HASH processing phase          */
0078   HAL_HASH_PHASE_HMAC_STEP_1       = 0x03U,    /*!< HASH peripheral is in HMAC step 1 processing phase
0079                                               (step 1 consists in entering the inner hash function key) */
0080   HAL_HASH_PHASE_HMAC_STEP_2       = 0x04U,    /*!< HASH peripheral is in HMAC step 2 processing phase
0081                                               (step 2 consists in entering the message text) */
0082   HAL_HASH_PHASE_HMAC_STEP_3       = 0x05U     /*!< HASH peripheral is in HMAC step 3 processing phase
0083                                               (step 3 consists in entering the outer hash function key) */
0084 } HAL_HASH_PhaseTypeDef;
0085 
0086 /**
0087   * @brief HAL HASH mode suspend definitions
0088   */
0089 typedef enum
0090 {
0091   HAL_HASH_SUSPEND_NONE            = 0x00U,    /*!< HASH peripheral suspension not requested */
0092   HAL_HASH_SUSPEND                 = 0x01U     /*!< HASH peripheral suspension is requested  */
0093 } HAL_HASH_SuspendTypeDef;
0094 
0095 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
0096 /**
0097   * @brief  HAL HASH common Callback ID enumeration definition
0098   */
0099 typedef enum
0100 {
0101   HAL_HASH_MSPINIT_CB_ID           = 0x00U,    /*!< HASH MspInit callback ID     */
0102   HAL_HASH_MSPDEINIT_CB_ID         = 0x01U,    /*!< HASH MspDeInit callback ID   */
0103   HAL_HASH_INPUTCPLT_CB_ID         = 0x02U,    /*!< HASH input completion callback ID */
0104   HAL_HASH_DGSTCPLT_CB_ID          = 0x03U,    /*!< HASH digest computation completion callback ID */
0105   HAL_HASH_ERROR_CB_ID             = 0x04U,    /*!< HASH error callback ID     */
0106 } HAL_HASH_CallbackIDTypeDef;
0107 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
0108 
0109 
0110 /**
0111   * @brief  HASH Handle Structure definition
0112   */
0113 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
0114 typedef struct __HASH_HandleTypeDef
0115 #else
0116 typedef struct
0117 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
0118 {
0119   HASH_InitTypeDef           Init;             /*!< HASH required parameters */
0120 
0121   uint8_t                    *pHashInBuffPtr;  /*!< Pointer to input buffer */
0122 
0123   uint8_t                    *pHashOutBuffPtr; /*!< Pointer to output buffer (digest) */
0124 
0125   uint8_t                    *pHashKeyBuffPtr; /*!< Pointer to key buffer (HMAC only) */
0126 
0127   uint8_t                    *pHashMsgBuffPtr; /*!< Pointer to message buffer (HMAC only) */
0128 
0129   uint32_t                   HashBuffSize;     /*!< Size of buffer to be processed */
0130 
0131   __IO uint32_t              HashInCount;      /*!< Counter of inputted data */
0132 
0133   __IO uint32_t              HashITCounter;    /*!< Counter of issued interrupts */
0134 
0135   __IO uint32_t              HashKeyCount;     /*!< Counter for Key inputted data (HMAC only) */
0136 
0137   HAL_StatusTypeDef          Status;           /*!< HASH peripheral status   */
0138 
0139   HAL_HASH_PhaseTypeDef      Phase;            /*!< HASH peripheral phase   */
0140 
0141   DMA_HandleTypeDef          *hdmain;          /*!< HASH In DMA Handle parameters */
0142 
0143   HAL_LockTypeDef            Lock;             /*!< Locking object */
0144 
0145   __IO HAL_HASH_StateTypeDef State;            /*!< HASH peripheral state */
0146 
0147   HAL_HASH_SuspendTypeDef    SuspendRequest;   /*!< HASH peripheral suspension request flag */
0148 
0149   FlagStatus                 DigestCalculationDisable;  /*!< Digest calculation phase skip (MDMAT bit control) for multi-buffers DMA-based HMAC computation */
0150 
0151   __IO uint32_t              NbWordsAlreadyPushed;      /*!< Numbers of words already pushed in FIFO before inputting new block */
0152 
0153   __IO  uint32_t             ErrorCode;        /*!< HASH Error code */
0154 
0155   __IO  uint32_t             Accumulation;     /*!< HASH multi buffers accumulation flag */
0156 
0157 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
0158   void (* InCpltCallback)(struct __HASH_HandleTypeDef *hhash);         /*!< HASH input completion callback */
0159 
0160   void (* DgstCpltCallback)(struct __HASH_HandleTypeDef *hhash);       /*!< HASH digest computation completion callback */
0161 
0162   void (* ErrorCallback)(struct __HASH_HandleTypeDef *hhash);          /*!< HASH error callback */
0163 
0164   void (* MspInitCallback)(struct __HASH_HandleTypeDef *hhash);        /*!< HASH Msp Init callback */
0165 
0166   void (* MspDeInitCallback)(struct __HASH_HandleTypeDef *hhash);      /*!< HASH Msp DeInit callback */
0167 
0168 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
0169 } HASH_HandleTypeDef;
0170 
0171 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
0172 /**
0173   * @brief  HAL HASH Callback pointer definition
0174   */
0175 typedef  void (*pHASH_CallbackTypeDef)(HASH_HandleTypeDef *hhash);  /*!< pointer to a HASH common callback functions */
0176 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
0177 
0178 /**
0179   * @}
0180   */
0181 
0182 /* Exported constants --------------------------------------------------------*/
0183 
0184 /** @defgroup HASH_Exported_Constants  HASH Exported Constants
0185   * @ingroup RTEMSBSPsARMSTM32H7
0186   * @{
0187   */
0188 
0189 /** @defgroup HASH_Algo_Selection   HASH algorithm selection
0190   * @ingroup RTEMSBSPsARMSTM32H7
0191   * @{
0192   */
0193 #define HASH_ALGOSELECTION_SHA1      0x00000000U /*!< HASH function is SHA1   */
0194 #define HASH_ALGOSELECTION_MD5       HASH_CR_ALGO_0     /*!< HASH function is MD5    */
0195 #define HASH_ALGOSELECTION_SHA224    HASH_CR_ALGO_1     /*!< HASH function is SHA224 */
0196 #define HASH_ALGOSELECTION_SHA256    HASH_CR_ALGO       /*!< HASH function is SHA256 */
0197 /**
0198   * @}
0199   */
0200 
0201 /** @defgroup HASH_Algorithm_Mode   HASH algorithm mode
0202   * @ingroup RTEMSBSPsARMSTM32H7
0203   * @{
0204   */
0205 #define HASH_ALGOMODE_HASH         0x00000000U /*!< Algorithm is HASH */
0206 #define HASH_ALGOMODE_HMAC         HASH_CR_MODE           /*!< Algorithm is HMAC */
0207 /**
0208   * @}
0209   */
0210 
0211 /** @defgroup HASH_Data_Type      HASH input data type
0212   * @ingroup RTEMSBSPsARMSTM32H7
0213   * @{
0214   */
0215 #define HASH_DATATYPE_32B          0x00000000U /*!< 32-bit data. No swapping                     */
0216 #define HASH_DATATYPE_16B          HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped       */
0217 #define HASH_DATATYPE_8B           HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped            */
0218 #define HASH_DATATYPE_1B           HASH_CR_DATATYPE   /*!< 1-bit data. In the word all bits are swapped */
0219 /**
0220   * @}
0221   */
0222 
0223 /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode   HMAC key length type
0224   * @ingroup RTEMSBSPsARMSTM32H7
0225   * @{
0226   */
0227 #define HASH_HMAC_KEYTYPE_SHORTKEY      0x00000000U /*!< HMAC Key size is <= 64 bytes */
0228 #define HASH_HMAC_KEYTYPE_LONGKEY       HASH_CR_LKEY           /*!< HMAC Key size is > 64 bytes  */
0229 /**
0230   * @}
0231   */
0232 
0233 /** @defgroup HASH_flags_definition  HASH flags definitions
0234   * @ingroup RTEMSBSPsARMSTM32H7
0235   * @{
0236   */
0237 #define HASH_FLAG_DINIS            HASH_SR_DINIS  /*!< 16 locations are free in the DIN : a new block can be entered in the Peripheral */
0238 #define HASH_FLAG_DCIS             HASH_SR_DCIS   /*!< Digest calculation complete                                                     */
0239 #define HASH_FLAG_DMAS             HASH_SR_DMAS   /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing                      */
0240 #define HASH_FLAG_BUSY             HASH_SR_BUSY   /*!< The hash core is Busy, processing a block of data                               */
0241 #define HASH_FLAG_DINNE            HASH_CR_DINNE  /*!< DIN not empty : the input buffer contains at least one word of data             */
0242 
0243 /**
0244   * @}
0245   */
0246 
0247 /** @defgroup HASH_interrupts_definition   HASH interrupts definitions
0248   * @ingroup RTEMSBSPsARMSTM32H7
0249   * @{
0250   */
0251 #define HASH_IT_DINI               HASH_IMR_DINIE  /*!< A new block can be entered into the input buffer (DIN) */
0252 #define HASH_IT_DCI                HASH_IMR_DCIE   /*!< Digest calculation complete                            */
0253 
0254 /**
0255   * @}
0256   */
0257 
0258 /** @defgroup HASH_Error_Definition   HASH Error Definition
0259   * @ingroup RTEMSBSPsARMSTM32H7
0260   * @{
0261   */
0262 #define  HAL_HASH_ERROR_NONE             0x00000000U   /*!< No error                */
0263 #define  HAL_HASH_ERROR_IT               0x00000001U   /*!< IT-based process error  */
0264 #define  HAL_HASH_ERROR_DMA              0x00000002U   /*!< DMA-based process error */
0265 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
0266 #define  HAL_HASH_ERROR_INVALID_CALLBACK 0x00000004U   /*!< Invalid Callback error  */
0267 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
0268 /**
0269   * @}
0270   */
0271 
0272 /**
0273   * @}
0274   */
0275 
0276 /* Exported macros -----------------------------------------------------------*/
0277 /** @defgroup HASH_Exported_Macros HASH Exported Macros
0278   * @ingroup RTEMSBSPsARMSTM32H7
0279   * @{
0280   */
0281 
0282 /** @brief  Check whether or not the specified HASH flag is set.
0283   * @param  __FLAG__ specifies the flag to check.
0284   *        This parameter can be one of the following values:
0285   *            @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
0286   *            @arg @ref HASH_FLAG_DCIS Digest calculation complete.
0287   *            @arg @ref HASH_FLAG_DMAS DMA interface is enabled (DMAE=1) or a transfer is ongoing.
0288   *            @arg @ref HASH_FLAG_BUSY The hash core is Busy : processing a block of data.
0289   *            @arg @ref HASH_FLAG_DINNE DIN not empty : the input buffer contains at least one word of data.
0290   * @retval The new state of __FLAG__ (TRUE or FALSE).
0291   */
0292 #define __HAL_HASH_GET_FLAG(__FLAG__)  (((__FLAG__) > 8U)  ?                    \
0293                                         ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
0294                                         ((HASH->SR & (__FLAG__)) == (__FLAG__)) )
0295 
0296 
0297 /** @brief  Clear the specified HASH flag.
0298   * @param  __FLAG__ specifies the flag to clear.
0299   *        This parameter can be one of the following values:
0300   *            @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
0301   *            @arg @ref HASH_FLAG_DCIS Digest calculation complete
0302   * @retval None
0303   */
0304 #define __HAL_HASH_CLEAR_FLAG(__FLAG__) CLEAR_BIT(HASH->SR, (__FLAG__))
0305 
0306 
0307 /** @brief  Enable the specified HASH interrupt.
0308   * @param  __INTERRUPT__ specifies the HASH interrupt source to enable.
0309   *          This parameter can be one of the following values:
0310   *            @arg @ref HASH_IT_DINI  A new block can be entered into the input buffer (DIN)
0311   *            @arg @ref HASH_IT_DCI   Digest calculation complete
0312   * @retval None
0313   */
0314 #define __HAL_HASH_ENABLE_IT(__INTERRUPT__)   SET_BIT(HASH->IMR, (__INTERRUPT__))
0315 
0316 /** @brief  Disable the specified HASH interrupt.
0317   * @param  __INTERRUPT__ specifies the HASH interrupt source to disable.
0318   *          This parameter can be one of the following values:
0319   *            @arg @ref HASH_IT_DINI  A new block can be entered into the input buffer (DIN)
0320   *            @arg @ref HASH_IT_DCI   Digest calculation complete
0321   * @retval None
0322   */
0323 #define __HAL_HASH_DISABLE_IT(__INTERRUPT__)   CLEAR_BIT(HASH->IMR, (__INTERRUPT__))
0324 
0325 /** @brief Reset HASH handle state.
0326   * @param  __HANDLE__ HASH handle.
0327   * @retval None
0328   */
0329 
0330 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
0331 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) do{\
0332                                                       (__HANDLE__)->State = HAL_HASH_STATE_RESET;\
0333                                                       (__HANDLE__)->MspInitCallback = NULL;      \
0334                                                       (__HANDLE__)->MspDeInitCallback = NULL;    \
0335                                                      }while(0)
0336 #else
0337 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
0338 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
0339 
0340 
0341 /** @brief Reset HASH handle status.
0342   * @param  __HANDLE__ HASH handle.
0343   * @retval None
0344   */
0345 #define __HAL_HASH_RESET_HANDLE_STATUS(__HANDLE__) ((__HANDLE__)->Status = HAL_OK)
0346 
0347 /**
0348   * @brief  Enable the multi-buffer DMA transfer mode.
0349   * @note   This bit is set when hashing large files when multiple DMA transfers are needed.
0350   * @retval None
0351   */
0352 #define __HAL_HASH_SET_MDMAT()          SET_BIT(HASH->CR, HASH_CR_MDMAT)
0353 
0354 /**
0355   * @brief  Disable the multi-buffer DMA transfer mode.
0356   * @retval None
0357   */
0358 #define __HAL_HASH_RESET_MDMAT()        CLEAR_BIT(HASH->CR, HASH_CR_MDMAT)
0359 
0360 
0361 /**
0362   * @brief Start the digest computation.
0363   * @retval None
0364   */
0365 #define __HAL_HASH_START_DIGEST()       SET_BIT(HASH->STR, HASH_STR_DCAL)
0366 
0367 /**
0368   * @brief Set the number of valid bits in the last word written in data register DIN.
0369   * @param  __SIZE__ size in bytes of last data written in Data register.
0370   * @retval None
0371   */
0372 #define  __HAL_HASH_SET_NBVALIDBITS(__SIZE__)    MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8U * ((__SIZE__) % 4U))
0373 
0374 /**
0375   * @brief Reset the HASH core.
0376   * @retval None
0377   */
0378 #define __HAL_HASH_INIT()       SET_BIT(HASH->CR, HASH_CR_INIT)
0379 
0380 /**
0381   * @}
0382   */
0383 
0384 
0385 /* Private macros --------------------------------------------------------*/
0386 /** @defgroup HASH_Private_Macros   HASH Private Macros
0387   * @ingroup RTEMSBSPsARMSTM32H7
0388   * @{
0389   */
0390 /**
0391   * @brief  Return digest length in bytes.
0392   * @retval Digest length
0393   */
0394 #define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1)   ?  20U : \
0395                               ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA224) ?  28U : \
0396                                ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA256) ?  32U : 16U ) ) )
0397 /**
0398   * @brief  Return number of words already pushed in the FIFO.
0399   * @retval Number of words already pushed in the FIFO
0400   */
0401 #define HASH_NBW_PUSHED() ((READ_BIT(HASH->CR, HASH_CR_NBW)) >> 8U)
0402 
0403 /**
0404   * @brief Ensure that HASH input data type is valid.
0405   * @param __DATATYPE__ HASH input data type.
0406   * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid)
0407   */
0408 #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
0409                                         ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
0410                                         ((__DATATYPE__) == HASH_DATATYPE_8B) || \
0411                                         ((__DATATYPE__) == HASH_DATATYPE_1B))
0412 
0413 /**
0414   * @brief Ensure that input data buffer size is valid for multi-buffer HASH
0415   *        processing in DMA mode.
0416   * @note  This check is valid only for multi-buffer HASH processing in DMA mode.
0417   * @param __SIZE__ input data buffer size.
0418   * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
0419   */
0420 #define IS_HASH_DMA_MULTIBUFFER_SIZE(__SIZE__)  ((READ_BIT(HASH->CR, HASH_CR_MDMAT) == 0U) || (((__SIZE__) % 4U) == 0U))
0421 
0422 /**
0423   * @brief Ensure that input data buffer size is valid for multi-buffer HMAC
0424   *        processing in DMA mode.
0425   * @note  This check is valid only for multi-buffer HMAC processing in DMA mode.
0426   * @param __HANDLE__ HASH handle.
0427   * @param __SIZE__ input data buffer size.
0428   * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
0429   */
0430 #define IS_HMAC_DMA_MULTIBUFFER_SIZE(__HANDLE__,__SIZE__)  ((((__HANDLE__)->DigestCalculationDisable) == RESET)\
0431                                                             || (((__SIZE__) % 4U) == 0U))
0432 /**
0433   * @brief Ensure that handle phase is set to HASH processing.
0434   * @param __HANDLE__ HASH handle.
0435   * @retval SET (handle phase is set to HASH processing) or RESET (handle phase is not set to HASH processing)
0436   */
0437 #define IS_HASH_PROCESSING(__HANDLE__)  ((__HANDLE__)->Phase == HAL_HASH_PHASE_PROCESS)
0438 
0439 /**
0440   * @brief Ensure that handle phase is set to HMAC processing.
0441   * @param __HANDLE__ HASH handle.
0442   * @retval SET (handle phase is set to HMAC processing) or RESET (handle phase is not set to HMAC processing)
0443   */
0444 #define IS_HMAC_PROCESSING(__HANDLE__)  (((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_1) || \
0445                                          ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_2) || \
0446                                          ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_3))
0447 
0448 /**
0449   * @}
0450   */
0451 
0452 /* Include HASH HAL Extended module */
0453 #include "stm32h7xx_hal_hash_ex.h"
0454 /* Exported functions --------------------------------------------------------*/
0455 
0456 /** @addtogroup HASH_Exported_Functions HASH Exported Functions
0457   * @{
0458   */
0459 
0460 /** @addtogroup HASH_Exported_Functions_Group1 Initialization and de-initialization functions
0461   * @{
0462   */
0463 
0464 /* Initialization/de-initialization methods  **********************************/
0465 HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
0466 HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
0467 void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
0468 void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
0469 void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
0470 void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
0471 void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
0472 /* Callbacks Register/UnRegister functions  ***********************************/
0473 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
0474 HAL_StatusTypeDef HAL_HASH_RegisterCallback(HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID,
0475                                             pHASH_CallbackTypeDef pCallback);
0476 HAL_StatusTypeDef HAL_HASH_UnRegisterCallback(HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID);
0477 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
0478 
0479 
0480 /**
0481   * @}
0482   */
0483 
0484 /** @addtogroup HASH_Exported_Functions_Group2 HASH processing functions in polling mode
0485   * @{
0486   */
0487 
0488 
0489 /* HASH processing using polling  *********************************************/
0490 HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0491                                       uint32_t Timeout);
0492 HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0493                                      uint32_t Timeout);
0494 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0495 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0496 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0497                                           uint8_t *pOutBuffer, uint32_t Timeout);
0498 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0499                                            uint8_t *pOutBuffer, uint32_t Timeout);
0500 
0501 
0502 /**
0503   * @}
0504   */
0505 
0506 /** @addtogroup HASH_Exported_Functions_Group3 HASH processing functions in interrupt mode
0507   * @{
0508   */
0509 
0510 /* HASH processing using IT  **************************************************/
0511 HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0512                                          uint8_t *pOutBuffer);
0513 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0514 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0515                                               uint8_t *pOutBuffer);
0516 HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0517                                         uint8_t *pOutBuffer);
0518 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0519 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0520                                              uint8_t *pOutBuffer);
0521 void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
0522 /**
0523   * @}
0524   */
0525 
0526 /** @addtogroup HASH_Exported_Functions_Group4 HASH processing functions in DMA mode
0527   * @{
0528   */
0529 
0530 /* HASH processing using DMA  *************************************************/
0531 HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0532 HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
0533 HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0534 HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
0535 
0536 /**
0537   * @}
0538   */
0539 
0540 /** @addtogroup HASH_Exported_Functions_Group5 HMAC processing functions in polling mode
0541   * @{
0542   */
0543 
0544 /* HASH-MAC processing using polling  *****************************************/
0545 HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0546                                       uint32_t Timeout);
0547 HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0548                                      uint32_t Timeout);
0549 
0550 /**
0551   * @}
0552   */
0553 
0554 /** @addtogroup HASH_Exported_Functions_Group6 HMAC processing functions in interrupt mode
0555   * @{
0556   */
0557 
0558 HAL_StatusTypeDef HAL_HMAC_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0559                                         uint8_t *pOutBuffer);
0560 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
0561                                          uint8_t *pOutBuffer);
0562 
0563 /**
0564   * @}
0565   */
0566 
0567 /** @addtogroup HASH_Exported_Functions_Group7 HMAC processing functions in DMA mode
0568   * @{
0569   */
0570 
0571 /* HASH-HMAC processing using DMA  ********************************************/
0572 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0573 HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
0574 
0575 /**
0576   * @}
0577   */
0578 
0579 /** @addtogroup HASH_Exported_Functions_Group8 Peripheral states functions
0580   * @{
0581   */
0582 
0583 
0584 /* Peripheral State methods  **************************************************/
0585 HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
0586 HAL_StatusTypeDef HAL_HASH_GetStatus(HASH_HandleTypeDef *hhash);
0587 void HAL_HASH_ContextSaving(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer);
0588 void HAL_HASH_ContextRestoring(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer);
0589 void HAL_HASH_SwFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
0590 HAL_StatusTypeDef HAL_HASH_DMAFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
0591 uint32_t HAL_HASH_GetError(HASH_HandleTypeDef *hhash);
0592 
0593 /**
0594   * @}
0595   */
0596 
0597 /**
0598   * @}
0599   */
0600 
0601 /* Private functions -----------------------------------------------------------*/
0602 
0603 /** @addtogroup HASH_Private_Functions HASH Private Functions
0604   * @{
0605   */
0606 
0607 /* Private functions */
0608 HAL_StatusTypeDef HASH_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0609                              uint32_t Timeout, uint32_t Algorithm);
0610 HAL_StatusTypeDef HASH_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
0611 HAL_StatusTypeDef HASH_Accumulate_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
0612 HAL_StatusTypeDef HASH_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0613                                 uint32_t Algorithm);
0614 HAL_StatusTypeDef HASH_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
0615 HAL_StatusTypeDef HASH_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
0616 HAL_StatusTypeDef HMAC_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0617                              uint32_t Timeout, uint32_t Algorithm);
0618 HAL_StatusTypeDef HMAC_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
0619                                 uint32_t Algorithm);
0620 HAL_StatusTypeDef HMAC_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
0621 
0622 /**
0623   * @}
0624   */
0625 
0626 /**
0627   * @}
0628   */
0629 #endif /*  HASH*/
0630 /**
0631   * @}
0632   */
0633 
0634 
0635 #ifdef __cplusplus
0636 }
0637 #endif
0638 
0639 
0640 #endif /* STM32H7xx_HAL_HASH_H */
0641