Merge pull request #10592 from iNavFlight/MrD_Update-parameter-description
[inav.git] / lib / main / STM32F7 / Drivers / STM32F7xx_HAL_Driver / Inc / stm32f7xx_hal_hash.h
blob0619c8d5e430e8a6f45cc8389666807daf2db536
1 /**
2 ******************************************************************************
3 * @file stm32f7xx_hal_hash.h
4 * @author MCD Application Team
5 * @version V1.2.2
6 * @date 14-April-2017
7 * @brief Header file of HASH HAL module.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F7xx_HAL_HASH_H
40 #define __STM32F7xx_HAL_HASH_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 #if defined (STM32F756xx) || defined (STM32F777xx) || defined (STM32F779xx)
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f7xx_hal_def.h"
50 /** @addtogroup STM32F7xx_HAL_Driver
51 * @{
54 /** @addtogroup HASH
55 * @brief HASH HAL module driver
56 * @{
57 */
59 /* Exported types ------------------------------------------------------------*/
60 /** @defgroup HASH_Exported_Types HASH Exported Types
61 * @{
64 /** @defgroup HASH_Exported_Types_Group1 HASH Configuration Structure definition
65 * @{
68 typedef struct
70 uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string.
71 This parameter can be a value of @ref HASH_Data_Type */
73 uint32_t KeySize; /*!< The key size is used only in HMAC operation */
75 uint8_t* pKey; /*!< The key is used only in HMAC operation */
76 }HASH_InitTypeDef;
78 /**
79 * @}
82 /** @defgroup HASH_Exported_Types_Group2 HASH State structures definition
83 * @{
86 typedef enum
88 HAL_HASH_STATE_RESET = 0x00U, /*!< HASH not yet initialized or disabled */
89 HAL_HASH_STATE_READY = 0x01U, /*!< HASH initialized and ready for use */
90 HAL_HASH_STATE_BUSY = 0x02U, /*!< HASH internal process is ongoing */
91 HAL_HASH_STATE_TIMEOUT = 0x03U, /*!< HASH timeout state */
92 HAL_HASH_STATE_ERROR = 0x04U /*!< HASH error state */
93 }HAL_HASH_StateTypeDef;
95 /**
96 * @}
99 /** @defgroup HASH_Exported_Types_Group3 HASH phase structures definition
100 * @{
103 typedef enum
105 HAL_HASH_PHASE_READY = 0x01U, /*!< HASH peripheral is ready for initialization */
106 HAL_HASH_PHASE_PROCESS = 0x02U, /*!< HASH peripheral is in processing phase */
107 }HAL_HASHPhaseTypeDef;
109 /**
110 * @}
113 /** @defgroup HASH_Exported_Types_Group4 HASH Handle structures definition
114 * @{
117 typedef struct
119 HASH_InitTypeDef Init; /*!< HASH required parameters */
121 uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */
123 uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */
125 __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */
127 __IO uint32_t HashInCount; /*!< Counter of inputed data */
129 __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */
131 HAL_StatusTypeDef Status; /*!< HASH peripheral status */
133 HAL_HASH_PhaseTypeDef Phase; /*!< HASH peripheral phase */
135 DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */
137 HAL_LockTypeDef Lock; /*!< HASH locking object */
139 __IO HAL_HASH_StateTypeDef State; /*!< HASH peripheral state */
140 } HASH_HandleTypeDef;
142 /**
143 * @}
148 * @}
151 /* Exported constants --------------------------------------------------------*/
152 /** @defgroup HASH_Exported_Constants HASH Exported Constants
153 * @{
156 /** @defgroup HASH_Exported_Constants_Group1 HASH Algorithm Selection
157 * @{
159 #define HASH_ALGOSELECTION_SHA1 ((uint32_t)0x0000U) /*!< HASH function is SHA1 */
160 #define HASH_ALGOSELECTION_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */
161 #define HASH_ALGOSELECTION_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */
162 #define HASH_ALGOSELECTION_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */
164 * @}
167 /** @defgroup HASH_Exported_Constants_Group2 HASH Algorithm Mode
168 * @{
170 #define HASH_ALGOMODE_HASH ((uint32_t)0x00000000U) /*!< Algorithm is HASH */
171 #define HASH_ALGOMODE_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */
173 * @}
176 /** @defgroup HASH_Data_Type HASH Data Type
177 * @{
179 #define HASH_DATATYPE_32B ((uint32_t)0x0000U) /*!< 32-bit data. No swapping */
180 #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */
181 #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */
182 #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */
184 * @}
187 /** @defgroup HASH_Exported_Constants_Group4 HASH HMAC Long key
188 * @brief HASH HMAC Long key used only for HMAC mode
189 * @{
191 #define HASH_HMAC_KEYTYPE_SHORTKEY ((uint32_t)0x00000000U) /*!< HMAC Key is <= 64 bytes */
192 #define HASH_HMAC_KEYTYPE_LONGKEY HASH_CR_LKEY /*!< HMAC Key is > 64 bytes */
194 * @}
197 /** @defgroup HASH_Exported_Constants_Group5 HASH Flags definition
198 * @{
200 #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : A new block can be entered into the input buffer */
201 #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */
202 #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */
203 #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy : processing a block of data */
204 #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */
206 * @}
209 /** @defgroup HASH_Exported_Constants_Group6 HASH Interrupts definition
210 * @{
212 #define HASH_IT_DINI HASH_IMR_DINIE /*!< A new block can be entered into the input buffer (DIN) */
213 #define HASH_IT_DCI HASH_IMR_DCIE /*!< Digest calculation complete */
215 * @}
219 * @}
222 /* Exported macro ------------------------------------------------------------*/
223 /** @defgroup HASH_Exported_Macros HASH Exported Macros
224 * @{
227 /** @brief Reset HASH handle state
228 * @param __HANDLE__: specifies the HASH handle.
229 * @retval None
231 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
233 /** @brief Check whether the specified HASH flag is set or not.
234 * @param __FLAG__: specifies the flag to check.
235 * This parameter can be one of the following values:
236 * @arg HASH_FLAG_DINIS: A new block can be entered into the input buffer.
237 * @arg HASH_FLAG_DCIS: Digest calculation complete
238 * @arg HASH_FLAG_DMAS: DMA interface is enabled (DMAE=1) or a transfer is ongoing
239 * @arg HASH_FLAG_BUSY: The hash core is Busy : processing a block of data
240 * @arg HASH_FLAG_DINNE: DIN not empty : The input buffer contains at least one word of data
241 * @retval The new state of __FLAG__ (TRUE or FALSE).
243 #define __HAL_HASH_GET_FLAG(__FLAG__) (((__FLAG__) > 8U) ? ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
244 ((HASH->SR & (__FLAG__)) == (__FLAG__)))
247 * @brief Enable the multiple DMA mode.
248 * This feature is available only in STM32F429x and STM32F439x devices.
249 * @retval None
251 #define __HAL_HASH_SET_MDMAT() HASH->CR |= HASH_CR_MDMAT
254 * @brief Disable the multiple DMA mode.
255 * @retval None
257 #define __HAL_HASH_RESET_MDMAT() HASH->CR &= (uint32_t)(~HASH_CR_MDMAT)
260 * @brief Start the digest computation
261 * @retval None
263 #define __HAL_HASH_START_DIGEST() HASH->STR |= HASH_STR_DCAL
266 * @brief Set the number of valid bits in last word written in Data register
267 * @param SIZE: size in byte of last data written in Data register.
268 * @retval None
270 #define __HAL_HASH_SET_NBVALIDBITS(SIZE) do{HASH->STR &= ~(HASH_STR_NBW);\
271 HASH->STR |= 8 * ((SIZE) % 4);\
272 }while(0)
275 * @}
278 /* Include HASH HAL Extension module */
279 #include "stm32f7xx_hal_hash_ex.h"
280 /* Exported functions --------------------------------------------------------*/
282 /** @defgroup HASH_Exported_Functions HASH Exported Functions
283 * @{
286 /** @addtogroup HASH_Exported_Functions_Group1
287 * @{
289 HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
290 HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
292 * @}
295 /** @addtogroup HASH_Exported_Functions_Group2
296 * @{
298 HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
299 HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
300 HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
301 HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
303 * @}
306 /** @addtogroup HASH_Exported_Functions_Group3
307 * @{
309 HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
310 HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
312 * @}
315 /** @addtogroup HASH_Exported_Functions_Group4
316 * @{
318 HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
319 HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
321 * @}
324 /** @addtogroup HASH_Exported_Functions_Group5
325 * @{
327 HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
328 HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
329 HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
330 HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
332 * @}
335 /** @addtogroup HASH_Exported_Functions_Group6
336 * @{
338 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
339 HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
341 * @}
344 /** @addtogroup HASH_Exported_Functions_Group7
345 * @{
347 void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
349 * @}
352 /** @addtogroup HASH_Exported_Functions_Group8
353 * @{
355 HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
356 void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
357 void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
358 void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
359 void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
360 void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
362 * @}
366 * @}
369 /* Private types -------------------------------------------------------------*/
370 /** @defgroup HASH_Private_Types HASH Private Types
371 * @{
375 * @}
378 /* Private variables ---------------------------------------------------------*/
379 /** @defgroup HASH_Private_Variables HASH Private Variables
380 * @{
384 * @}
387 /* Private constants ---------------------------------------------------------*/
388 /** @defgroup HASH_Private_Constants HASH Private Constants
389 * @{
393 * @}
396 /* Private macros ------------------------------------------------------------*/
397 /** @defgroup HASH_Private_Macros HASH Private Macros
398 * @{
400 #define IS_HASH_ALGOSELECTION(__ALGOSELECTION__) (((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA1) || \
401 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA224) || \
402 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA256) || \
403 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_MD5))
406 #define IS_HASH_ALGOMODE(__ALGOMODE__) (((__ALGOMODE__) == HASH_ALGOMODE_HASH) || \
407 ((__ALGOMODE__) == HASH_ALGOMODE_HMAC))
410 #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
411 ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
412 ((__DATATYPE__) == HASH_DATATYPE_8B) || \
413 ((__DATATYPE__) == HASH_DATATYPE_1B))
416 #define IS_HASH_HMAC_KEYTYPE(__KEYTYPE__) (((__KEYTYPE__) == HASH_HMAC_KEYTYPE_SHORTKEY) || \
417 ((__KEYTYPE__) == HASH_HMAC_KEYTYPE_LONGKEY))
419 #define IS_HASH_SHA1_BUFFER_SIZE(__SIZE__) ((((__SIZE__)%4) != 0)? 0U: 1U)
423 * @}
426 /* Private functions ---------------------------------------------------------*/
427 /** @defgroup HASH_Private_Functions HASH Private Functions
428 * @{
432 * @}
436 * @}
438 #endif /* STM32F756xx || STM32F777xx || STM32F779xx */
440 * @}
443 #ifdef __cplusplus
445 #endif
448 #endif /* __STM32F7xx_HAL_HASH_H */
450 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/