You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

636 lines
25 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_hal_cryp.h
  4. * @author MCD Application Team
  5. * @brief Header file of CRYP HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  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
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32WBxx_HAL_CRYP_H
  21. #define STM32WBxx_HAL_CRYP_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx_hal_def.h"
  27. /** @addtogroup STM32WBxx_HAL_Driver
  28. * @{
  29. */
  30. /** @defgroup CRYP CRYP
  31. * @brief CRYP HAL module driver.
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup CRYP_Exported_Types CRYP Exported Types
  36. * @{
  37. */
  38. /**
  39. * @brief CRYP Init Structure definition
  40. */
  41. typedef struct
  42. {
  43. uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string.
  44. This parameter can be a value of @ref CRYP_Data_Type */
  45. uint32_t KeySize; /*!< Used only in AES mode : 128, 192 or 256 bit key length in CRYP1.
  46. 128 or 256 bit key length in TinyAES This parameter can be a value of @ref CRYP_Key_Size */
  47. uint32_t *pKey; /*!< The key used for encryption/decryption */
  48. uint32_t *pInitVect; /*!< The initialization vector used also as initialization
  49. counter in CTR mode */
  50. uint32_t Algorithm; /*!< DES/ TDES Algorithm ECB/CBC
  51. AES Algorithm ECB/CBC/CTR/GCM or CCM
  52. This parameter can be a value of @ref CRYP_Algorithm_Mode */
  53. uint32_t *Header; /*!< used only in AES GCM and CCM Algorithm for authentication,
  54. GCM : also known as Additional Authentication Data
  55. CCM : named B1 composed of the associated data length and Associated Data. */
  56. uint32_t HeaderSize; /*!< The size of header buffer in word */
  57. uint32_t *B0; /*!< B0 is first authentication block used only in AES CCM mode */
  58. uint32_t DataWidthUnit; /*!< Data With Unit, this parameter can be value of @ref CRYP_Data_Width_Unit*/
  59. uint32_t KeyIVConfigSkip; /*!< CRYP peripheral Key and IV configuration skip, to config Key and Initialization
  60. Vector only once and to skip configuration for consecutive processings.
  61. This parameter can be a value of @ref CRYP_Configuration_Skip */
  62. } CRYP_ConfigTypeDef;
  63. /**
  64. * @brief CRYP State Structure definition
  65. */
  66. typedef enum
  67. {
  68. HAL_CRYP_STATE_RESET = 0x00U, /*!< CRYP not yet initialized or disabled */
  69. HAL_CRYP_STATE_READY = 0x01U, /*!< CRYP initialized and ready for use */
  70. HAL_CRYP_STATE_BUSY = 0x02U, /*!< CRYP BUSY, internal processing is ongoing */
  71. #if (USE_HAL_CRYP_SUSPEND_RESUME == 1U)
  72. HAL_CRYP_STATE_SUSPENDED = 0x03U, /*!< CRYP suspended */
  73. #endif /* USE_HAL_CRYP_SUSPEND_RESUME */
  74. } HAL_CRYP_STATETypeDef;
  75. #if (USE_HAL_CRYP_SUSPEND_RESUME == 1U)
  76. /**
  77. * @brief HAL CRYP mode suspend definitions
  78. */
  79. typedef enum
  80. {
  81. HAL_CRYP_SUSPEND_NONE = 0x00U, /*!< CRYP processing suspension not requested */
  82. HAL_CRYP_SUSPEND = 0x01U /*!< CRYP processing suspension requested */
  83. }HAL_SuspendTypeDef;
  84. #endif /* USE_HAL_CRYP_SUSPEND_RESUME */
  85. /**
  86. * @brief CRYP handle Structure definition
  87. */
  88. #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
  89. typedef struct __CRYP_HandleTypeDef
  90. #else
  91. typedef struct
  92. #endif
  93. {
  94. AES_TypeDef *Instance; /*!< AES Register base address */
  95. CRYP_ConfigTypeDef Init; /*!< CRYP required parameters */
  96. FunctionalState AutoKeyDerivation; /*!< Used only in TinyAES to allow to bypass or not key write-up before decryption.
  97. This parameter can be a value of ENABLE/DISABLE */
  98. uint32_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */
  99. uint32_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */
  100. __IO uint16_t CrypHeaderCount; /*!< Counter of header data */
  101. __IO uint16_t CrypInCount; /*!< Counter of input data */
  102. __IO uint16_t CrypOutCount; /*!< Counter of output data */
  103. uint16_t Size; /*!< length of input data in words */
  104. uint32_t Phase; /*!< CRYP peripheral phase */
  105. DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */
  106. DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */
  107. HAL_LockTypeDef Lock; /*!< CRYP locking object */
  108. __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */
  109. __IO uint32_t ErrorCode; /*!< CRYP peripheral error code */
  110. uint32_t KeyIVConfig; /*!< CRYP peripheral Key and IV configuration flag, used when
  111. configuration can be skipped */
  112. uint32_t SizesSum; /*!< Sum of successive payloads lengths (in bytes), stored
  113. for a single signature computation after several
  114. messages processing */
  115. #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U)
  116. void (*InCpltCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Input FIFO transfer completed callback */
  117. void (*OutCpltCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Output FIFO transfer completed callback */
  118. void (*ErrorCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Error callback */
  119. void (* MspInitCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Msp Init callback */
  120. void (* MspDeInitCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Msp DeInit callback */
  121. #endif /* (USE_HAL_CRYP_REGISTER_CALLBACKS) */
  122. #if (USE_HAL_CRYP_SUSPEND_RESUME == 1U)
  123. __IO HAL_SuspendTypeDef SuspendRequest; /*!< CRYP peripheral suspension request flag */
  124. CRYP_ConfigTypeDef Init_saved; /*!< copy of CRYP required parameters when processing is suspended */
  125. uint32_t *pCrypInBuffPtr_saved; /*!< copy of CRYP input pointer when processing is suspended */
  126. uint32_t *pCrypOutBuffPtr_saved; /*!< copy of CRYP output pointer when processing is suspended */
  127. uint32_t CrypInCount_saved; /*!< copy of CRYP input data counter when processing is suspended */
  128. uint32_t CrypOutCount_saved; /*!< copy of CRYP output data counter when processing is suspended */
  129. uint32_t Phase_saved; /*!< copy of CRYP authentication phase when processing is suspended */
  130. __IO HAL_CRYP_STATETypeDef State_saved; /*!< copy of CRYP peripheral state when processing is suspended */
  131. uint32_t IV_saved[4]; /*!< copy of Initialisation Vector registers */
  132. uint32_t SUSPxR_saved[8]; /*!< copy of suspension registers */
  133. uint32_t CR_saved; /*!< copy of CRYP control register when processing is suspended*/
  134. uint32_t Key_saved[8]; /*!< copy of key registers */
  135. uint16_t Size_saved; /*!< copy of input buffer size */
  136. uint16_t CrypHeaderCount_saved; /*!< copy of CRYP header data counter when processing is suspended */
  137. uint32_t SizesSum_saved; /*!< copy of SizesSum when processing is suspended */
  138. uint32_t ResumingFlag; /*!< resumption flag to bypass steps already carried out */
  139. FunctionalState AutoKeyDerivation_saved; /*!< copy of CRYP handle auto key derivation parameter */
  140. #endif /* USE_HAL_CRYP_SUSPEND_RESUME */
  141. } CRYP_HandleTypeDef;
  142. #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U)
  143. /** @defgroup HAL_CRYP_Callback_ID_enumeration_definition HAL CRYP Callback ID enumeration definition
  144. * @brief HAL CRYP Callback ID enumeration definition
  145. * @{
  146. */
  147. typedef enum
  148. {
  149. HAL_CRYP_MSPINIT_CB_ID = 0x00U, /*!< CRYP MspInit callback ID */
  150. HAL_CRYP_MSPDEINIT_CB_ID = 0x01U, /*!< CRYP MspDeInit callback ID */
  151. HAL_CRYP_INPUT_COMPLETE_CB_ID = 0x02U, /*!< CRYP Input FIFO transfer completed callback ID */
  152. HAL_CRYP_OUTPUT_COMPLETE_CB_ID = 0x03U, /*!< CRYP Output FIFO transfer completed callback ID */
  153. HAL_CRYP_ERROR_CB_ID = 0x04U, /*!< CRYP Error callback ID */
  154. } HAL_CRYP_CallbackIDTypeDef;
  155. /**
  156. * @}
  157. */
  158. /** @defgroup HAL_CRYP_Callback_pointer_definition HAL CRYP Callback pointer definition
  159. * @brief HAL CRYP Callback pointer definition
  160. * @{
  161. */
  162. typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< pointer to a common CRYP callback function */
  163. /**
  164. * @}
  165. */
  166. #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
  167. /**
  168. * @}
  169. */
  170. /* Exported constants --------------------------------------------------------*/
  171. /** @defgroup CRYP_Exported_Constants CRYP Exported Constants
  172. * @{
  173. */
  174. /** @defgroup CRYP_Error_Definition CRYP Error Definition
  175. * @{
  176. */
  177. #define HAL_CRYP_ERROR_NONE 0x00000000U /*!< No error */
  178. #define HAL_CRYP_ERROR_WRITE 0x00000001U /*!< Write error */
  179. #define HAL_CRYP_ERROR_READ 0x00000002U /*!< Read error */
  180. #define HAL_CRYP_ERROR_DMA 0x00000004U /*!< DMA error */
  181. #define HAL_CRYP_ERROR_BUSY 0x00000008U /*!< Busy flag error */
  182. #define HAL_CRYP_ERROR_TIMEOUT 0x00000010U /*!< Timeout error */
  183. #define HAL_CRYP_ERROR_NOT_SUPPORTED 0x00000020U /*!< Not supported mode */
  184. #define HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE 0x00000040U /*!< Sequence are not respected only for GCM or CCM */
  185. #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U)
  186. #define HAL_CRYP_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U) /*!< Invalid Callback error */
  187. #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
  188. /**
  189. * @}
  190. */
  191. /** @defgroup CRYP_Data_Width_Unit CRYP Data Width Unit
  192. * @{
  193. */
  194. #define CRYP_DATAWIDTHUNIT_WORD 0x00000000U /*!< By default, size unit is word */
  195. #define CRYP_DATAWIDTHUNIT_BYTE 0x00000001U /*!< By default, size unit is byte */
  196. /**
  197. * @}
  198. */
  199. /** @defgroup CRYP_Algorithm_Mode CRYP Algorithm Mode
  200. * @{
  201. */
  202. #define CRYP_AES_ECB 0x00000000U /*!< Electronic codebook chaining algorithm */
  203. #define CRYP_AES_CBC AES_CR_CHMOD_0 /*!< Cipher block chaining algorithm */
  204. #define CRYP_AES_CTR AES_CR_CHMOD_1 /*!< Counter mode chaining algorithm */
  205. #define CRYP_AES_GCM_GMAC (AES_CR_CHMOD_0 | AES_CR_CHMOD_1) /*!< Galois counter mode - Galois message authentication code */
  206. #define CRYP_AES_CCM AES_CR_CHMOD_2 /*!< Counter with Cipher Mode */
  207. /**
  208. * @}
  209. */
  210. /** @defgroup CRYP_Key_Size CRYP Key Size
  211. * @{
  212. */
  213. #define CRYP_KEYSIZE_128B 0x00000000U /*!< 128-bit long key */
  214. #define CRYP_KEYSIZE_256B AES_CR_KEYSIZE /*!< 256-bit long key */
  215. /**
  216. * @}
  217. */
  218. /** @defgroup CRYP_Data_Type CRYP Data Type
  219. * @{
  220. */
  221. #define CRYP_DATATYPE_32B 0x00000000U /*!< 32-bit data type (no swapping) */
  222. #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */
  223. #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */
  224. #define CRYP_DATATYPE_1B AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */
  225. /**
  226. * @}
  227. */
  228. /** @defgroup CRYP_Interrupt CRYP Interrupt
  229. * @{
  230. */
  231. #define CRYP_IT_CCFIE AES_CR_CCFIE /*!< Computation Complete interrupt enable */
  232. #define CRYP_IT_ERRIE AES_CR_ERRIE /*!< Error interrupt enable */
  233. #define CRYP_IT_WRERR AES_SR_WRERR /*!< Write Error */
  234. #define CRYP_IT_RDERR AES_SR_RDERR /*!< Read Error */
  235. #define CRYP_IT_CCF AES_SR_CCF /*!< Computation completed */
  236. /**
  237. * @}
  238. */
  239. /** @defgroup CRYP_Flags CRYP Flags
  240. * @{
  241. */
  242. /* status flags */
  243. #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden */
  244. #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error */
  245. #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read error */
  246. #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed */
  247. /* clearing flags */
  248. #define CRYP_CCF_CLEAR AES_CR_CCFC /*!< Computation Complete Flag Clear */
  249. #define CRYP_ERR_CLEAR AES_CR_ERRC /*!< Error Flag Clear */
  250. /**
  251. * @}
  252. */
  253. /** @defgroup CRYP_Configuration_Skip CRYP Key and IV Configuration Skip Mode
  254. * @{
  255. */
  256. #define CRYP_KEYIVCONFIG_ALWAYS 0x00000000U /*!< Peripheral Key and IV configuration to do systematically */
  257. #define CRYP_KEYIVCONFIG_ONCE 0x00000001U /*!< Peripheral Key and IV configuration to do only once */
  258. /**
  259. * @}
  260. */
  261. /**
  262. * @}
  263. */
  264. /* Exported macros -----------------------------------------------------------*/
  265. /** @defgroup CRYP_Exported_Macros CRYP Exported Macros
  266. * @{
  267. */
  268. /** @brief Reset CRYP handle state
  269. * @param __HANDLE__ specifies the CRYP handle.
  270. * @retval None
  271. */
  272. #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U)
  273. #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) do{\
  274. (__HANDLE__)->State = HAL_CRYP_STATE_RESET;\
  275. (__HANDLE__)->MspInitCallback = NULL;\
  276. (__HANDLE__)->MspDeInitCallback = NULL;\
  277. }while(0U)
  278. #else
  279. #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ( (__HANDLE__)->State = HAL_CRYP_STATE_RESET)
  280. #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
  281. /**
  282. * @brief Enable/Disable the CRYP peripheral.
  283. * @param __HANDLE__ specifies the CRYP handle.
  284. * @retval None
  285. */
  286. #define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= AES_CR_EN)
  287. #define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~AES_CR_EN)
  288. /** @brief Check whether the specified CRYP status flag is set or not.
  289. * @param __HANDLE__ specifies the CRYP handle.
  290. * @param __FLAG__ specifies the flag to check.
  291. * This parameter can be one of the following values for TinyAES:
  292. * @arg @ref CRYP_FLAG_BUSY GCM process suspension forbidden
  293. * @arg @ref CRYP_IT_WRERR Write Error
  294. * @arg @ref CRYP_IT_RDERR Read Error
  295. * @arg @ref CRYP_IT_CCF Computation Complete
  296. * This parameter can be one of the following values for CRYP:
  297. * @arg CRYP_FLAG_BUSY: The CRYP core is currently processing a block of data
  298. * or a key preparation (for AES decryption).
  299. * @arg CRYP_FLAG_IFEM: Input FIFO is empty
  300. * @arg CRYP_FLAG_IFNF: Input FIFO is not full
  301. * @arg CRYP_FLAG_INRIS: Input FIFO service raw interrupt is pending
  302. * @arg CRYP_FLAG_OFNE: Output FIFO is not empty
  303. * @arg CRYP_FLAG_OFFU: Output FIFO is full
  304. * @arg CRYP_FLAG_OUTRIS: Input FIFO service raw interrupt is pending
  305. * @retval The state of __FLAG__ (TRUE or FALSE).
  306. */
  307. #define CRYP_FLAG_MASK 0x0000001FU
  308. #define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
  309. /** @brief Clear the CRYP pending status flag.
  310. * @param __HANDLE__ specifies the CRYP handle.
  311. * @param __FLAG__ specifies the flag to clear.
  312. * This parameter can be one of the following values:
  313. * @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear
  314. * @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear
  315. * @retval None
  316. */
  317. #define __HAL_CRYP_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT((__HANDLE__)->Instance->CR, (__FLAG__))
  318. /** @brief Check whether the specified CRYP interrupt source is enabled or not.
  319. * @param __HANDLE__ specifies the CRYP handle.
  320. * @param __INTERRUPT__ CRYP interrupt source to check
  321. * This parameter can be one of the following values for TinyAES:
  322. * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
  323. * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
  324. * @retval State of interruption (TRUE or FALSE).
  325. */
  326. #define __HAL_CRYP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__))
  327. /** @brief Check whether the specified CRYP interrupt is set or not.
  328. * @param __HANDLE__ specifies the CRYP handle.
  329. * @param __INTERRUPT__ specifies the interrupt to check.
  330. * This parameter can be one of the following values for TinyAES:
  331. * @arg @ref CRYP_IT_WRERR Write Error
  332. * @arg @ref CRYP_IT_RDERR Read Error
  333. * @arg @ref CRYP_IT_CCF Computation Complete
  334. * This parameter can be one of the following values for CRYP:
  335. * @arg CRYP_IT_INI: Input FIFO service masked interrupt status
  336. * @arg CRYP_IT_OUTI: Output FIFO service masked interrupt status
  337. * @retval The state of __INTERRUPT__ (TRUE or FALSE).
  338. */
  339. #define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
  340. /**
  341. * @brief Enable the CRYP interrupt.
  342. * @param __HANDLE__ specifies the CRYP handle.
  343. * @param __INTERRUPT__ CRYP Interrupt.
  344. * This parameter can be one of the following values for TinyAES:
  345. * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
  346. * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
  347. * This parameter can be one of the following values for CRYP:
  348. * @ CRYP_IT_INI : Input FIFO service interrupt mask.
  349. * @ CRYP_IT_OUTI : Output FIFO service interrupt mask.CRYP interrupt.
  350. * @retval None
  351. */
  352. #define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__))
  353. /**
  354. * @brief Disable the CRYP interrupt.
  355. * @param __HANDLE__ specifies the CRYP handle.
  356. * @param __INTERRUPT__ CRYP Interrupt.
  357. * This parameter can be one of the following values for TinyAES:
  358. * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
  359. * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
  360. * This parameter can be one of the following values for CRYP:
  361. * @ CRYP_IT_INI : Input FIFO service interrupt mask.
  362. * @ CRYP_IT_OUTI : Output FIFO service interrupt mask.CRYP interrupt.
  363. * @retval None
  364. */
  365. #define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__))
  366. /**
  367. * @}
  368. */
  369. /* Include CRYP HAL Extended module */
  370. #include "stm32wbxx_hal_cryp_ex.h"
  371. /* Exported functions --------------------------------------------------------*/
  372. /** @defgroup CRYP_Exported_Functions CRYP Exported Functions
  373. * @{
  374. */
  375. /** @addtogroup CRYP_Exported_Functions_Group1
  376. * @{
  377. */
  378. HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp);
  379. HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp);
  380. void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp);
  381. void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp);
  382. HAL_StatusTypeDef HAL_CRYP_SetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf);
  383. HAL_StatusTypeDef HAL_CRYP_GetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf);
  384. #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U)
  385. HAL_StatusTypeDef HAL_CRYP_RegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID, pCRYP_CallbackTypeDef pCallback);
  386. HAL_StatusTypeDef HAL_CRYP_UnRegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID);
  387. #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
  388. #if (USE_HAL_CRYP_SUSPEND_RESUME == 1U)
  389. void HAL_CRYP_ProcessSuspend(CRYP_HandleTypeDef *hcryp);
  390. HAL_StatusTypeDef HAL_CRYP_Suspend(CRYP_HandleTypeDef *hcryp);
  391. HAL_StatusTypeDef HAL_CRYP_Resume(CRYP_HandleTypeDef *hcryp);
  392. #endif /* defined (USE_HAL_CRYP_SUSPEND_RESUME) */
  393. /**
  394. * @}
  395. */
  396. /** @addtogroup CRYP_Exported_Functions_Group2
  397. * @{
  398. */
  399. /* encryption/decryption ***********************************/
  400. HAL_StatusTypeDef HAL_CRYP_Encrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output, uint32_t Timeout);
  401. HAL_StatusTypeDef HAL_CRYP_Decrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output, uint32_t Timeout);
  402. HAL_StatusTypeDef HAL_CRYP_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
  403. HAL_StatusTypeDef HAL_CRYP_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
  404. HAL_StatusTypeDef HAL_CRYP_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
  405. HAL_StatusTypeDef HAL_CRYP_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output);
  406. /**
  407. * @}
  408. */
  409. /** @addtogroup CRYP_Exported_Functions_Group3
  410. * @{
  411. */
  412. /* Interrupt Handler functions **********************************************/
  413. void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp);
  414. HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp);
  415. void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp);
  416. void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp);
  417. void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp);
  418. uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
  419. /**
  420. * @}
  421. */
  422. /**
  423. * @}
  424. */
  425. /* Private macros --------------------------------------------------------*/
  426. /** @defgroup CRYP_Private_Macros CRYP Private Macros
  427. * @{
  428. */
  429. /** @defgroup CRYP_IS_CRYP_Definitions CRYP Private macros to check input parameters
  430. * @{
  431. */
  432. #define IS_CRYP_ALGORITHM(ALGORITHM) (((ALGORITHM) == CRYP_AES_ECB) || \
  433. ((ALGORITHM) == CRYP_AES_CBC) || \
  434. ((ALGORITHM) == CRYP_AES_CTR) || \
  435. ((ALGORITHM) == CRYP_AES_GCM_GMAC)|| \
  436. ((ALGORITHM) == CRYP_AES_CCM))
  437. #define IS_CRYP_KEYSIZE(KEYSIZE)(((KEYSIZE) == CRYP_KEYSIZE_128B) || \
  438. ((KEYSIZE) == CRYP_KEYSIZE_256B))
  439. #define IS_CRYP_DATATYPE(DATATYPE)(((DATATYPE) == CRYP_DATATYPE_32B) || \
  440. ((DATATYPE) == CRYP_DATATYPE_16B) || \
  441. ((DATATYPE) == CRYP_DATATYPE_8B) || \
  442. ((DATATYPE) == CRYP_DATATYPE_1B))
  443. #define IS_CRYP_INIT(CONFIG)(((CONFIG) == CRYP_KEYIVCONFIG_ALWAYS) || \
  444. ((CONFIG) == CRYP_KEYIVCONFIG_ONCE))
  445. #define IS_CRYP_BUFFERSIZE(ALGO, DATAWIDTH, SIZE) \
  446. (((((ALGO) == CRYP_AES_ECB) || ((ALGO) == CRYP_AES_CBC) || ((ALGO) == CRYP_AES_CTR)) && \
  447. ((((DATAWIDTH) == CRYP_DATAWIDTHUNIT_WORD) && (((SIZE) % 4U) == 0U)) || \
  448. (((DATAWIDTH) == CRYP_DATAWIDTHUNIT_BYTE) && (((SIZE) % 16U) == 0U)))) || \
  449. (((ALGO)== CRYP_AES_GCM_GMAC) || ((ALGO) == CRYP_AES_CCM)))
  450. /**
  451. * @}
  452. */
  453. /**
  454. * @}
  455. */
  456. /* Private constants ---------------------------------------------------------*/
  457. /** @defgroup CRYP_Private_Constants CRYP Private Constants
  458. * @{
  459. */
  460. /**
  461. * @}
  462. */
  463. /* Private defines -----------------------------------------------------------*/
  464. /** @defgroup CRYP_Private_Defines CRYP Private Defines
  465. * @{
  466. */
  467. /**
  468. * @}
  469. */
  470. /* Private variables ---------------------------------------------------------*/
  471. /** @defgroup CRYP_Private_Variables CRYP Private Variables
  472. * @{
  473. */
  474. /**
  475. * @}
  476. */
  477. /* Private functions ---------------------------------------------------------*/
  478. /** @defgroup CRYP_Private_Functions CRYP Private Functions
  479. * @{
  480. */
  481. /**
  482. * @}
  483. */
  484. /**
  485. * @}
  486. */
  487. /**
  488. * @}
  489. */
  490. #ifdef __cplusplus
  491. }
  492. #endif
  493. #endif /* STM32WBxx_HAL_CRYP_H */
  494. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/