STM32F479xx HAL User Manual
stm32f4xx_hal_hash.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_hash.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of HASH HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef STM32F4xx_HAL_HASH_H
00022 #define STM32F4xx_HAL_HASH_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal_def.h"
00030 
00031 /** @addtogroup STM32F4xx_HAL_Driver
00032   * @{
00033   */
00034 #if defined (HASH)
00035 /** @addtogroup HASH
00036   * @{
00037   */
00038 
00039 /* Exported types ------------------------------------------------------------*/
00040 /** @defgroup HASH_Exported_Types HASH Exported Types
00041   * @{
00042   */
00043 
00044 /**
00045   * @brief  HASH Configuration Structure definition
00046   */
00047 typedef struct
00048 {
00049   uint32_t DataType;    /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit data.
00050                               This parameter can be a value of @ref HASH_Data_Type. */
00051 
00052   uint32_t KeySize;     /*!< The key size is used only in HMAC operation. */
00053 
00054   uint8_t *pKey;        /*!< The key is used only in HMAC operation. */
00055 
00056 } HASH_InitTypeDef;
00057 
00058 /**
00059   * @brief HAL State structures definition
00060   */
00061 typedef enum
00062 {
00063   HAL_HASH_STATE_RESET             = 0x00U,    /*!< Peripheral is not initialized            */
00064   HAL_HASH_STATE_READY             = 0x01U,    /*!< Peripheral Initialized and ready for use */
00065   HAL_HASH_STATE_BUSY              = 0x02U,    /*!< Processing (hashing) is ongoing          */
00066   HAL_HASH_STATE_TIMEOUT           = 0x06U,    /*!< Timeout state                            */
00067   HAL_HASH_STATE_ERROR             = 0x07U,    /*!< Error state                              */
00068   HAL_HASH_STATE_SUSPENDED         = 0x08U     /*!< Suspended state                          */
00069 } HAL_HASH_StateTypeDef;
00070 
00071 /**
00072   * @brief HAL phase structures definition
00073   */
00074 typedef enum
00075 {
00076   HAL_HASH_PHASE_READY             = 0x01U,    /*!< HASH peripheral is ready to start                    */
00077   HAL_HASH_PHASE_PROCESS           = 0x02U,    /*!< HASH peripheral is in HASH processing phase          */
00078   HAL_HASH_PHASE_HMAC_STEP_1       = 0x03U,    /*!< HASH peripheral is in HMAC step 1 processing phase
00079                                               (step 1 consists in entering the inner hash function key) */
00080   HAL_HASH_PHASE_HMAC_STEP_2       = 0x04U,    /*!< HASH peripheral is in HMAC step 2 processing phase
00081                                               (step 2 consists in entering the message text) */
00082   HAL_HASH_PHASE_HMAC_STEP_3       = 0x05U     /*!< HASH peripheral is in HMAC step 3 processing phase
00083                                               (step 3 consists in entering the outer hash function key) */
00084 } HAL_HASH_PhaseTypeDef;
00085 
00086 /**
00087   * @brief HAL HASH mode suspend definitions
00088   */
00089 typedef enum
00090 {
00091   HAL_HASH_SUSPEND_NONE            = 0x00U,    /*!< HASH peripheral suspension not requested */
00092   HAL_HASH_SUSPEND                 = 0x01U     /*!< HASH peripheral suspension is requested  */
00093 } HAL_HASH_SuspendTypeDef;
00094 
00095 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
00096 /**
00097   * @brief  HAL HASH common Callback ID enumeration definition
00098   */
00099 typedef enum
00100 {
00101   HAL_HASH_MSPINIT_CB_ID           = 0x00U,    /*!< HASH MspInit callback ID     */
00102   HAL_HASH_MSPDEINIT_CB_ID         = 0x01U,    /*!< HASH MspDeInit callback ID   */
00103   HAL_HASH_INPUTCPLT_CB_ID         = 0x02U,    /*!< HASH input completion callback ID */
00104   HAL_HASH_DGSTCPLT_CB_ID          = 0x03U,    /*!< HASH digest computation completion callback ID */
00105   HAL_HASH_ERROR_CB_ID             = 0x04U,    /*!< HASH error callback ID     */
00106 } HAL_HASH_CallbackIDTypeDef;
00107 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
00108 
00109 
00110 /**
00111   * @brief  HASH Handle Structure definition
00112   */
00113 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
00114 typedef struct __HASH_HandleTypeDef
00115 #else
00116 typedef struct
00117 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
00118 {
00119   HASH_InitTypeDef           Init;             /*!< HASH required parameters */
00120 
00121   uint8_t                    *pHashInBuffPtr;  /*!< Pointer to input buffer */
00122 
00123   uint8_t                    *pHashOutBuffPtr; /*!< Pointer to output buffer (digest) */
00124 
00125   uint8_t                    *pHashKeyBuffPtr; /*!< Pointer to key buffer (HMAC only) */
00126 
00127   uint8_t                    *pHashMsgBuffPtr; /*!< Pointer to message buffer (HMAC only) */
00128 
00129   uint32_t                   HashBuffSize;     /*!< Size of buffer to be processed */
00130 
00131   __IO uint32_t              HashInCount;      /*!< Counter of inputted data */
00132 
00133   __IO uint32_t              HashITCounter;    /*!< Counter of issued interrupts */
00134 
00135   __IO uint32_t              HashKeyCount;     /*!< Counter for Key inputted data (HMAC only) */
00136 
00137   HAL_StatusTypeDef          Status;           /*!< HASH peripheral status   */
00138 
00139   HAL_HASH_PhaseTypeDef      Phase;            /*!< HASH peripheral phase   */
00140 
00141   DMA_HandleTypeDef          *hdmain;          /*!< HASH In DMA Handle parameters */
00142 
00143   HAL_LockTypeDef            Lock;             /*!< Locking object */
00144 
00145   __IO HAL_HASH_StateTypeDef State;            /*!< HASH peripheral state */
00146 
00147   HAL_HASH_SuspendTypeDef    SuspendRequest;   /*!< HASH peripheral suspension request flag */
00148 
00149   FlagStatus                 DigestCalculationDisable;  /*!< Digest calculation phase skip (MDMAT bit control) for multi-buffers DMA-based HMAC computation */
00150 
00151   __IO uint32_t              NbWordsAlreadyPushed;      /*!< Numbers of words already pushed in FIFO before inputting new block */
00152 
00153   __IO  uint32_t             ErrorCode;        /*!< HASH Error code */
00154 
00155   __IO  uint32_t             Accumulation;     /*!< HASH multi buffers accumulation flag */
00156 
00157 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
00158   void (* InCpltCallback)(struct __HASH_HandleTypeDef *hhash);         /*!< HASH input completion callback */
00159 
00160   void (* DgstCpltCallback)(struct __HASH_HandleTypeDef *hhash);       /*!< HASH digest computation completion callback */
00161 
00162   void (* ErrorCallback)(struct __HASH_HandleTypeDef *hhash);          /*!< HASH error callback */
00163 
00164   void (* MspInitCallback)(struct __HASH_HandleTypeDef *hhash);        /*!< HASH Msp Init callback */
00165 
00166   void (* MspDeInitCallback)(struct __HASH_HandleTypeDef *hhash);      /*!< HASH Msp DeInit callback */
00167 
00168 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
00169 } HASH_HandleTypeDef;
00170 
00171 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
00172 /**
00173   * @brief  HAL HASH Callback pointer definition
00174   */
00175 typedef  void (*pHASH_CallbackTypeDef)(HASH_HandleTypeDef *hhash);  /*!< pointer to a HASH common callback functions */
00176 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
00177 
00178 /**
00179   * @}
00180   */
00181 
00182 /* Exported constants --------------------------------------------------------*/
00183 
00184 /** @defgroup HASH_Exported_Constants  HASH Exported Constants
00185   * @{
00186   */
00187 
00188 /** @defgroup HASH_Algo_Selection   HASH algorithm selection
00189   * @{
00190   */
00191 #define HASH_ALGOSELECTION_SHA1      0x00000000U /*!< HASH function is SHA1   */
00192 #define HASH_ALGOSELECTION_MD5       HASH_CR_ALGO_0     /*!< HASH function is MD5    */
00193 #define HASH_ALGOSELECTION_SHA224    HASH_CR_ALGO_1     /*!< HASH function is SHA224 */
00194 #define HASH_ALGOSELECTION_SHA256    HASH_CR_ALGO       /*!< HASH function is SHA256 */
00195 /**
00196   * @}
00197   */
00198 
00199 /** @defgroup HASH_Algorithm_Mode   HASH algorithm mode
00200   * @{
00201   */
00202 #define HASH_ALGOMODE_HASH         0x00000000U /*!< Algorithm is HASH */
00203 #define HASH_ALGOMODE_HMAC         HASH_CR_MODE           /*!< Algorithm is HMAC */
00204 /**
00205   * @}
00206   */
00207 
00208 /** @defgroup HASH_Data_Type      HASH input data type
00209   * @{
00210   */
00211 #define HASH_DATATYPE_32B          0x00000000U /*!< 32-bit data. No swapping                     */
00212 #define HASH_DATATYPE_16B          HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped       */
00213 #define HASH_DATATYPE_8B           HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped            */
00214 #define HASH_DATATYPE_1B           HASH_CR_DATATYPE   /*!< 1-bit data. In the word all bits are swapped */
00215 /**
00216   * @}
00217   */
00218 
00219 /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode   HMAC key length type
00220   * @{
00221   */
00222 #define HASH_HMAC_KEYTYPE_SHORTKEY      0x00000000U /*!< HMAC Key size is <= 64 bytes */
00223 #define HASH_HMAC_KEYTYPE_LONGKEY       HASH_CR_LKEY           /*!< HMAC Key size is > 64 bytes  */
00224 /**
00225   * @}
00226   */
00227 
00228 /** @defgroup HASH_flags_definition  HASH flags definitions
00229   * @{
00230   */
00231 #define HASH_FLAG_DINIS            HASH_SR_DINIS  /*!< 16 locations are free in the DIN : a new block can be entered in the Peripheral */
00232 #define HASH_FLAG_DCIS             HASH_SR_DCIS   /*!< Digest calculation complete                                                     */
00233 #define HASH_FLAG_DMAS             HASH_SR_DMAS   /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing                      */
00234 #define HASH_FLAG_BUSY             HASH_SR_BUSY   /*!< The hash core is Busy, processing a block of data                               */
00235 #define HASH_FLAG_DINNE            HASH_CR_DINNE  /*!< DIN not empty : the input buffer contains at least one word of data             */
00236 
00237 /**
00238   * @}
00239   */
00240 
00241 /** @defgroup HASH_interrupts_definition   HASH interrupts definitions
00242   * @{
00243   */
00244 #define HASH_IT_DINI               HASH_IMR_DINIE  /*!< A new block can be entered into the input buffer (DIN) */
00245 #define HASH_IT_DCI                HASH_IMR_DCIE   /*!< Digest calculation complete                            */
00246 
00247 /**
00248   * @}
00249   */
00250 
00251 /** @defgroup HASH_Error_Definition   HASH Error Definition
00252   * @{
00253   */
00254 #define  HAL_HASH_ERROR_NONE             0x00000000U   /*!< No error                */
00255 #define  HAL_HASH_ERROR_IT               0x00000001U   /*!< IT-based process error  */
00256 #define  HAL_HASH_ERROR_DMA              0x00000002U   /*!< DMA-based process error */
00257 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1U)
00258 #define  HAL_HASH_ERROR_INVALID_CALLBACK 0x00000004U   /*!< Invalid Callback error  */
00259 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
00260 /**
00261   * @}
00262   */
00263 
00264 /**
00265   * @}
00266   */
00267 
00268 /* Exported macros -----------------------------------------------------------*/
00269 /** @defgroup HASH_Exported_Macros HASH Exported Macros
00270   * @{
00271   */
00272 
00273 /** @brief  Check whether or not the specified HASH flag is set.
00274   * @param  __FLAG__ specifies the flag to check.
00275   *        This parameter can be one of the following values:
00276   *            @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
00277   *            @arg @ref HASH_FLAG_DCIS Digest calculation complete.
00278   *            @arg @ref HASH_FLAG_DMAS DMA interface is enabled (DMAE=1) or a transfer is ongoing.
00279   *            @arg @ref HASH_FLAG_BUSY The hash core is Busy : processing a block of data.
00280   *            @arg @ref HASH_FLAG_DINNE DIN not empty : the input buffer contains at least one word of data.
00281   * @retval The new state of __FLAG__ (TRUE or FALSE).
00282   */
00283 #define __HAL_HASH_GET_FLAG(__FLAG__)  (((__FLAG__) > 8U)  ?                    \
00284                                         ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
00285                                         ((HASH->SR & (__FLAG__)) == (__FLAG__)) )
00286 
00287 
00288 /** @brief  Clear the specified HASH flag.
00289   * @param  __FLAG__ specifies the flag to clear.
00290   *        This parameter can be one of the following values:
00291   *            @arg @ref HASH_FLAG_DINIS A new block can be entered into the input buffer.
00292   *            @arg @ref HASH_FLAG_DCIS Digest calculation complete
00293   * @retval None
00294   */
00295 #define __HAL_HASH_CLEAR_FLAG(__FLAG__) CLEAR_BIT(HASH->SR, (__FLAG__))
00296 
00297 
00298 /** @brief  Enable the specified HASH interrupt.
00299   * @param  __INTERRUPT__ specifies the HASH interrupt source to enable.
00300   *          This parameter can be one of the following values:
00301   *            @arg @ref HASH_IT_DINI  A new block can be entered into the input buffer (DIN)
00302   *            @arg @ref HASH_IT_DCI   Digest calculation complete
00303   * @retval None
00304   */
00305 #define __HAL_HASH_ENABLE_IT(__INTERRUPT__)   SET_BIT(HASH->IMR, (__INTERRUPT__))
00306 
00307 /** @brief  Disable the specified HASH interrupt.
00308   * @param  __INTERRUPT__ specifies the HASH interrupt source to disable.
00309   *          This parameter can be one of the following values:
00310   *            @arg @ref HASH_IT_DINI  A new block can be entered into the input buffer (DIN)
00311   *            @arg @ref HASH_IT_DCI   Digest calculation complete
00312   * @retval None
00313   */
00314 #define __HAL_HASH_DISABLE_IT(__INTERRUPT__)   CLEAR_BIT(HASH->IMR, (__INTERRUPT__))
00315 
00316 /** @brief Reset HASH handle state.
00317   * @param  __HANDLE__ HASH handle.
00318   * @retval None
00319   */
00320 
00321 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
00322 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) do{\
00323                                                       (__HANDLE__)->State = HAL_HASH_STATE_RESET;\
00324                                                       (__HANDLE__)->MspInitCallback = NULL;      \
00325                                                       (__HANDLE__)->MspDeInitCallback = NULL;    \
00326                                                      }while(0)
00327 #else
00328 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
00329 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
00330 
00331 
00332 /** @brief Reset HASH handle status.
00333   * @param  __HANDLE__ HASH handle.
00334   * @retval None
00335   */
00336 #define __HAL_HASH_RESET_HANDLE_STATUS(__HANDLE__) ((__HANDLE__)->Status = HAL_OK)
00337 
00338 /**
00339   * @brief  Enable the multi-buffer DMA transfer mode.
00340   * @note   This bit is set when hashing large files when multiple DMA transfers are needed.
00341   * @retval None
00342   */
00343 #define __HAL_HASH_SET_MDMAT()          SET_BIT(HASH->CR, HASH_CR_MDMAT)
00344 
00345 /**
00346   * @brief  Disable the multi-buffer DMA transfer mode.
00347   * @retval None
00348   */
00349 #define __HAL_HASH_RESET_MDMAT()        CLEAR_BIT(HASH->CR, HASH_CR_MDMAT)
00350 
00351 
00352 /**
00353   * @brief Start the digest computation.
00354   * @retval None
00355   */
00356 #define __HAL_HASH_START_DIGEST()       SET_BIT(HASH->STR, HASH_STR_DCAL)
00357 
00358 /**
00359   * @brief Set the number of valid bits in the last word written in data register DIN.
00360   * @param  __SIZE__ size in bytes of last data written in Data register.
00361   * @retval None
00362   */
00363 #define  __HAL_HASH_SET_NBVALIDBITS(__SIZE__)    MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8U * ((__SIZE__) % 4U))
00364 
00365 /**
00366   * @brief Reset the HASH core.
00367   * @retval None
00368   */
00369 #define __HAL_HASH_INIT()       SET_BIT(HASH->CR, HASH_CR_INIT)
00370 
00371 /**
00372   * @}
00373   */
00374 
00375 
00376 /* Private macros --------------------------------------------------------*/
00377 /** @defgroup HASH_Private_Macros   HASH Private Macros
00378   * @{
00379   */
00380 /**
00381   * @brief  Return digest length in bytes.
00382   * @retval Digest length
00383   */
00384 #if defined(HASH_CR_MDMAT)
00385 #define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1)   ?  20U : \
00386                               ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA224) ?  28U : \
00387                                ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA256) ?  32U : 16U ) ) )
00388 #else
00389 #define HASH_DIGEST_LENGTH() ((READ_BIT(HASH->CR, HASH_CR_ALGO) == HASH_ALGOSELECTION_SHA1)   ?  20U : 16)
00390 #endif  /* HASH_CR_MDMAT*/
00391 /**
00392   * @brief  Return number of words already pushed in the FIFO.
00393   * @retval Number of words already pushed in the FIFO
00394   */
00395 #define HASH_NBW_PUSHED() ((READ_BIT(HASH->CR, HASH_CR_NBW)) >> 8U)
00396 
00397 /**
00398   * @brief Ensure that HASH input data type is valid.
00399   * @param __DATATYPE__ HASH input data type.
00400   * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid)
00401   */
00402 #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
00403                                         ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
00404                                         ((__DATATYPE__) == HASH_DATATYPE_8B) || \
00405                                         ((__DATATYPE__) == HASH_DATATYPE_1B))
00406 
00407 /**
00408   * @brief Ensure that input data buffer size is valid for multi-buffer HASH
00409   *        processing in DMA mode.
00410   * @note  This check is valid only for multi-buffer HASH processing in DMA mode.
00411   * @param __SIZE__ input data buffer size.
00412   * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
00413   */
00414 #define IS_HASH_DMA_MULTIBUFFER_SIZE(__SIZE__)  ((READ_BIT(HASH->CR, HASH_CR_MDMAT) == 0U) || (((__SIZE__) % 4U) == 0U))
00415 
00416 /**
00417   * @brief Ensure that input data buffer size is valid for multi-buffer HMAC
00418   *        processing in DMA mode.
00419   * @note  This check is valid only for multi-buffer HMAC processing in DMA mode.
00420   * @param __HANDLE__ HASH handle.
00421   * @param __SIZE__ input data buffer size.
00422   * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
00423   */
00424 #define IS_HMAC_DMA_MULTIBUFFER_SIZE(__HANDLE__,__SIZE__)  ((((__HANDLE__)->DigestCalculationDisable) == RESET)\
00425                                                             || (((__SIZE__) % 4U) == 0U))
00426 /**
00427   * @brief Ensure that handle phase is set to HASH processing.
00428   * @param __HANDLE__ HASH handle.
00429   * @retval SET (handle phase is set to HASH processing) or RESET (handle phase is not set to HASH processing)
00430   */
00431 #define IS_HASH_PROCESSING(__HANDLE__)  ((__HANDLE__)->Phase == HAL_HASH_PHASE_PROCESS)
00432 
00433 /**
00434   * @brief Ensure that handle phase is set to HMAC processing.
00435   * @param __HANDLE__ HASH handle.
00436   * @retval SET (handle phase is set to HMAC processing) or RESET (handle phase is not set to HMAC processing)
00437   */
00438 #define IS_HMAC_PROCESSING(__HANDLE__)  (((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_1) || \
00439                                          ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_2) || \
00440                                          ((__HANDLE__)->Phase == HAL_HASH_PHASE_HMAC_STEP_3))
00441 
00442 /**
00443   * @}
00444   */
00445 
00446 /* Include HASH HAL Extended module */
00447 #include "stm32f4xx_hal_hash_ex.h"
00448 /* Exported functions --------------------------------------------------------*/
00449 
00450 /** @addtogroup HASH_Exported_Functions HASH Exported Functions
00451   * @{
00452   */
00453 
00454 /** @addtogroup HASH_Exported_Functions_Group1 Initialization and de-initialization functions
00455   * @{
00456   */
00457 
00458 /* Initialization/de-initialization methods  **********************************/
00459 HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
00460 HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
00461 void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
00462 void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
00463 void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
00464 void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
00465 void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
00466 /* Callbacks Register/UnRegister functions  ***********************************/
00467 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
00468 HAL_StatusTypeDef HAL_HASH_RegisterCallback(HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID,
00469                                             pHASH_CallbackTypeDef pCallback);
00470 HAL_StatusTypeDef HAL_HASH_UnRegisterCallback(HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID);
00471 #endif /* USE_HAL_HASH_REGISTER_CALLBACKS */
00472 
00473 
00474 /**
00475   * @}
00476   */
00477 
00478 /** @addtogroup HASH_Exported_Functions_Group2 HASH processing functions in polling mode
00479   * @{
00480   */
00481 
00482 
00483 /* HASH processing using polling  *********************************************/
00484 HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00485                                       uint32_t Timeout);
00486 HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00487                                      uint32_t Timeout);
00488 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00489 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00490 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00491                                           uint8_t *pOutBuffer, uint32_t Timeout);
00492 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00493                                            uint8_t *pOutBuffer, uint32_t Timeout);
00494 
00495 
00496 /**
00497   * @}
00498   */
00499 
00500 /** @addtogroup HASH_Exported_Functions_Group3 HASH processing functions in interrupt mode
00501   * @{
00502   */
00503 
00504 /* HASH processing using IT  **************************************************/
00505 HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00506                                          uint8_t *pOutBuffer);
00507 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00508 HAL_StatusTypeDef HAL_HASH_SHA1_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00509                                               uint8_t *pOutBuffer);
00510 HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00511                                         uint8_t *pOutBuffer);
00512 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00513 HAL_StatusTypeDef HAL_HASH_MD5_Accmlt_End_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00514                                              uint8_t *pOutBuffer);
00515 void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
00516 /**
00517   * @}
00518   */
00519 
00520 /** @addtogroup HASH_Exported_Functions_Group4 HASH processing functions in DMA mode
00521   * @{
00522   */
00523 
00524 /* HASH processing using DMA  *************************************************/
00525 HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00526 HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
00527 HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00528 HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
00529 
00530 /**
00531   * @}
00532   */
00533 
00534 /** @addtogroup HASH_Exported_Functions_Group5 HMAC processing functions in polling mode
00535   * @{
00536   */
00537 
00538 /* HASH-MAC processing using polling  *****************************************/
00539 HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00540                                       uint32_t Timeout);
00541 HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00542                                      uint32_t Timeout);
00543 
00544 /**
00545   * @}
00546   */
00547 
00548 /** @addtogroup HASH_Exported_Functions_Group6 HMAC processing functions in interrupt mode
00549   * @{
00550   */
00551 
00552 HAL_StatusTypeDef HAL_HMAC_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00553                                         uint8_t *pOutBuffer);
00554 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size,
00555                                          uint8_t *pOutBuffer);
00556 
00557 /**
00558   * @}
00559   */
00560 
00561 /** @addtogroup HASH_Exported_Functions_Group7 HMAC processing functions in DMA mode
00562   * @{
00563   */
00564 
00565 /* HASH-HMAC processing using DMA  ********************************************/
00566 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00567 HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
00568 
00569 /**
00570   * @}
00571   */
00572 
00573 /** @addtogroup HASH_Exported_Functions_Group8 Peripheral states functions
00574   * @{
00575   */
00576 
00577 
00578 /* Peripheral State methods  **************************************************/
00579 HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
00580 HAL_StatusTypeDef HAL_HASH_GetStatus(HASH_HandleTypeDef *hhash);
00581 void HAL_HASH_ContextSaving(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer);
00582 void HAL_HASH_ContextRestoring(HASH_HandleTypeDef *hhash, uint8_t *pMemBuffer);
00583 void HAL_HASH_SwFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
00584 HAL_StatusTypeDef HAL_HASH_DMAFeed_ProcessSuspend(HASH_HandleTypeDef *hhash);
00585 uint32_t HAL_HASH_GetError(HASH_HandleTypeDef *hhash);
00586 
00587 /**
00588   * @}
00589   */
00590 
00591 /**
00592   * @}
00593   */
00594 
00595 /* Private functions -----------------------------------------------------------*/
00596 
00597 /** @addtogroup HASH_Private_Functions HASH Private Functions
00598   * @{
00599   */
00600 
00601 /* Private functions */
00602 HAL_StatusTypeDef HASH_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00603                              uint32_t Timeout, uint32_t Algorithm);
00604 HAL_StatusTypeDef HASH_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
00605 HAL_StatusTypeDef HASH_Accumulate_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
00606 HAL_StatusTypeDef HASH_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00607                                 uint32_t Algorithm);
00608 HAL_StatusTypeDef HASH_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
00609 HAL_StatusTypeDef HASH_Finish(HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout);
00610 HAL_StatusTypeDef HMAC_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00611                              uint32_t Timeout, uint32_t Algorithm);
00612 HAL_StatusTypeDef HMAC_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer,
00613                                 uint32_t Algorithm);
00614 HAL_StatusTypeDef HMAC_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint32_t Algorithm);
00615 
00616 /**
00617   * @}
00618   */
00619 
00620 /**
00621   * @}
00622   */
00623 #endif /*  HASH*/
00624 /**
00625   * @}
00626   */
00627 
00628 
00629 #ifdef __cplusplus
00630 }
00631 #endif
00632 
00633 
00634 #endif /* STM32F4xx_HAL_HASH_H */
00635 
00636 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/