STM32F439xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_cryp_ex.h 00004 * @author MCD Application Team 00005 * @brief Header file of CRYP HAL Extension module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32F4xx_HAL_CRYP_EX_H 00038 #define __STM32F4xx_HAL_CRYP_EX_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32f4xx_hal_def.h" 00046 00047 00048 #if defined(CRYP) 00049 00050 /** @addtogroup STM32F4xx_HAL_Driver 00051 * @{ 00052 */ 00053 00054 /** @addtogroup CRYPEx 00055 * @{ 00056 */ 00057 00058 /* Exported types ------------------------------------------------------------*/ 00059 /* Exported constants --------------------------------------------------------*/ 00060 00061 /** @defgroup CRYPEx_Exported_Constants CRYPEx Exported Constants 00062 * @{ 00063 */ 00064 00065 /** @defgroup CRYPEx_Exported_Constants_Group1 CRYP AlgoModeDirection 00066 * @{ 00067 */ 00068 #define CRYP_CR_ALGOMODE_AES_GCM_ENCRYPT 0x00080000U 00069 #define CRYP_CR_ALGOMODE_AES_GCM_DECRYPT 0x00080004U 00070 #define CRYP_CR_ALGOMODE_AES_CCM_ENCRYPT 0x00080008U 00071 #define CRYP_CR_ALGOMODE_AES_CCM_DECRYPT 0x0008000CU 00072 00073 /** 00074 * @} 00075 */ 00076 00077 /** @defgroup CRYPEx_Exported_Constants_Group3 CRYP PhaseConfig 00078 * @brief The phases are relevant only to AES-GCM and AES-CCM 00079 * @{ 00080 */ 00081 #define CRYP_PHASE_INIT 0x00000000U 00082 #define CRYP_PHASE_HEADER CRYP_CR_GCM_CCMPH_0 00083 #define CRYP_PHASE_PAYLOAD CRYP_CR_GCM_CCMPH_1 00084 #define CRYP_PHASE_FINAL CRYP_CR_GCM_CCMPH 00085 /** 00086 * @} 00087 */ 00088 00089 /** 00090 * @} 00091 */ 00092 00093 /* Exported macro ------------------------------------------------------------*/ 00094 /** @defgroup CRYPEx_Exported_Macros CRYP Exported Macros 00095 * @{ 00096 */ 00097 00098 /** 00099 * @brief Set the phase: Init, header, payload, final. 00100 * This is relevant only for GCM and CCM modes. 00101 * @param __HANDLE__ specifies the CRYP handle. 00102 * @param __PHASE__ The phase. 00103 * @retval None 00104 */ 00105 #define __HAL_CRYP_SET_PHASE(__HANDLE__, __PHASE__) do{(__HANDLE__)->Instance->CR &= (uint32_t)(~CRYP_CR_GCM_CCMPH);\ 00106 (__HANDLE__)->Instance->CR |= (uint32_t)(__PHASE__);\ 00107 }while(0) 00108 00109 /** 00110 * @} 00111 */ 00112 00113 /* Exported functions --------------------------------------------------------*/ 00114 /** @defgroup CRYPEx_Exported_Functions CRYPEx Exported Functions 00115 * @{ 00116 */ 00117 00118 /** @addtogroup CRYPEx_Exported_Functions_Group1 00119 * @{ 00120 */ 00121 00122 /* AES encryption/decryption using polling ***********************************/ 00123 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); 00124 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); 00125 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Finish(CRYP_HandleTypeDef *hcryp, uint32_t Size, uint8_t *AuthTag, uint32_t Timeout); 00126 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); 00127 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); 00128 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Finish(CRYP_HandleTypeDef *hcryp, uint8_t *AuthTag, uint32_t Timeout); 00129 00130 /* AES encryption/decryption using interrupt *********************************/ 00131 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); 00132 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); 00133 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); 00134 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); 00135 00136 /* AES encryption/decryption using DMA ***************************************/ 00137 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); 00138 HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); 00139 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); 00140 HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); 00141 00142 /** 00143 * @} 00144 */ 00145 00146 /** @addtogroup CRYPEx_Exported_Functions_Group2 00147 * @{ 00148 */ 00149 00150 void HAL_CRYPEx_GCMCCM_IRQHandler(CRYP_HandleTypeDef *hcryp); 00151 00152 /** 00153 * @} 00154 */ 00155 00156 /** 00157 * @} 00158 */ 00159 00160 00161 /* Private types -------------------------------------------------------------*/ 00162 /** @defgroup CRYPEx_Private_Types CRYPEx Private Types 00163 * @{ 00164 */ 00165 00166 /** 00167 * @} 00168 */ 00169 00170 /* Private variables ---------------------------------------------------------*/ 00171 /** @defgroup CRYPEx_Private_Variables CRYPEx Private Variables 00172 * @{ 00173 */ 00174 00175 /** 00176 * @} 00177 */ 00178 00179 /* Private constants ---------------------------------------------------------*/ 00180 /** @defgroup CRYPEx_Private_Constants CRYPEx Private Constants 00181 * @{ 00182 */ 00183 00184 /** 00185 * @} 00186 */ 00187 00188 /* Private macros ------------------------------------------------------------*/ 00189 /** @defgroup CRYPEx_Private_Macros CRYPEx Private Macros 00190 * @{ 00191 */ 00192 00193 /** 00194 * @} 00195 */ 00196 00197 /* Private functions ---------------------------------------------------------*/ 00198 /** @defgroup CRYPEx_Private_Functions CRYPEx Private Functions 00199 * @{ 00200 */ 00201 00202 /** 00203 * @} 00204 */ 00205 00206 #endif /* CRYP */ 00207 00208 #if defined (AES) 00209 00210 /** @addtogroup CRYPEx_Exported_Functions 00211 * @{ 00212 */ 00213 00214 /** @addtogroup CRYPEx_Exported_Functions_Group1 00215 * @{ 00216 */ 00217 00218 /* CallBack functions ********************************************************/ 00219 void HAL_CRYPEx_ComputationCpltCallback(CRYP_HandleTypeDef *hcryp); 00220 00221 /** 00222 * @} 00223 */ 00224 00225 /** @addtogroup CRYPEx_Exported_Functions_Group2 00226 * @{ 00227 */ 00228 00229 /* AES encryption/decryption processing functions ****************************/ 00230 HAL_StatusTypeDef HAL_CRYPEx_AES(CRYP_HandleTypeDef *hcryp, uint8_t *pInputData, uint16_t Size, uint8_t *pOutputData, uint32_t Timeout); 00231 HAL_StatusTypeDef HAL_CRYPEx_AES_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pInputData, uint16_t Size, uint8_t *pOutputData); 00232 HAL_StatusTypeDef HAL_CRYPEx_AES_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pInputData, uint16_t Size, uint8_t *pOutputData); 00233 00234 /* AES encryption/decryption/authentication processing functions *************/ 00235 HAL_StatusTypeDef HAL_CRYPEx_AES_Auth(CRYP_HandleTypeDef *hcryp, uint8_t *pInputData, uint64_t Size, uint8_t *pOutputData, uint32_t Timeout); 00236 HAL_StatusTypeDef HAL_CRYPEx_AES_Auth_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pInputData, uint64_t Size, uint8_t *pOutputData); 00237 HAL_StatusTypeDef HAL_CRYPEx_AES_Auth_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pInputData, uint64_t Size, uint8_t *pOutputData); 00238 00239 /** 00240 * @} 00241 */ 00242 00243 /** @addtogroup CRYPEx_Exported_Functions_Group3 00244 * @{ 00245 */ 00246 00247 /* AES suspension/resumption functions ***************************************/ 00248 void HAL_CRYPEx_Read_IVRegisters(CRYP_HandleTypeDef *hcryp, uint8_t* Output); 00249 void HAL_CRYPEx_Write_IVRegisters(CRYP_HandleTypeDef *hcryp, uint8_t* Input); 00250 void HAL_CRYPEx_Read_SuspendRegisters(CRYP_HandleTypeDef *hcryp, uint8_t* Output); 00251 void HAL_CRYPEx_Write_SuspendRegisters(CRYP_HandleTypeDef *hcryp, uint8_t* Input); 00252 void HAL_CRYPEx_Read_KeyRegisters(CRYP_HandleTypeDef *hcryp, uint8_t* Output, uint32_t KeySize); 00253 void HAL_CRYPEx_Write_KeyRegisters(CRYP_HandleTypeDef *hcryp, uint8_t* Input, uint32_t KeySize); 00254 void HAL_CRYPEx_Read_ControlRegister(CRYP_HandleTypeDef *hcryp, uint8_t* Output); 00255 void HAL_CRYPEx_Write_ControlRegister(CRYP_HandleTypeDef *hcryp, uint8_t* Input); 00256 void HAL_CRYPEx_ProcessSuspend(CRYP_HandleTypeDef *hcryp); 00257 00258 /** 00259 * @} 00260 */ 00261 00262 00263 /** 00264 * @} 00265 */ 00266 00267 /* Private functions -----------------------------------------------------------*/ 00268 /** @addtogroup CRYPEx_Private_Functions CRYPEx Private Functions 00269 * @{ 00270 */ 00271 HAL_StatusTypeDef CRYP_AES_Auth_IT(CRYP_HandleTypeDef *hcryp); 00272 00273 /** 00274 * @} 00275 */ 00276 00277 #endif /* AES */ 00278 00279 /** 00280 * @} 00281 */ 00282 00283 /** 00284 * @} 00285 */ 00286 00287 #ifdef __cplusplus 00288 } 00289 #endif 00290 00291 #endif /* __STM32F4xx_HAL_CRYP_EX_H */ 00292 00293 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/