meh
Fork of mbed by
TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h@81:7d30d6019079, 2014-03-19 (annotated)
- Committer:
- bogdanm
- Date:
- Wed Mar 19 18:28:32 2014 +0000
- Revision:
- 81:7d30d6019079
- Parent:
- 77:869cf507173a
- Child:
- 85:024bf7f99721
Release 81 of the mbed library
Main changes:
- Updates and fixes for many targets
- LPC1768: serial interface code fixes
- nRF51822 targets now output a .hex file
- More exporters
- More flexible GPIO API
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 |
bogdanm | 81:7d30d6019079 | 5 | * @version V1.0.0 |
bogdanm | 81:7d30d6019079 | 6 | * @date 18-February-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 | ****************************************************************************** |
emilmont | 77:869cf507173a | 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 | |
emilmont | 77:869cf507173a | 59 | /* Exported types ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 60 | |
emilmont | 77:869cf507173a | 61 | /** |
emilmont | 77:869cf507173a | 62 | * @brief HASH Configuration Structure definition |
emilmont | 77:869cf507173a | 63 | */ |
emilmont | 77:869cf507173a | 64 | typedef struct |
emilmont | 77:869cf507173a | 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 */ |
emilmont | 77:869cf507173a | 68 | |
emilmont | 77:869cf507173a | 69 | uint32_t KeySize; /*!< The key size is used only in HMAC operation */ |
emilmont | 77:869cf507173a | 70 | |
emilmont | 77:869cf507173a | 71 | uint8_t* pKey; /*!< The key is used only in HMAC operation */ |
emilmont | 77:869cf507173a | 72 | |
emilmont | 77:869cf507173a | 73 | }HASH_InitTypeDef; |
emilmont | 77:869cf507173a | 74 | |
emilmont | 77:869cf507173a | 75 | /** |
emilmont | 77:869cf507173a | 76 | * @brief HAL State structures definition |
emilmont | 77:869cf507173a | 77 | */ |
emilmont | 77:869cf507173a | 78 | typedef enum |
emilmont | 77:869cf507173a | 79 | { |
emilmont | 77:869cf507173a | 80 | HAL_HASH_STATE_RESET = 0x00, /*!< HASH not yet initialized or disabled */ |
emilmont | 77:869cf507173a | 81 | HAL_HASH_STATE_READY = 0x01, /*!< HASH initialized and ready for use */ |
emilmont | 77:869cf507173a | 82 | HAL_HASH_STATE_BUSY = 0x02, /*!< HASH internal process is ongoing */ |
emilmont | 77:869cf507173a | 83 | HAL_HASH_STATE_TIMEOUT = 0x03, /*!< HASH timeout state */ |
emilmont | 77:869cf507173a | 84 | HAL_HASH_STATE_ERROR = 0x04 /*!< HASH error state */ |
emilmont | 77:869cf507173a | 85 | |
emilmont | 77:869cf507173a | 86 | }HAL_HASH_STATETypeDef; |
emilmont | 77:869cf507173a | 87 | |
emilmont | 77:869cf507173a | 88 | /** |
emilmont | 77:869cf507173a | 89 | * @brief HAL phase structures definition |
emilmont | 77:869cf507173a | 90 | */ |
emilmont | 77:869cf507173a | 91 | typedef enum |
emilmont | 77:869cf507173a | 92 | { |
emilmont | 77:869cf507173a | 93 | HAL_HASH_PHASE_READY = 0x01, /*!< HASH peripheral is ready for initialization */ |
emilmont | 77:869cf507173a | 94 | HAL_HASH_PHASE_PROCESS = 0x02, /*!< HASH peripheral is in processing phase */ |
emilmont | 77:869cf507173a | 95 | |
emilmont | 77:869cf507173a | 96 | }HAL_HASHPhaseTypeDef; |
emilmont | 77:869cf507173a | 97 | |
emilmont | 77:869cf507173a | 98 | /** |
emilmont | 77:869cf507173a | 99 | * @brief HASH Handle Structure definition |
emilmont | 77:869cf507173a | 100 | */ |
emilmont | 77:869cf507173a | 101 | typedef struct |
emilmont | 77:869cf507173a | 102 | { |
emilmont | 77:869cf507173a | 103 | HASH_InitTypeDef Init; /*!< HASH required parameters */ |
emilmont | 77:869cf507173a | 104 | |
emilmont | 77:869cf507173a | 105 | uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */ |
emilmont | 77:869cf507173a | 106 | |
emilmont | 77:869cf507173a | 107 | uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */ |
emilmont | 77:869cf507173a | 108 | |
emilmont | 77:869cf507173a | 109 | __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */ |
emilmont | 77:869cf507173a | 110 | |
emilmont | 77:869cf507173a | 111 | __IO uint32_t HashInCount; /*!< Counter of inputed data */ |
emilmont | 77:869cf507173a | 112 | |
emilmont | 77:869cf507173a | 113 | __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */ |
emilmont | 77:869cf507173a | 114 | |
emilmont | 77:869cf507173a | 115 | HAL_StatusTypeDef Status; /*!< HASH peripheral status */ |
emilmont | 77:869cf507173a | 116 | |
emilmont | 77:869cf507173a | 117 | HAL_HASHPhaseTypeDef Phase; /*!< HASH peripheral phase */ |
emilmont | 77:869cf507173a | 118 | |
emilmont | 77:869cf507173a | 119 | DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */ |
emilmont | 77:869cf507173a | 120 | |
emilmont | 77:869cf507173a | 121 | HAL_LockTypeDef Lock; /*!< HASH locking object */ |
emilmont | 77:869cf507173a | 122 | |
emilmont | 77:869cf507173a | 123 | __IO HAL_HASH_STATETypeDef State; /*!< HASH peripheral state */ |
emilmont | 77:869cf507173a | 124 | |
emilmont | 77:869cf507173a | 125 | } HASH_HandleTypeDef; |
emilmont | 77:869cf507173a | 126 | |
emilmont | 77:869cf507173a | 127 | /* Exported constants --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 128 | |
emilmont | 77:869cf507173a | 129 | /** @defgroup HASH_Exported_Constants |
emilmont | 77:869cf507173a | 130 | * @{ |
emilmont | 77:869cf507173a | 131 | */ |
emilmont | 77:869cf507173a | 132 | |
emilmont | 77:869cf507173a | 133 | /** @defgroup HASH_Algo_Selection |
emilmont | 77:869cf507173a | 134 | * @{ |
emilmont | 77:869cf507173a | 135 | */ |
emilmont | 77:869cf507173a | 136 | #define HASH_AlgoSelection_SHA1 ((uint32_t)0x0000) /*!< HASH function is SHA1 */ |
emilmont | 77:869cf507173a | 137 | #define HASH_AlgoSelection_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */ |
emilmont | 77:869cf507173a | 138 | #define HASH_AlgoSelection_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */ |
emilmont | 77:869cf507173a | 139 | #define HASH_AlgoSelection_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */ |
emilmont | 77:869cf507173a | 140 | |
emilmont | 77:869cf507173a | 141 | #define IS_HASH_ALGOSELECTION(ALGOSELECTION) (((ALGOSELECTION) == HASH_AlgoSelection_SHA1) || \ |
emilmont | 77:869cf507173a | 142 | ((ALGOSELECTION) == HASH_AlgoSelection_SHA224) || \ |
emilmont | 77:869cf507173a | 143 | ((ALGOSELECTION) == HASH_AlgoSelection_SHA256) || \ |
emilmont | 77:869cf507173a | 144 | ((ALGOSELECTION) == HASH_AlgoSelection_MD5)) |
emilmont | 77:869cf507173a | 145 | /** |
emilmont | 77:869cf507173a | 146 | * @} |
emilmont | 77:869cf507173a | 147 | */ |
emilmont | 77:869cf507173a | 148 | |
emilmont | 77:869cf507173a | 149 | /** @defgroup HASH_Algorithm_Mode |
emilmont | 77:869cf507173a | 150 | * @{ |
emilmont | 77:869cf507173a | 151 | */ |
emilmont | 77:869cf507173a | 152 | #define HASH_AlgoMode_HASH ((uint32_t)0x00000000) /*!< Algorithm is HASH */ |
emilmont | 77:869cf507173a | 153 | #define HASH_AlgoMode_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */ |
emilmont | 77:869cf507173a | 154 | |
emilmont | 77:869cf507173a | 155 | #define IS_HASH_ALGOMODE(ALGOMODE) (((ALGOMODE) == HASH_AlgoMode_HASH) || \ |
emilmont | 77:869cf507173a | 156 | ((ALGOMODE) == HASH_AlgoMode_HMAC)) |
emilmont | 77:869cf507173a | 157 | /** |
emilmont | 77:869cf507173a | 158 | * @} |
emilmont | 77:869cf507173a | 159 | */ |
emilmont | 77:869cf507173a | 160 | |
emilmont | 77:869cf507173a | 161 | /** @defgroup HASH_Data_Type |
emilmont | 77:869cf507173a | 162 | * @{ |
emilmont | 77:869cf507173a | 163 | */ |
emilmont | 77:869cf507173a | 164 | #define HASH_DATATYPE_32B ((uint32_t)0x0000) /*!< 32-bit data. No swapping */ |
emilmont | 77:869cf507173a | 165 | #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */ |
emilmont | 77:869cf507173a | 166 | #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */ |
emilmont | 77:869cf507173a | 167 | #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */ |
emilmont | 77:869cf507173a | 168 | |
emilmont | 77:869cf507173a | 169 | #define IS_HASH_DATATYPE(DATATYPE) (((DATATYPE) == HASH_DATATYPE_32B)|| \ |
emilmont | 77:869cf507173a | 170 | ((DATATYPE) == HASH_DATATYPE_16B)|| \ |
emilmont | 77:869cf507173a | 171 | ((DATATYPE) == HASH_DATATYPE_8B) || \ |
emilmont | 77:869cf507173a | 172 | ((DATATYPE) == HASH_DATATYPE_1B)) |
emilmont | 77:869cf507173a | 173 | /** |
emilmont | 77:869cf507173a | 174 | * @} |
emilmont | 77:869cf507173a | 175 | */ |
emilmont | 77:869cf507173a | 176 | |
emilmont | 77:869cf507173a | 177 | /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode |
emilmont | 77:869cf507173a | 178 | * @{ |
emilmont | 77:869cf507173a | 179 | */ |
emilmont | 77:869cf507173a | 180 | #define HASH_HMACKeyType_ShortKey ((uint32_t)0x00000000) /*!< HMAC Key is <= 64 bytes */ |
emilmont | 77:869cf507173a | 181 | #define HASH_HMACKeyType_LongKey HASH_CR_LKEY /*!< HMAC Key is > 64 bytes */ |
emilmont | 77:869cf507173a | 182 | |
emilmont | 77:869cf507173a | 183 | #define IS_HASH_HMAC_KEYTYPE(KEYTYPE) (((KEYTYPE) == HASH_HMACKeyType_ShortKey) || \ |
emilmont | 77:869cf507173a | 184 | ((KEYTYPE) == HASH_HMACKeyType_LongKey)) |
emilmont | 77:869cf507173a | 185 | /** |
emilmont | 77:869cf507173a | 186 | * @} |
emilmont | 77:869cf507173a | 187 | */ |
emilmont | 77:869cf507173a | 188 | |
emilmont | 77:869cf507173a | 189 | /** @defgroup HASH_flags_definition |
emilmont | 77:869cf507173a | 190 | * @{ |
emilmont | 77:869cf507173a | 191 | */ |
emilmont | 77:869cf507173a | 192 | #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 | 193 | #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */ |
emilmont | 77:869cf507173a | 194 | #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */ |
emilmont | 77:869cf507173a | 195 | #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy : processing a block of data */ |
emilmont | 77:869cf507173a | 196 | #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */ |
emilmont | 77:869cf507173a | 197 | /** |
emilmont | 77:869cf507173a | 198 | * @} |
emilmont | 77:869cf507173a | 199 | */ |
emilmont | 77:869cf507173a | 200 | |
emilmont | 77:869cf507173a | 201 | /** @defgroup HASH_interrupts_definition |
emilmont | 77:869cf507173a | 202 | * @{ |
emilmont | 77:869cf507173a | 203 | */ |
emilmont | 77:869cf507173a | 204 | #define HASH_IT_DINI HASH_IMR_DINIM /*!< A new block can be entered into the input buffer (DIN) */ |
emilmont | 77:869cf507173a | 205 | #define HASH_IT_DCI HASH_IMR_DCIM /*!< Digest calculation complete */ |
emilmont | 77:869cf507173a | 206 | /** |
emilmont | 77:869cf507173a | 207 | * @} |
emilmont | 77:869cf507173a | 208 | */ |
emilmont | 77:869cf507173a | 209 | |
emilmont | 77:869cf507173a | 210 | /** |
emilmont | 77:869cf507173a | 211 | * @} |
emilmont | 77:869cf507173a | 212 | */ |
emilmont | 77:869cf507173a | 213 | |
emilmont | 77:869cf507173a | 214 | /* Exported macro ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 215 | |
emilmont | 77:869cf507173a | 216 | /** @brief Check whether the specified HASH flag is set or not. |
emilmont | 77:869cf507173a | 217 | * @param __FLAG__: specifies the flag to check. |
emilmont | 77:869cf507173a | 218 | * This parameter can be one of the following values: |
emilmont | 77:869cf507173a | 219 | * @arg HASH_FLAG_DINIS: A new block can be entered into the input buffer. |
emilmont | 77:869cf507173a | 220 | * @arg HASH_FLAG_DCIS: Digest calculation complete |
emilmont | 77:869cf507173a | 221 | * @arg HASH_FLAG_DMAS: DMA interface is enabled (DMAE=1) or a transfer is ongoing |
emilmont | 77:869cf507173a | 222 | * @arg HASH_FLAG_BUSY: The hash core is Busy : processing a block of data |
emilmont | 77:869cf507173a | 223 | * @arg HASH_FLAG_DINNE: DIN not empty : The input buffer contains at least one word of data |
emilmont | 77:869cf507173a | 224 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
emilmont | 77:869cf507173a | 225 | */ |
emilmont | 77:869cf507173a | 226 | #define __HAL_HASH_GET_FLAG(__FLAG__) ((HASH->SR & (__FLAG__)) == (__FLAG__)) |
emilmont | 77:869cf507173a | 227 | |
emilmont | 77:869cf507173a | 228 | /** |
emilmont | 77:869cf507173a | 229 | * @brief Macros for HMAC finish. |
emilmont | 77:869cf507173a | 230 | * @param None |
emilmont | 77:869cf507173a | 231 | * @retval None |
emilmont | 77:869cf507173a | 232 | */ |
emilmont | 77:869cf507173a | 233 | #define HAL_HMAC_MD5_Finish HAL_HASH_MD5_Finish |
emilmont | 77:869cf507173a | 234 | #define HAL_HMAC_SHA1_Finish HAL_HASH_SHA1_Finish |
emilmont | 77:869cf507173a | 235 | #define HAL_HMAC_SHA224_Finish HAL_HASH_SHA224_Finish |
emilmont | 77:869cf507173a | 236 | #define HAL_HMAC_SHA256_Finish HAL_HASH_SHA256_Finish |
emilmont | 77:869cf507173a | 237 | |
emilmont | 77:869cf507173a | 238 | /** |
emilmont | 77:869cf507173a | 239 | * @brief Enable the multiple DMA mode. |
emilmont | 77:869cf507173a | 240 | * This feature is available only in STM32F429x and STM32F439x devices. |
emilmont | 77:869cf507173a | 241 | * @param None |
emilmont | 77:869cf507173a | 242 | * @retval None |
emilmont | 77:869cf507173a | 243 | */ |
emilmont | 77:869cf507173a | 244 | #define __HAL_HASH_SET_MDMAT() HASH->CR |= HASH_CR_MDMAT |
emilmont | 77:869cf507173a | 245 | |
emilmont | 77:869cf507173a | 246 | /** |
emilmont | 77:869cf507173a | 247 | * @brief Disable the multiple DMA mode. |
emilmont | 77:869cf507173a | 248 | * @param None |
emilmont | 77:869cf507173a | 249 | * @retval None |
emilmont | 77:869cf507173a | 250 | */ |
emilmont | 77:869cf507173a | 251 | #define __HAL_HASH_RESET_MDMAT() HASH->CR &= (uint32_t)(~HASH_CR_MDMAT) |
emilmont | 77:869cf507173a | 252 | |
emilmont | 77:869cf507173a | 253 | /** |
emilmont | 77:869cf507173a | 254 | * @brief Start the digest computation |
emilmont | 77:869cf507173a | 255 | * @param None |
emilmont | 77:869cf507173a | 256 | * @retval None |
emilmont | 77:869cf507173a | 257 | */ |
emilmont | 77:869cf507173a | 258 | #define __HAL_HASH_START_DIGEST() HASH->STR |= HASH_STR_DCAL |
emilmont | 77:869cf507173a | 259 | |
emilmont | 77:869cf507173a | 260 | /** |
emilmont | 77:869cf507173a | 261 | * @brief Set the number of valid bits in last word written in Data register |
emilmont | 77:869cf507173a | 262 | * @param SIZE: size in byte of last data written in Data register. |
emilmont | 77:869cf507173a | 263 | * @retval None |
emilmont | 77:869cf507173a | 264 | */ |
emilmont | 77:869cf507173a | 265 | #define __HAL_HASH_SET_NBVALIDBITS(SIZE) do{HASH->STR &= ~(HASH_STR_NBW);\ |
emilmont | 77:869cf507173a | 266 | HASH->STR |= 8 * ((SIZE) % 4);\ |
emilmont | 77:869cf507173a | 267 | }while(0) |
emilmont | 77:869cf507173a | 268 | |
emilmont | 77:869cf507173a | 269 | /* Include HASH HAL Extension module */ |
emilmont | 77:869cf507173a | 270 | #include "stm32f4xx_hal_hash_ex.h" |
emilmont | 77:869cf507173a | 271 | |
emilmont | 77:869cf507173a | 272 | /* Exported functions --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 273 | |
emilmont | 77:869cf507173a | 274 | /* Initialization and de-initialization functions **********************************/ |
emilmont | 77:869cf507173a | 275 | HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 276 | HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 277 | |
emilmont | 77:869cf507173a | 278 | /* HASH processing using polling *********************************************/ |
emilmont | 77:869cf507173a | 279 | HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 280 | HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 281 | HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 282 | HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 283 | |
emilmont | 77:869cf507173a | 284 | /* HASH-MAC processing using polling *****************************************/ |
emilmont | 77:869cf507173a | 285 | HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 286 | HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 287 | |
emilmont | 77:869cf507173a | 288 | /* HASH processing using interrupt *******************************************/ |
emilmont | 77:869cf507173a | 289 | HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); |
emilmont | 77:869cf507173a | 290 | HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); |
emilmont | 77:869cf507173a | 291 | |
emilmont | 77:869cf507173a | 292 | /* HASH processing using DMA *************************************************/ |
emilmont | 77:869cf507173a | 293 | HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 294 | HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 295 | HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 296 | HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); |
emilmont | 77:869cf507173a | 297 | |
emilmont | 77:869cf507173a | 298 | /* HASH-HMAC processing using DMA ********************************************/ |
emilmont | 77:869cf507173a | 299 | HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 300 | HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); |
emilmont | 77:869cf507173a | 301 | |
emilmont | 77:869cf507173a | 302 | /* Processing functions ******************************************************/ |
emilmont | 77:869cf507173a | 303 | void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 304 | |
emilmont | 77:869cf507173a | 305 | /* Peripheral State functions ************************************************/ |
emilmont | 77:869cf507173a | 306 | HAL_HASH_STATETypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 307 | void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 308 | void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 309 | void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 310 | void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash); |
bogdanm | 81:7d30d6019079 | 311 | void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash); |
emilmont | 77:869cf507173a | 312 | |
emilmont | 77:869cf507173a | 313 | #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ |
emilmont | 77:869cf507173a | 314 | /** |
emilmont | 77:869cf507173a | 315 | * @} |
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 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 323 | } |
emilmont | 77:869cf507173a | 324 | #endif |
emilmont | 77:869cf507173a | 325 | |
emilmont | 77:869cf507173a | 326 | |
emilmont | 77:869cf507173a | 327 | #endif /* __STM32F4xx_HAL_HASH_H */ |
emilmont | 77:869cf507173a | 328 | |
emilmont | 77:869cf507173a | 329 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |