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