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