stm32f4xx_hal_cryp_ex.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_cryp_ex.h
  4. * @author MCD Application Team
  5. * @version V1.3.0
  6. * @date 09-March-2015
  7. * @brief Header file of CRYP HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  12. *
  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.
  23. *
  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.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_HAL_CRYP_EX_H
  39. #define __STM32F4xx_HAL_CRYP_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if defined(STM32F437xx) || defined(STM32F439xx)
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32f4xx_hal_def.h"
  46. /** @addtogroup STM32F4xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup CRYPEx
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /* Exported constants --------------------------------------------------------*/
  54. /** @defgroup CRYPEx_Exported_Constants CRYPEx Exported Constants
  55. * @{
  56. */
  57. /** @defgroup CRYPEx_Exported_Constants_Group1 CRYP AlgoModeDirection
  58. * @{
  59. */
  60. #define CRYP_CR_ALGOMODE_AES_GCM_ENCRYPT ((uint32_t)0x00080000)
  61. #define CRYP_CR_ALGOMODE_AES_GCM_DECRYPT ((uint32_t)0x00080004)
  62. #define CRYP_CR_ALGOMODE_AES_CCM_ENCRYPT ((uint32_t)0x00080008)
  63. #define CRYP_CR_ALGOMODE_AES_CCM_DECRYPT ((uint32_t)0x0008000C)
  64. /**
  65. * @}
  66. */
  67. /** @defgroup CRYPEx_Exported_Constants_Group3 CRYP PhaseConfig
  68. * @brief The phases are relevant only to AES-GCM and AES-CCM
  69. * @{
  70. */
  71. #define CRYP_PHASE_INIT ((uint32_t)0x00000000)
  72. #define CRYP_PHASE_HEADER CRYP_CR_GCM_CCMPH_0
  73. #define CRYP_PHASE_PAYLOAD CRYP_CR_GCM_CCMPH_1
  74. #define CRYP_PHASE_FINAL CRYP_CR_GCM_CCMPH
  75. /**
  76. * @}
  77. */
  78. /**
  79. * @}
  80. */
  81. /* Exported macro ------------------------------------------------------------*/
  82. /** @defgroup CRYPEx_Exported_Macros CRYP Exported Macros
  83. * @{
  84. */
  85. /**
  86. * @brief Set the phase: Init, header, payload, final.
  87. * This is relevant only for GCM and CCM modes.
  88. * @param __HANDLE__: specifies the CRYP handle.
  89. * @param __PHASE__: The phase.
  90. * @retval None
  91. */
  92. #define __HAL_CRYP_SET_PHASE(__HANDLE__, __PHASE__) do{(__HANDLE__)->Instance->CR &= (uint32_t)(~CRYP_CR_GCM_CCMPH);\
  93. (__HANDLE__)->Instance->CR |= (uint32_t)(__PHASE__);\
  94. }while(0)
  95. /**
  96. * @}
  97. */
  98. /* Exported functions --------------------------------------------------------*/
  99. /** @defgroup CRYPEx_Exported_Functions CRYPEx Exported Functions
  100. * @{
  101. */
  102. /** @addtogroup CRYPEx_Exported_Functions_Group1
  103. * @{
  104. */
  105. /* AES encryption/decryption using polling ***********************************/
  106. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout);
  107. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout);
  108. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Finish(CRYP_HandleTypeDef *hcryp, uint32_t Size, uint8_t *AuthTag, uint32_t Timeout);
  109. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout);
  110. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout);
  111. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Finish(CRYP_HandleTypeDef *hcryp, uint8_t *AuthTag, uint32_t Timeout);
  112. /* AES encryption/decryption using interrupt *********************************/
  113. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
  114. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
  115. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
  116. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
  117. /* AES encryption/decryption using DMA ***************************************/
  118. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
  119. HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
  120. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
  121. HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
  122. /**
  123. * @}
  124. */
  125. /** @addtogroup CRYPEx_Exported_Functions_Group2
  126. * @{
  127. */
  128. void HAL_CRYPEx_GCMCCM_IRQHandler(CRYP_HandleTypeDef *hcryp);
  129. /**
  130. * @}
  131. */
  132. /**
  133. * @}
  134. */
  135. /* Private types -------------------------------------------------------------*/
  136. /** @defgroup CRYPEx_Private_Types CRYPEx Private Types
  137. * @{
  138. */
  139. /**
  140. * @}
  141. */
  142. /* Private variables ---------------------------------------------------------*/
  143. /** @defgroup CRYPEx_Private_Variables CRYPEx Private Variables
  144. * @{
  145. */
  146. /**
  147. * @}
  148. */
  149. /* Private constants ---------------------------------------------------------*/
  150. /** @defgroup CRYPEx_Private_Constants CRYPEx Private Constants
  151. * @{
  152. */
  153. /**
  154. * @}
  155. */
  156. /* Private macros ------------------------------------------------------------*/
  157. /** @defgroup CRYPEx_Private_Macros CRYPEx Private Macros
  158. * @{
  159. */
  160. /**
  161. * @}
  162. */
  163. /* Private functions ---------------------------------------------------------*/
  164. /** @defgroup CRYPEx_Private_Functions CRYPEx Private Functions
  165. * @{
  166. */
  167. /**
  168. * @}
  169. */
  170. #endif /* STM32F437xx || STM32F439xx */
  171. /**
  172. * @}
  173. */
  174. /**
  175. * @}
  176. */
  177. #ifdef __cplusplus
  178. }
  179. #endif
  180. #endif /* __STM32F4xx_HAL_CRYP_EX_H */
  181. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/