Updated and Validated
[betaflight.git] / lib / main / STM32F7 / Drivers / STM32F7xx_HAL_Driver / Inc / stm32f7xx_hal_cryp.h
bloba8f8baff5ab140d09d03abfb6dd53983a5df9202
1 /**
2 ******************************************************************************
3 * @file stm32f7xx_hal_cryp.h
4 * @author MCD Application Team
5 * @brief Header file of CRYP HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
18 */
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32F7xx_HAL_CRYP_H
22 #define __STM32F7xx_HAL_CRYP_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32f7xx_hal_def.h"
32 /** @addtogroup STM32F7xx_HAL_Driver
33 * @{
35 #if defined (AES) || defined (CRYP)
36 /** @addtogroup CRYP
37 * @{
40 /* Exported types ------------------------------------------------------------*/
42 /** @defgroup CRYP_Exported_Types CRYP Exported Types
43 * @{
46 /**
47 * @brief CRYP Init Structure definition
50 typedef struct
52 uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string.
53 This parameter can be a value of @ref CRYP_Data_Type */
54 uint32_t KeySize; /*!< Used only in AES mode : 128, 192 or 256 bit key length in CRYP1.
55 128 or 256 bit key length in TinyAES This parameter can be a value of @ref CRYP_Key_Size */
56 uint32_t* pKey; /*!< The key used for encryption/decryption */
57 uint32_t* pInitVect; /*!< The initialization vector used also as initialization
58 counter in CTR mode */
59 uint32_t Algorithm; /*!< DES/ TDES Algorithm ECB/CBC
60 AES Algorithm ECB/CBC/CTR/GCM or CCM
61 This parameter can be a value of @ref CRYP_Algorithm_Mode */
62 uint32_t* Header; /*!< used only in AES GCM and CCM Algorithm for authentication,
63 GCM : also known as Additional Authentication Data
64 CCM : named B1 composed of the associated data length and Associated Data. */
65 uint32_t HeaderSize; /*!< The size of header buffer in word */
66 uint32_t* B0; /*!< B0 is first authentication block used only in AES CCM mode */
67 uint32_t DataWidthUnit; /*!< Data With Unit, this parameter can be value of @ref CRYP_Data_Width_Unit*/
69 }CRYP_ConfigTypeDef;
72 /**
73 * @brief CRYP State Structure definition
76 typedef enum
78 HAL_CRYP_STATE_RESET = 0x00U, /*!< CRYP not yet initialized or disabled */
79 HAL_CRYP_STATE_READY = 0x01U, /*!< CRYP initialized and ready for use */
80 HAL_CRYP_STATE_BUSY = 0x02U /*!< CRYP BUSY, internal processing is ongoing */
81 }HAL_CRYP_STATETypeDef;
84 /**
85 * @brief CRYP handle Structure definition
88 typedef struct __CRYP_HandleTypeDef
90 #if defined (CRYP)
91 CRYP_TypeDef *Instance; /*!< CRYP registers base address */
92 #else /* AES*/
93 AES_TypeDef *Instance; /*!< AES Register base address */
94 #endif /* End AES or CRYP */
96 CRYP_ConfigTypeDef Init; /*!< CRYP required parameters */
98 FunctionalState AutoKeyDerivation; /*!< Used only in TinyAES to allows to bypass or not key write-up before decryption.
99 This parameter can be a value of ENABLE/DISABLE */
101 uint32_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */
103 uint32_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */
105 __IO uint16_t CrypHeaderCount; /*!< Counter of header data */
107 __IO uint16_t CrypInCount; /*!< Counter of input data */
109 __IO uint16_t CrypOutCount; /*!< Counter of output data */
111 uint16_t Size; /*!< length of input data in word */
113 uint32_t Phase; /*!< CRYP peripheral phase */
115 DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */
117 DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */
119 HAL_LockTypeDef Lock; /*!< CRYP locking object */
121 __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */
123 __IO uint32_t ErrorCode; /*!< CRYP peripheral error code */
125 #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
126 void (*InCpltCallback) (struct __CRYP_HandleTypeDef * hcryp); /*!< CRYP Input FIFO transfer completed callback */
127 void (*OutCpltCallback) (struct __CRYP_HandleTypeDef * hcryp); /*!< CRYP Output FIFO transfer completed callback */
128 void (*ErrorCallback) (struct __CRYP_HandleTypeDef * hcryp); /*!< CRYP Error callback */
130 void (* MspInitCallback) (struct __CRYP_HandleTypeDef * hcryp); /*!< CRYP Msp Init callback */
131 void (* MspDeInitCallback)(struct __CRYP_HandleTypeDef * hcryp); /*!< CRYP Msp DeInit callback */
133 #endif /* (USE_HAL_CRYP_REGISTER_CALLBACKS) */
134 }CRYP_HandleTypeDef;
138 * @}
141 #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
142 /** @defgroup HAL_CRYP_Callback_ID_enumeration_definition HAL CRYP Callback ID enumeration definition
143 * @brief HAL CRYP Callback ID enumeration definition
144 * @{
146 typedef enum
148 HAL_CRYP_INPUT_COMPLETE_CB_ID = 0x01U, /*!< CRYP Input FIFO transfer completed callback ID */
149 HAL_CRYP_OUTPUT_COMPLETE_CB_ID = 0x02U, /*!< CRYP Output FIFO transfer completed callback ID */
150 HAL_CRYP_ERROR_CB_ID = 0x03U, /*!< CRYP Error callback ID */
152 HAL_CRYP_MSPINIT_CB_ID = 0x04U, /*!< CRYP MspInit callback ID */
153 HAL_CRYP_MSPDEINIT_CB_ID = 0x05U /*!< CRYP MspDeInit callback ID */
155 }HAL_CRYP_CallbackIDTypeDef;
157 * @}
160 /** @defgroup HAL_CRYP_Callback_pointer_definition HAL CRYP Callback pointer definition
161 * @brief HAL CRYP Callback pointer definition
162 * @{
165 typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef * hcryp); /*!< pointer to a common CRYP callback function */
168 * @}
171 #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
173 /* Exported constants --------------------------------------------------------*/
174 /** @defgroup CRYP_Exported_Constants CRYP Exported Constants
175 * @{
178 /** @defgroup CRYP_Error_Definition CRYP Error Definition
179 * @{
181 #define HAL_CRYP_ERROR_NONE 0x00000000U /*!< No error */
182 #define HAL_CRYP_ERROR_WRITE 0x00000001U /*!< Write error */
183 #define HAL_CRYP_ERROR_READ 0x00000002U /*!< Read error */
184 #define HAL_CRYP_ERROR_DMA 0x00000004U /*!< DMA error */
185 #define HAL_CRYP_ERROR_BUSY 0x00000008U /*!< Busy flag error */
186 #define HAL_CRYP_ERROR_TIMEOUT 0x00000010U /*!< Timeout error */
187 #define HAL_CRYP_ERROR_NOT_SUPPORTED 0x00000020U /*!< Not supported mode */
188 #define HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE 0x00000040U /*!< Sequence are not respected only for GCM or CCM */
189 #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
190 #define HAL_CRYP_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U) /*!< Invalid Callback error */
191 #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
192 /**
193 * @}
196 /** @defgroup CRYP_Data_Width_Unit CRYP Data Width Unit
197 * @{
200 #define CRYP_DATAWIDTHUNIT_WORD 0x00000000U /*!< By default, size unit is word */
201 #define CRYP_DATAWIDTHUNIT_BYTE 0x00000001U /*!< By default, size unit is word */
203 /**
204 * @}
207 /** @defgroup CRYP_Algorithm_Mode CRYP Algorithm Mode
208 * @{
210 #if defined(CRYP)
212 #define CRYP_DES_ECB CRYP_CR_ALGOMODE_DES_ECB
213 #define CRYP_DES_CBC CRYP_CR_ALGOMODE_DES_CBC
214 #define CRYP_TDES_ECB CRYP_CR_ALGOMODE_TDES_ECB
215 #define CRYP_TDES_CBC CRYP_CR_ALGOMODE_TDES_CBC
216 #define CRYP_AES_ECB CRYP_CR_ALGOMODE_AES_ECB
217 #define CRYP_AES_CBC CRYP_CR_ALGOMODE_AES_CBC
218 #define CRYP_AES_CTR CRYP_CR_ALGOMODE_AES_CTR
220 #define CRYP_AES_GCM CRYP_CR_ALGOMODE_AES_GCM
221 #define CRYP_AES_CCM CRYP_CR_ALGOMODE_AES_CCM
223 #else /* AES*/
224 #define CRYP_AES_ECB 0x00000000U /*!< Electronic codebook chaining algorithm */
225 #define CRYP_AES_CBC AES_CR_CHMOD_0 /*!< Cipher block chaining algorithm */
226 #define CRYP_AES_CTR AES_CR_CHMOD_1 /*!< Counter mode chaining algorithm */
227 #define CRYP_AES_GCM_GMAC (AES_CR_CHMOD_0 | AES_CR_CHMOD_1) /*!< Galois counter mode - Galois message authentication code */
228 #define CRYP_AES_CCM AES_CR_CHMOD_2 /*!< Counter with Cipher Mode */
229 #endif /* End AES or CRYP */
231 /**
232 * @}
235 /** @defgroup CRYP_Key_Size CRYP Key Size
236 * @{
238 #if defined(CRYP)
239 #define CRYP_KEYSIZE_128B 0x00000000U
240 #define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0
241 #define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1
242 #else /* AES*/
243 #define CRYP_KEYSIZE_128B 0x00000000U /*!< 128-bit long key */
244 #define CRYP_KEYSIZE_256B AES_CR_KEYSIZE /*!< 256-bit long key */
245 #endif /* End AES or CRYP */
246 /**
247 * @}
250 /** @defgroup CRYP_Data_Type CRYP Data Type
251 * @{
253 #if defined(CRYP)
254 #define CRYP_DATATYPE_32B 0x00000000U
255 #define CRYP_DATATYPE_16B CRYP_CR_DATATYPE_0
256 #define CRYP_DATATYPE_8B CRYP_CR_DATATYPE_1
257 #define CRYP_DATATYPE_1B CRYP_CR_DATATYPE
258 #else /* AES*/
259 #define CRYP_DATATYPE_32B 0x00000000U /*!< 32-bit data type (no swapping) */
260 #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */
261 #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */
262 #define CRYP_DATATYPE_1B AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */
263 #endif /* End AES or CRYP */
265 /**
266 * @}
269 /** @defgroup CRYP_Interrupt CRYP Interrupt
270 * @{
272 #if defined (CRYP)
273 #define CRYP_IT_INI CRYP_IMSCR_INIM /*!< Input FIFO Interrupt */
274 #define CRYP_IT_OUTI CRYP_IMSCR_OUTIM /*!< Output FIFO Interrupt */
275 #else /* AES*/
276 #define CRYP_IT_CCFIE AES_CR_CCFIE /*!< Computation Complete interrupt enable */
277 #define CRYP_IT_ERRIE AES_CR_ERRIE /*!< Error interrupt enable */
278 #define CRYP_IT_WRERR AES_SR_WRERR /*!< Write Error */
279 #define CRYP_IT_RDERR AES_SR_RDERR /*!< Read Error */
280 #define CRYP_IT_CCF AES_SR_CCF /*!< Computation completed */
281 #endif /* End AES or CRYP */
284 * @}
287 /** @defgroup CRYP_Flags CRYP Flags
288 * @{
290 #if defined (CRYP)
291 /* Flags in the SR register */
292 #define CRYP_FLAG_IFEM CRYP_SR_IFEM /*!< Input FIFO is empty */
293 #define CRYP_FLAG_IFNF CRYP_SR_IFNF /*!< Input FIFO is not Full */
294 #define CRYP_FLAG_OFNE CRYP_SR_OFNE /*!< Output FIFO is not empty */
295 #define CRYP_FLAG_OFFU CRYP_SR_OFFU /*!< Output FIFO is Full */
296 #define CRYP_FLAG_BUSY CRYP_SR_BUSY /*!< The CRYP core is currently processing a block of data
297 or a key preparation (for AES decryption). */
298 /* Flags in the RISR register */
299 #define CRYP_FLAG_OUTRIS 0x01000002U /*!< Output FIFO service raw interrupt status */
300 #define CRYP_FLAG_INRIS 0x01000001U /*!< Input FIFO service raw interrupt status*/
301 #else /* AES*/
302 /* status flags */
303 #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden */
304 #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error */
305 #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read error */
306 #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed */
307 /* clearing flags */
308 #define CRYP_CCF_CLEAR AES_CR_CCFC /*!< Computation Complete Flag Clear */
309 #define CRYP_ERR_CLEAR AES_CR_ERRC /*!< Error Flag Clear */
310 #endif /* End AES or CRYP */
313 * @}
318 * @}
321 /* Exported macros -----------------------------------------------------------*/
322 /** @defgroup CRYP_Exported_Macros CRYP Exported Macros
323 * @{
326 /** @brief Reset CRYP handle state
327 * @param __HANDLE__ specifies the CRYP handle.
328 * @retval None
330 #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
331 #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) do{\
332 (__HANDLE__)->State = HAL_CRYP_STATE_RESET;\
333 (__HANDLE__)->MspInitCallback = NULL;\
334 (__HANDLE__)->MspDeInitCallback = NULL;\
335 }while(0)
336 #else
337 #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ( (__HANDLE__)->State = HAL_CRYP_STATE_RESET)
338 #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
341 * @brief Enable/Disable the CRYP peripheral.
342 * @param __HANDLE__: specifies the CRYP handle.
343 * @retval None
345 #if defined(CRYP)
346 #define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRYP_CR_CRYPEN)
347 #define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~CRYP_CR_CRYPEN)
348 #else /* AES*/
349 #define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= AES_CR_EN)
350 #define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~AES_CR_EN)
351 #endif /* End AES or CRYP */
353 /** @brief Check whether the specified CRYP status flag is set or not.
354 * @param __FLAG__: specifies the flag to check.
355 * This parameter can be one of the following values for TinyAES:
356 * @arg @ref CRYP_FLAG_BUSY GCM process suspension forbidden
357 * @arg @ref CRYP_IT_WRERR Write Error
358 * @arg @ref CRYP_IT_RDERR Read Error
359 * @arg @ref CRYP_IT_CCF Computation Complete
360 * This parameter can be one of the following values for CRYP:
361 * @arg CRYP_FLAG_BUSY: The CRYP core is currently processing a block of data
362 * or a key preparation (for AES decryption).
363 * @arg CRYP_FLAG_IFEM: Input FIFO is empty
364 * @arg CRYP_FLAG_IFNF: Input FIFO is not full
365 * @arg CRYP_FLAG_INRIS: Input FIFO service raw interrupt is pending
366 * @arg CRYP_FLAG_OFNE: Output FIFO is not empty
367 * @arg CRYP_FLAG_OFFU: Output FIFO is full
368 * @arg CRYP_FLAG_OUTRIS: Input FIFO service raw interrupt is pending
369 * @retval The state of __FLAG__ (TRUE or FALSE).
371 #define CRYP_FLAG_MASK 0x0000001FU
372 #if defined(CRYP)
373 #define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 24)) == 0x01U)?((((__HANDLE__)->Instance->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)): \
374 ((((__HANDLE__)->Instance->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)))
375 #else /* AES*/
376 #define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
377 #endif /* End AES or CRYP */
379 /** @brief Clear the CRYP pending status flag.
380 * @param __FLAG__: specifies the flag to clear.
381 * This parameter can be one of the following values:
382 * @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear
383 * @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear
384 * @param __HANDLE__: specifies the CRYP handle.
385 * @retval None
388 #if defined(AES)
389 #define __HAL_CRYP_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT((__HANDLE__)->Instance->CR, (__FLAG__))
392 /** @brief Check whether the specified CRYP interrupt source is enabled or not.
393 * @param __INTERRUPT__: CRYP interrupt source to check
394 * This parameter can be one of the following values for TinyAES:
395 * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
396 * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
397 * @param __HANDLE__: specifies the CRYP handle.
398 * @retval State of interruption (TRUE or FALSE).
401 #define __HAL_CRYP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__))
403 #endif /* AES */
405 /** @brief Check whether the specified CRYP interrupt is set or not.
406 * @param __INTERRUPT__: specifies the interrupt to check.
407 * This parameter can be one of the following values for TinyAES:
408 * @arg @ref CRYP_IT_WRERR Write Error
409 * @arg @ref CRYP_IT_RDERR Read Error
410 * @arg @ref CRYP_IT_CCF Computation Complete
411 * This parameter can be one of the following values for CRYP:
412 * @arg CRYP_IT_INI: Input FIFO service masked interrupt status
413 * @arg CRYP_IT_OUTI: Output FIFO service masked interrupt status
414 * @param __HANDLE__: specifies the CRYP handle.
415 * @retval The state of __INTERRUPT__ (TRUE or FALSE).
417 #if defined(CRYP)
418 #define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->MISR & (__INTERRUPT__)) == (__INTERRUPT__))
419 #else /* AES*/
420 #define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
421 #endif /* End AES or CRYP */
424 * @brief Enable the CRYP interrupt.
425 * @param __INTERRUPT__: CRYP Interrupt.
426 * This parameter can be one of the following values for TinyAES:
427 * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
428 * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
429 * This parameter can be one of the following values for CRYP:
430 * @ CRYP_IT_INI : Input FIFO service interrupt mask.
431 * @ CRYP_IT_OUTI : Output FIFO service interrupt mask.CRYP interrupt.
432 * @param __HANDLE__: specifies the CRYP handle.
433 * @retval None
435 #if defined(CRYP)
436 #define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) |= (__INTERRUPT__))
437 #else /* AES*/
438 #define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__))
439 #endif /* End AES or CRYP */
442 * @brief Disable the CRYP interrupt.
443 * @param __INTERRUPT__: CRYP Interrupt.
444 * This parameter can be one of the following values for TinyAES:
445 * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
446 * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
447 * This parameter can be one of the following values for CRYP:
448 * @ CRYP_IT_INI : Input FIFO service interrupt mask.
449 * @ CRYP_IT_OUTI : Output FIFO service interrupt mask.CRYP interrupt.
450 * @param __HANDLE__: specifies the CRYP handle.
451 * @retval None
453 #if defined(CRYP)
454 #define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) &= ~(__INTERRUPT__))
455 #else /* AES*/
456 #define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__))
457 #endif /* End AES or CRYP */
460 * @}
462 /* Include CRYP HAL Extended module */
463 #include "stm32f7xx_hal_cryp_ex.h"
464 /* Exported functions --------------------------------------------------------*/
465 /** @defgroup CRYP_Exported_Functions CRYP Exported Functions
466 * @{
469 /** @addtogroup CRYP_Exported_Functions_Group1
470 * @{
472 HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp);
473 HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp);
474 void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp);
475 void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp);
476 HAL_StatusTypeDef HAL_CRYP_SetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf );
477 HAL_StatusTypeDef HAL_CRYP_GetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf );
478 #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
479 HAL_StatusTypeDef HAL_CRYP_RegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID, pCRYP_CallbackTypeDef pCallback);
480 HAL_StatusTypeDef HAL_CRYP_UnRegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID);
481 #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
483 * @}
486 /** @addtogroup CRYP_Exported_Functions_Group2
487 * @{
490 /* encryption/decryption ***********************************/
491 HAL_StatusTypeDef HAL_CRYP_Encrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output, uint32_t Timeout);
492 HAL_StatusTypeDef HAL_CRYP_Decrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output, uint32_t Timeout);
493 HAL_StatusTypeDef HAL_CRYP_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
494 HAL_StatusTypeDef HAL_CRYP_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
495 HAL_StatusTypeDef HAL_CRYP_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
496 HAL_StatusTypeDef HAL_CRYP_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
499 * @}
503 /** @addtogroup CRYP_Exported_Functions_Group3
504 * @{
506 /* Interrupt Handler functions **********************************************/
507 void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp);
508 HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp);
509 void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp);
510 void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp);
511 void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp);
512 uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
515 * @}
519 * @}
522 /* Private macros --------------------------------------------------------*/
523 /** @defgroup CRYP_Private_Macros CRYP Private Macros
524 * @{
527 /** @defgroup CRYP_IS_CRYP_Definitions CRYP Private macros to check input parameters
528 * @{
530 #if defined(CRYP)
531 #define IS_CRYP_ALGORITHM(ALGORITHM) (((ALGORITHM) == CRYP_DES_ECB) || \
532 ((ALGORITHM) == CRYP_DES_CBC) || \
533 ((ALGORITHM) == CRYP_TDES_ECB) || \
534 ((ALGORITHM) == CRYP_TDES_CBC) || \
535 ((ALGORITHM) == CRYP_AES_ECB) || \
536 ((ALGORITHM) == CRYP_AES_CBC) || \
537 ((ALGORITHM) == CRYP_AES_CTR) || \
538 ((ALGORITHM) == CRYP_AES_GCM) || \
539 ((ALGORITHM) == CRYP_AES_CCM))
540 #define IS_CRYP_KEYSIZE(KEYSIZE)(((KEYSIZE) == CRYP_KEYSIZE_128B) || \
541 ((KEYSIZE) == CRYP_KEYSIZE_192B) || \
542 ((KEYSIZE) == CRYP_KEYSIZE_256B))
543 #else /* AES*/
544 #define IS_CRYP_ALGORITHM(ALGORITHM) (((ALGORITHM) == CRYP_AES_ECB) || \
545 ((ALGORITHM) == CRYP_AES_CBC) || \
546 ((ALGORITHM) == CRYP_AES_CTR) || \
547 ((ALGORITHM) == CRYP_AES_GCM_GMAC)|| \
548 ((ALGORITHM) == CRYP_AES_CCM))
551 #define IS_CRYP_KEYSIZE(KEYSIZE)(((KEYSIZE) == CRYP_KEYSIZE_128B) || \
552 ((KEYSIZE) == CRYP_KEYSIZE_256B))
553 #endif /* End AES or CRYP */
555 #define IS_CRYP_DATATYPE(DATATYPE)(((DATATYPE) == CRYP_DATATYPE_32B) || \
556 ((DATATYPE) == CRYP_DATATYPE_16B) || \
557 ((DATATYPE) == CRYP_DATATYPE_8B) || \
558 ((DATATYPE) == CRYP_DATATYPE_1B))
561 * @}
565 * @}
569 /* Private constants ---------------------------------------------------------*/
570 /** @defgroup CRYP_Private_Constants CRYP Private Constants
571 * @{
575 * @}
577 /* Private defines -----------------------------------------------------------*/
578 /** @defgroup CRYP_Private_Defines CRYP Private Defines
579 * @{
583 * @}
586 /* Private variables ---------------------------------------------------------*/
587 /** @defgroup CRYP_Private_Variables CRYP Private Variables
588 * @{
592 * @}
594 /* Private functions prototypes ----------------------------------------------*/
595 /** @defgroup CRYP_Private_Functions_Prototypes CRYP Private Functions Prototypes
596 * @{
600 * @}
603 /* Private functions ---------------------------------------------------------*/
604 /** @defgroup CRYP_Private_Functions CRYP Private Functions
605 * @{
609 * @}
614 * @}
619 * @}
621 #endif /* TinyAES or CRYP*/
624 * @}
627 #ifdef __cplusplus
629 #endif
631 #endif /* __STM32F7xx_HAL_CRYP_H */
633 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/