meh
Fork of mbed by
TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h@90:cb3d968589d8, 2014-10-28 (annotated)
- Committer:
- Kojto
- Date:
- Tue Oct 28 16:40:41 2014 +0000
- Revision:
- 90:cb3d968589d8
- Parent:
- 85:024bf7f99721
- Child:
- 99:dbbf35b96557
Release 90 of the mbed library
Changes:
- Freescale KSDK update (v1.0)
- K22 - new target addition
- KL43Z - new target addition
- Nucleo F091RC - new target addition
- Nucleo L152RE - STM32Cube driver
- Nordic - Softdevice v7.1.0
- Nvic files - BSD License
- LPC824 - various HAL fixes
- Nucleo F411RE - CMSIS - IAR files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 77:869cf507173a | 1 | /** |
emilmont | 77:869cf507173a | 2 | ****************************************************************************** |
emilmont | 77:869cf507173a | 3 | * @file stm32f4xx_hal_hash.h |
emilmont | 77:869cf507173a | 4 | * @author MCD Application Team |
Kojto | 90:cb3d968589d8 | 5 | * @version V1.1.0 |
Kojto | 90:cb3d968589d8 | 6 | * @date 19-June-2014 |
emilmont | 77:869cf507173a | 7 | * @brief Header file of HASH HAL module. |
emilmont | 77:869cf507173a | 8 | ****************************************************************************** |
emilmont | 77:869cf507173a | 9 | * @attention |
emilmont | 77:869cf507173a | 10 | * |
emilmont | 77:869cf507173a | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
emilmont | 77:869cf507173a | 12 | * |
emilmont | 77:869cf507173a | 13 | * Redistribution and use in source and binary forms, with or without modification, |
emilmont | 77:869cf507173a | 14 | * are permitted provided that the following conditions are met: |
emilmont | 77:869cf507173a | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
emilmont | 77:869cf507173a | 16 | * this list of conditions and the following disclaimer. |
emilmont | 77:869cf507173a | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
emilmont | 77:869cf507173a | 18 | * this list of conditions and the following disclaimer in the documentation |
emilmont | 77:869cf507173a | 19 | * and/or other materials provided with the distribution. |
emilmont | 77:869cf507173a | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
emilmont | 77:869cf507173a | 21 | * may be used to endorse or promote products derived from this software |
emilmont | 77:869cf507173a | 22 | * without specific prior written permission. |
emilmont | 77:869cf507173a | 23 | * |
emilmont | 77:869cf507173a | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
emilmont | 77:869cf507173a | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
emilmont | 77:869cf507173a | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
emilmont | 77:869cf507173a | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
emilmont | 77:869cf507173a | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
emilmont | 77:869cf507173a | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
emilmont | 77:869cf507173a | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emilmont | 77:869cf507173a | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
emilmont | 77:869cf507173a | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
emilmont | 77:869cf507173a | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
emilmont | 77:869cf507173a | 34 | * |
emilmont | 77:869cf507173a | 35 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 36 | */ |
emilmont | 77:869cf507173a | 37 | |
emilmont | 77:869cf507173a | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
emilmont | 77:869cf507173a | 39 | #ifndef __STM32F4xx_HAL_HASH_H |
emilmont | 77:869cf507173a | 40 | #define __STM32F4xx_HAL_HASH_H |
emilmont | 77:869cf507173a | 41 | |
emilmont | 77:869cf507173a | 42 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 43 | extern "C" { |
emilmont | 77:869cf507173a | 44 | #endif |
emilmont | 77:869cf507173a | 45 | |
emilmont | 77:869cf507173a | 46 | #if defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F437xx) || defined(STM32F439xx) |
emilmont | 77:869cf507173a | 47 | |
emilmont | 77:869cf507173a | 48 | /* Includes ------------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 49 | #include "stm32f4xx_hal_def.h" |
emilmont | 77:869cf507173a | 50 | |
emilmont | 77:869cf507173a | 51 | /** @addtogroup STM32F4xx_HAL_Driver |
emilmont | 77:869cf507173a | 52 | * @{ |
emilmont | 77:869cf507173a | 53 | */ |
emilmont | 77:869cf507173a | 54 | |
emilmont | 77:869cf507173a | 55 | /** @addtogroup HASH |
emilmont | 77:869cf507173a | 56 | * @{ |
emilmont | 77:869cf507173a | 57 | */ |
emilmont | 77:869cf507173a | 58 | |
bogdanm | 85:024bf7f99721 | 59 | /* Exported types ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 60 | |
emilmont | 77:869cf507173a | 61 | /** |
bogdanm | 85:024bf7f99721 | 62 | * @brief HASH Configuration Structure definition |
emilmont | 77:869cf507173a | 63 | */ |
emilmont | 77:869cf507173a | 64 | typedef struct |
bogdanm | 85:024bf7f99721 | 65 | { |
emilmont | 77:869cf507173a | 66 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
emilmont | 77:869cf507173a | 67 | This parameter can be a value of @ref HASH_Data_Type */ |
bogdanm | 85:024bf7f99721 | 68 | |
emilmont | 77:869cf507173a | 69 | uint32_t KeySize; /*!< The key size is used only in HMAC operation */ |
bogdanm | 85:024bf7f99721 | 70 | |
emilmont | 77:869cf507173a | 71 | uint8_t* pKey; /*!< The key is used only in HMAC operation */ |
emilmont | 77:869cf507173a | 72 | }HASH_InitTypeDef; |
emilmont | 77:869cf507173a | 73 | |
emilmont | 77:869cf507173a | 74 | /** |
bogdanm | 85:024bf7f99721 | 75 | * @brief HAL State structures definition |
emilmont | 77:869cf507173a | 76 | */ |
emilmont | 77:869cf507173a | 77 | typedef enum |
emilmont | 77:869cf507173a | 78 | { |
emilmont | 77:869cf507173a | 79 | HAL_HASH_STATE_RESET = 0x00, /*!< HASH not yet initialized or disabled */ |
bogdanm | 85:024bf7f99721 | 80 | HAL_HASH_STATE_READY = 0x01, /*!< HASH initialized and ready for use */ |
bogdanm | 85:024bf7f99721 | 81 | HAL_HASH_STATE_BUSY = 0x02, /*!< HASH internal process is ongoing */ |
emilmont | 77:869cf507173a | 82 | HAL_HASH_STATE_TIMEOUT = 0x03, /*!< HASH timeout state */ |
emilmont | 77:869cf507173a | 83 | HAL_HASH_STATE_ERROR = 0x04 /*!< HASH error state */ |
emilmont | 77:869cf507173a | 84 | }HAL_HASH_STATETypeDef; |
emilmont | 77:869cf507173a | 85 | |
emilmont | 77:869cf507173a | 86 | /** |
bogdanm | 85:024bf7f99721 | 87 | * @brief HAL phase structures definition |
bogdanm | 85:024bf7f99721 | 88 | */ |
emilmont | 77:869cf507173a | 89 | typedef enum |
emilmont | 77:869cf507173a | 90 | { |
emilmont | 77:869cf507173a | 91 | HAL_HASH_PHASE_READY = 0x01, /*!< HASH peripheral is ready for initialization */ |
emilmont | 77:869cf507173a | 92 | HAL_HASH_PHASE_PROCESS = 0x02, /*!< HASH peripheral is in processing phase */ |
emilmont | 77:869cf507173a | 93 | }HAL_HASHPhaseTypeDef; |
emilmont | 77:869cf507173a | 94 | |
emilmont | 77:869cf507173a | 95 | /** |
bogdanm | 85:024bf7f99721 | 96 | * @brief HASH Handle Structure definition |
bogdanm | 85:024bf7f99721 | 97 | */ |
emilmont | 77:869cf507173a | 98 | typedef struct |
bogdanm | 85:024bf7f99721 | 99 | { |
emilmont | 77:869cf507173a | 100 | HASH_InitTypeDef Init; /*!< HASH required parameters */ |
bogdanm | 85:024bf7f99721 | 101 | |
emilmont | 77:869cf507173a | 102 | uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */ |
bogdanm | 85:024bf7f99721 | 103 | |
emilmont | 77:869cf507173a | 104 | uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */ |
bogdanm | 85:024bf7f99721 | 105 | |
emilmont | 77:869cf507173a | 106 | __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */ |
bogdanm | 85:024bf7f99721 | 107 | |
emilmont | 77:869cf507173a | 108 | __IO uint32_t HashInCount; /*!< Counter of inputed data */ |
bogdanm | 85:024bf7f99721 | 109 | |
emilmont | 77:869cf507173a | 110 | __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */ |
bogdanm | 85:024bf7f99721 | 111 | |
emilmont | 77:869cf507173a | 112 | HAL_StatusTypeDef Status; /*!< HASH peripheral status */ |
bogdanm | 85:024bf7f99721 | 113 | |
emilmont | 77:869cf507173a | 114 | HAL_HASHPhaseTypeDef Phase; /*!< HASH peripheral phase */ |
bogdanm | 85:024bf7f99721 | 115 | |
emilmont | 77:869cf507173a | 116 | DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */ |
bogdanm | 85:024bf7f99721 | 117 | |
emilmont | 77:869cf507173a | 118 | HAL_LockTypeDef Lock; /*!< HASH locking object */ |
bogdanm | 85:024bf7f99721 | 119 | |
emilmont | 77:869cf507173a | 120 | __IO HAL_HASH_STATETypeDef State; /*!< HASH peripheral state */ |
emilmont | 77:869cf507173a | 121 | } HASH_HandleTypeDef; |
emilmont | 77:869cf507173a | 122 | |
emilmont | 77:869cf507173a | 123 | /* Exported constants --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 124 | |
emilmont | 77:869cf507173a | 125 | /** @defgroup HASH_Exported_Constants |
emilmont | 77:869cf507173a | 126 | * @{ |
emilmont | 77:869cf507173a | 127 | */ |
emilmont | 77:869cf507173a | 128 | |
bogdanm | 85:024bf7f99721 | 129 | /** @defgroup HASH_Algo_Selection |
emilmont | 77:869cf507173a | 130 | * @{ |
bogdanm | 85:024bf7f99721 | 131 | */ |
emilmont | 77:869cf507173a | 132 | #define HASH_AlgoSelection_SHA1 ((uint32_t)0x0000) /*!< HASH function is SHA1 */ |
emilmont | 77:869cf507173a | 133 | #define HASH_AlgoSelection_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */ |
emilmont | 77:869cf507173a | 134 | #define HASH_AlgoSelection_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */ |
emilmont | 77:869cf507173a | 135 | #define HASH_AlgoSelection_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */ |
emilmont | 77:869cf507173a | 136 | |
emilmont | 77:869cf507173a | 137 | #define IS_HASH_ALGOSELECTION(ALGOSELECTION) (((ALGOSELECTION) == HASH_AlgoSelection_SHA1) || \ |
emilmont | 77:869cf507173a | 138 | ((ALGOSELECTION) == HASH_AlgoSelection_SHA224) || \ |
emilmont | 77:869cf507173a | 139 | ((ALGOSELECTION) == HASH_AlgoSelection_SHA256) || \ |
emilmont | 77:869cf507173a | 140 | ((ALGOSELECTION) == HASH_AlgoSelection_MD5)) |
emilmont | 77:869cf507173a | 141 | /** |
emilmont | 77:869cf507173a | 142 | * @} |
emilmont | 77:869cf507173a | 143 | */ |
emilmont | 77:869cf507173a | 144 | |
bogdanm | 85:024bf7f99721 | 145 | /** @defgroup HASH_Algorithm_Mode |
emilmont | 77:869cf507173a | 146 | * @{ |
emilmont | 77:869cf507173a | 147 | */ |
emilmont | 77:869cf507173a | 148 | #define HASH_AlgoMode_HASH ((uint32_t)0x00000000) /*!< Algorithm is HASH */ |
emilmont | 77:869cf507173a | 149 | #define HASH_AlgoMode_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */ |
emilmont | 77:869cf507173a | 150 | |
emilmont | 77:869cf507173a | 151 | #define IS_HASH_ALGOMODE(ALGOMODE) (((ALGOMODE) == HASH_AlgoMode_HASH) || \ |
emilmont | 77:869cf507173a | 152 | ((ALGOMODE) == HASH_AlgoMode_HMAC)) |
emilmont | 77:869cf507173a | 153 | /** |
emilmont | 77:869cf507173a | 154 | * @} |
emilmont | 77:869cf507173a | 155 | */ |
emilmont | 77:869cf507173a | 156 | |
bogdanm | 85:024bf7f99721 | 157 | /** @defgroup HASH_Data_Type |
emilmont | 77:869cf507173a | 158 | * @{ |
bogdanm | 85:024bf7f99721 | 159 | */ |
emilmont | 77:869cf507173a | 160 | #define HASH_DATATYPE_32B ((uint32_t)0x0000) /*!< 32-bit data. No swapping */ |
emilmont | 77:869cf507173a | 161 | #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */ |
emilmont | 77:869cf507173a | 162 | #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */ |
emilmont | 77:869cf507173a | 163 | #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */ |
emilmont | 77:869cf507173a | 164 | |
emilmont | 77:869cf507173a | 165 | #define IS_HASH_DATATYPE(DATATYPE) (((DATATYPE) == HASH_DATATYPE_32B)|| \ |
emilmont | 77:869cf507173a | 166 | ((DATATYPE) == HASH_DATATYPE_16B)|| \ |
emilmont | 77:869cf507173a | 167 | ((DATATYPE) == HASH_DATATYPE_8B) || \ |
emilmont | 77:869cf507173a | 168 | ((DATATYPE) == HASH_DATATYPE_1B)) |
emilmont | 77:869cf507173a | 169 | /** |
emilmont | 77:869cf507173a | 170 | * @} |
emilmont | 77:869cf507173a | 171 | */ |
emilmont | 77:869cf507173a | 172 | |
bogdanm | 85:024bf7f99721 | 173 | /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode |
emilmont | 77:869cf507173a | 174 | * @{ |
emilmont | 77:869cf507173a | 175 | */ |
emilmont | 77:869cf507173a | 176 | #define HASH_HMACKeyType_ShortKey ((uint32_t)0x00000000) /*!< HMAC Key is <= 64 bytes */ |
emilmont | 77:869cf507173a | 177 | #define HASH_HMACKeyType_LongKey HASH_CR_LKEY /*!< HMAC Key is > 64 bytes */ |
emilmont | 77:869cf507173a | 178 | |
emilmont | 77:869cf507173a | 179 | #define IS_HASH_HMAC_KEYTYPE(KEYTYPE) (((KEYTYPE) == HASH_HMACKeyType_ShortKey) || \ |
emilmont | 77:869cf507173a | 180 | ((KEYTYPE) == HASH_HMACKeyType_LongKey)) |
emilmont | 77:869cf507173a | 181 | /** |
emilmont | 77:869cf507173a | 182 | * @} |
emilmont | 77:869cf507173a | 183 | */ |
emilmont | 77:869cf507173a | 184 | |
bogdanm | 85:024bf7f99721 | 185 | /** @defgroup HASH_flags_definition |
emilmont | 77:869cf507173a | 186 | * @{ |
bogdanm | 85:024bf7f99721 | 187 | */ |
emilmont | 77:869cf507173a | 188 | #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : A new block can be entered into the input buffer */ |
emilmont | 77:869cf507173a | 189 | #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */ |
emilmont | 77:869cf507173a | 190 | #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */ |
emilmont | 77:869cf507173a | 191 | #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy : processing a block of data */ |
emilmont | 77:869cf507173a | 192 | #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */ |
emilmont | 77:869cf507173a | 193 | /** |
emilmont | 77:869cf507173a | 194 | * @} |
bogdanm | 85:024bf7f99721 | 195 | */ |
emilmont | 77:869cf507173a | 196 | |
bogdanm | 85:024bf7f99721 | 197 | /** @defgroup HASH_interrupts_definition |
emilmont | 77:869cf507173a | 198 | * @{ |
emilmont | 77:869cf507173a | 199 | */ |
emilmont | 77:869cf507173a | 200 | #define HASH_IT_DINI HASH_IMR_DINIM /*!< A new block can be entered into the input buffer (DIN) */ |
emilmont | 77:869cf507173a | 201 | #define HASH_IT_DCI HASH_IMR_DCIM /*!< Digest calculation complete */ |
emilmont | 77:869cf507173a | 202 | /** |
emilmont | 77:869cf507173a | 203 | * @} |
emilmont | 77:869cf507173a | 204 | */ |
emilmont | 77:869cf507173a | 205 | |
emilmont | 77:869cf507173a | 206 | /** |
emilmont | 77:869cf507173a | 207 | * @} |
emilmont | 77:869cf507173a | 208 | */ |
emilmont | 77:869cf507173a | 209 | |
emilmont | 77:869cf507173a | 210 | /* Exported macro ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 211 | |
bogdanm | 85:024bf7f99721 | 212 | /** @brief Reset HASH handle state |
bogdanm | 85:024bf7f99721 | 213 | * @param __HANDLE__: specifies the HASH handle. |
bogdanm | 85:024bf7f99721 | 214 | * @retval None |
bogdanm | 85:024bf7f99721 | 215 | */ |
bogdanm | 85:024bf7f99721 | 216 | #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET) |
bogdanm | 85:024bf7f99721 | 217 | |
emilmont | 77:869cf507173a | 218 | /** @brief Check whether the specified HASH flag is set or not. |
emilmont | 77:869cf507173a | 219 | * @param __FLAG__: specifies the flag to check. |
emilmont | 77:869cf507173a | 220 | * This parameter can be one of the following values: |
emilmont | 77:869cf507173a | 221 | * @arg HASH_FLAG_DINIS: A new block can be entered into the input buffer. |
emilmont | 77:869cf507173a | 222 | * @arg HASH_FLAG_DCIS: Digest calculation complete |
emilmont | 77:869cf507173a | 223 | * @arg HASH_FLAG_DMAS: DMA interface is enabled (DMAE=1) or a transfer is ongoing |
emilmont | 77:869cf507173a | 224 | * @arg HASH_FLAG_BUSY: The hash core is Busy : processing a block of data |
emilmont | 77:869cf507173a | 225 | * @arg HASH_FLAG_DINNE: DIN not empty : The input buffer contains at least one word of data |
emilmont | 77:869cf507173a | 226 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
emilmont | 77:869cf507173a | 227 | */ |
emilmont | 77:869cf507173a | 228 | #define __HAL_HASH_GET_FLAG(__FLAG__) ((HASH->SR & (__FLAG__)) == (__FLAG__)) |
emilmont | 77:869cf507173a | 229 | |
emilmont | 77:869cf507173a | 230 | /** |
emilmont | 77:869cf507173a | 231 | * @brief Macros for HMAC finish. |
emilmont | 77:869cf507173a | 232 | * @param None |
emilmont | 77:869cf507173a | 233 | * @retval None |
emilmont | 77:869cf507173a | 234 | */ |
emilmont | 77:869cf507173a | 235 | #define HAL_HMAC_MD5_Finish HAL_HASH_MD5_Finish |
emilmont | 77:869cf507173a | 236 | #define HAL_HMAC_SHA1_Finish HAL_HASH_SHA1_Finish |
emilmont | 77:869cf507173a | 237 | #define HAL_HMAC_SHA224_Finish HAL_HASH_SHA224_Finish |
emilmont | 77:869cf507173a | 238 | #define HAL_HMAC_SHA256_Finish HAL_HASH_SHA256_Finish |
emilmont | 77:869cf507173a | 239 | |
emilmont | 77:869cf507173a | 240 | /** |
emilmont | 77:869cf507173a | 241 | * @brief Enable the multiple DMA mode. |
emilmont | 77:869cf507173a | 242 | * This feature is available only in STM32F429x and STM32F439x devices. |
emilmont | 77:869cf507173a | 243 | * @param None |
emilmont | 77:869cf507173a | 244 | * @retval None |
emilmont | 77:869cf507173a | 245 | */ |
emilmont | 77:869cf507173a | 246 | #define __HAL_HASH_SET_MDMAT() HASH->CR |= HASH_CR_MDMAT |
emilmont | 77:869cf507173a | 247 | |
emilmont | 77:869cf507173a | 248 | /** |
emilmont | 77:869cf507173a | 249 | * @brief Disable the multiple DMA mode. |
emilmont | 77:869cf507173a | 250 | * @param None |
emilmont | 77:869cf507173a | 251 | * @retval None |
emilmont | 77:869cf507173a | 252 | */ |
emilmont | 77:869cf507173a | 253 | #define __HAL_HASH_RESET_MDMAT() HASH->CR &= (uint32_t)(~HASH_CR_MDMAT) |
emilmont | 77:869cf507173a | 254 | |
emilmont | 77:869cf507173a | 255 | /** |
emilmont | 77:869cf507173a | 256 | * @brief Start the digest computation |
emilmont | 77:869cf507173a | 257 | * @param None |
emilmont | 77:869cf507173a | 258 | * @retval None |
emilmont | 77:869cf507173a | 259 | */ |
emilmont | 77:869cf507173a | 260 | #define __HAL_HASH_START_DIGEST() HASH->STR |= HASH_STR_DCAL |
emilmont | 77:869cf507173a | 261 | |
emilmont | 77:869cf507173a | 262 | /** |
emilmont | 77:869cf507173a | 263 | * @brief Set the number of valid bits in last word written in Data register |
emilmont | 77:869cf507173a | 264 | * @param SIZE: size in byte of last data written in Data register. |
emilmont | 77:869cf507173a | 265 | * @retval None |
emilmont | 77:869cf507173a | 266 | */ |
emilmont | 77:869cf507173a | 267 | #define __HAL_HASH_SET_NBVALIDBITS(SIZE) do{HASH->STR &= ~(HASH_STR_NBW);\ |
emilmont | 77:869cf507173a | 268 | HASH->STR |= 8 * ((SIZE) % 4);\ |
emilmont | 77:869cf507173a | 269 | }while(0) |
emilmont | 77:869cf507173a | 270 | |
emilmont | 77:869cf507173a | 271 | /* Include HASH HAL Extension module */ |
emilmont | 77:869cf507173a | 272 | #include "stm32f4xx_hal_hash_ex.h" |
emilmont | 77:869cf507173a | 273 | |
emilmont | 77:869cf507173a | 274 | /* Exported functions --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 275 | |
emilmont | 77:869cf507173a | 276 | /* Initialization and de-initialization functions **********************************/ |
emilmont | 77:869cf507173a | 277 | HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 278 | HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 279 | |
emilmont | 77:869cf507173a | 280 | /* HASH processing using polling *********************************************/ |
emilmont | 77:869cf507173a | 281 | HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 282 | HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 283 | HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 284 | HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 285 | |
emilmont | 77:869cf507173a | 286 | /* HASH-MAC processing using polling *****************************************/ |
emilmont | 77:869cf507173a | 287 | HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 288 | HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 289 | |
emilmont | 77:869cf507173a | 290 | /* HASH processing using interrupt *******************************************/ |
emilmont | 77:869cf507173a | 291 | HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); |
emilmont | 77:869cf507173a | 292 | HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); |
emilmont | 77:869cf507173a | 293 | |
emilmont | 77:869cf507173a | 294 | /* HASH processing using DMA *************************************************/ |
emilmont | 77:869cf507173a | 295 | HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 296 | HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 297 | HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 298 | HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 299 | |
emilmont | 77:869cf507173a | 300 | /* HASH-HMAC processing using DMA ********************************************/ |
emilmont | 77:869cf507173a | 301 | HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 302 | HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 303 | |
emilmont | 77:869cf507173a | 304 | /* Processing functions ******************************************************/ |
emilmont | 77:869cf507173a | 305 | void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 306 | |
emilmont | 77:869cf507173a | 307 | /* Peripheral State functions ************************************************/ |
emilmont | 77:869cf507173a | 308 | HAL_HASH_STATETypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 309 | void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 310 | void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 311 | void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 312 | void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 313 | void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 314 | |
emilmont | 77:869cf507173a | 315 | #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ |
emilmont | 77:869cf507173a | 316 | /** |
emilmont | 77:869cf507173a | 317 | * @} |
emilmont | 77:869cf507173a | 318 | */ |
emilmont | 77:869cf507173a | 319 | |
emilmont | 77:869cf507173a | 320 | /** |
emilmont | 77:869cf507173a | 321 | * @} |
emilmont | 77:869cf507173a | 322 | */ |
emilmont | 77:869cf507173a | 323 | |
emilmont | 77:869cf507173a | 324 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 325 | } |
emilmont | 77:869cf507173a | 326 | #endif |
emilmont | 77:869cf507173a | 327 | |
emilmont | 77:869cf507173a | 328 | |
emilmont | 77:869cf507173a | 329 | #endif /* __STM32F4xx_HAL_HASH_H */ |
emilmont | 77:869cf507173a | 330 | |
emilmont | 77:869cf507173a | 331 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |