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.
 
 
 

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