The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_NUCLEO_F413ZH/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_cryp.h@160:5571c4ff569f, 2018-01-17 (annotated)
- Committer:
- Anna Bridge
- Date:
- Wed Jan 17 16:13:02 2018 +0000
- Revision:
- 160:5571c4ff569f
- Child:
- 163:e59c8e839560
mbed library. Release version 158
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
160:5571c4ff569f | 1 | /** |
Anna Bridge |
160:5571c4ff569f | 2 | ****************************************************************************** |
Anna Bridge |
160:5571c4ff569f | 3 | * @file stm32f4xx_hal_cryp.h |
Anna Bridge |
160:5571c4ff569f | 4 | * @author MCD Application Team |
Anna Bridge |
160:5571c4ff569f | 5 | * @version V1.7.1 |
Anna Bridge |
160:5571c4ff569f | 6 | * @date 14-April-2017 |
Anna Bridge |
160:5571c4ff569f | 7 | * @brief Header file of CRYP HAL module. |
Anna Bridge |
160:5571c4ff569f | 8 | ****************************************************************************** |
Anna Bridge |
160:5571c4ff569f | 9 | * @attention |
Anna Bridge |
160:5571c4ff569f | 10 | * |
Anna Bridge |
160:5571c4ff569f | 11 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
Anna Bridge |
160:5571c4ff569f | 12 | * |
Anna Bridge |
160:5571c4ff569f | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Anna Bridge |
160:5571c4ff569f | 14 | * are permitted provided that the following conditions are met: |
Anna Bridge |
160:5571c4ff569f | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Anna Bridge |
160:5571c4ff569f | 16 | * this list of conditions and the following disclaimer. |
Anna Bridge |
160:5571c4ff569f | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Anna Bridge |
160:5571c4ff569f | 18 | * this list of conditions and the following disclaimer in the documentation |
Anna Bridge |
160:5571c4ff569f | 19 | * and/or other materials provided with the distribution. |
Anna Bridge |
160:5571c4ff569f | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Anna Bridge |
160:5571c4ff569f | 21 | * may be used to endorse or promote products derived from this software |
Anna Bridge |
160:5571c4ff569f | 22 | * without specific prior written permission. |
Anna Bridge |
160:5571c4ff569f | 23 | * |
Anna Bridge |
160:5571c4ff569f | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Anna Bridge |
160:5571c4ff569f | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Anna Bridge |
160:5571c4ff569f | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Anna Bridge |
160:5571c4ff569f | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Anna Bridge |
160:5571c4ff569f | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Anna Bridge |
160:5571c4ff569f | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Anna Bridge |
160:5571c4ff569f | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Anna Bridge |
160:5571c4ff569f | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Anna Bridge |
160:5571c4ff569f | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Anna Bridge |
160:5571c4ff569f | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Anna Bridge |
160:5571c4ff569f | 34 | * |
Anna Bridge |
160:5571c4ff569f | 35 | ****************************************************************************** |
Anna Bridge |
160:5571c4ff569f | 36 | */ |
Anna Bridge |
160:5571c4ff569f | 37 | |
Anna Bridge |
160:5571c4ff569f | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 39 | #ifndef __STM32F4xx_HAL_CRYP_H |
Anna Bridge |
160:5571c4ff569f | 40 | #define __STM32F4xx_HAL_CRYP_H |
Anna Bridge |
160:5571c4ff569f | 41 | |
Anna Bridge |
160:5571c4ff569f | 42 | #ifdef __cplusplus |
Anna Bridge |
160:5571c4ff569f | 43 | extern "C" { |
Anna Bridge |
160:5571c4ff569f | 44 | #endif |
Anna Bridge |
160:5571c4ff569f | 45 | |
Anna Bridge |
160:5571c4ff569f | 46 | /* Includes ------------------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 47 | #include "stm32f4xx_hal_def.h" |
Anna Bridge |
160:5571c4ff569f | 48 | |
Anna Bridge |
160:5571c4ff569f | 49 | |
Anna Bridge |
160:5571c4ff569f | 50 | #if defined(CRYP) |
Anna Bridge |
160:5571c4ff569f | 51 | |
Anna Bridge |
160:5571c4ff569f | 52 | /** @addtogroup STM32F4xx_HAL_Driver |
Anna Bridge |
160:5571c4ff569f | 53 | * @{ |
Anna Bridge |
160:5571c4ff569f | 54 | */ |
Anna Bridge |
160:5571c4ff569f | 55 | |
Anna Bridge |
160:5571c4ff569f | 56 | /** @addtogroup CRYP |
Anna Bridge |
160:5571c4ff569f | 57 | * @{ |
Anna Bridge |
160:5571c4ff569f | 58 | */ |
Anna Bridge |
160:5571c4ff569f | 59 | |
Anna Bridge |
160:5571c4ff569f | 60 | /* Exported types ------------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 61 | |
Anna Bridge |
160:5571c4ff569f | 62 | /** @defgroup CRYP_Exported_Types CRYP Exported Types |
Anna Bridge |
160:5571c4ff569f | 63 | * @{ |
Anna Bridge |
160:5571c4ff569f | 64 | */ |
Anna Bridge |
160:5571c4ff569f | 65 | |
Anna Bridge |
160:5571c4ff569f | 66 | /** @defgroup CRYP_Exported_Types_Group1 CRYP Configuration Structure definition |
Anna Bridge |
160:5571c4ff569f | 67 | * @{ |
Anna Bridge |
160:5571c4ff569f | 68 | */ |
Anna Bridge |
160:5571c4ff569f | 69 | |
Anna Bridge |
160:5571c4ff569f | 70 | typedef struct |
Anna Bridge |
160:5571c4ff569f | 71 | { |
Anna Bridge |
160:5571c4ff569f | 72 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
Anna Bridge |
160:5571c4ff569f | 73 | This parameter can be a value of @ref CRYP_Data_Type */ |
Anna Bridge |
160:5571c4ff569f | 74 | |
Anna Bridge |
160:5571c4ff569f | 75 | uint32_t KeySize; /*!< Used only in AES mode only : 128, 192 or 256 bit key length. |
Anna Bridge |
160:5571c4ff569f | 76 | This parameter can be a value of @ref CRYP_Key_Size */ |
Anna Bridge |
160:5571c4ff569f | 77 | |
Anna Bridge |
160:5571c4ff569f | 78 | uint8_t* pKey; /*!< The key used for encryption/decryption */ |
Anna Bridge |
160:5571c4ff569f | 79 | |
Anna Bridge |
160:5571c4ff569f | 80 | uint8_t* pInitVect; /*!< The initialization vector used also as initialization |
Anna Bridge |
160:5571c4ff569f | 81 | counter in CTR mode */ |
Anna Bridge |
160:5571c4ff569f | 82 | |
Anna Bridge |
160:5571c4ff569f | 83 | uint8_t IVSize; /*!< The size of initialization vector. |
Anna Bridge |
160:5571c4ff569f | 84 | This parameter (called nonce size in CCM) is used only |
Anna Bridge |
160:5571c4ff569f | 85 | in AES-128/192/256 encryption/decryption CCM mode */ |
Anna Bridge |
160:5571c4ff569f | 86 | |
Anna Bridge |
160:5571c4ff569f | 87 | uint8_t TagSize; /*!< The size of returned authentication TAG. |
Anna Bridge |
160:5571c4ff569f | 88 | This parameter is used only in AES-128/192/256 |
Anna Bridge |
160:5571c4ff569f | 89 | encryption/decryption CCM mode */ |
Anna Bridge |
160:5571c4ff569f | 90 | |
Anna Bridge |
160:5571c4ff569f | 91 | uint8_t* Header; /*!< The header used in GCM and CCM modes */ |
Anna Bridge |
160:5571c4ff569f | 92 | |
Anna Bridge |
160:5571c4ff569f | 93 | uint32_t HeaderSize; /*!< The size of header buffer in bytes */ |
Anna Bridge |
160:5571c4ff569f | 94 | |
Anna Bridge |
160:5571c4ff569f | 95 | uint8_t* pScratch; /*!< Scratch buffer used to append the header. It's size must be equal to header size + 21 bytes. |
Anna Bridge |
160:5571c4ff569f | 96 | This parameter is used only in AES-128/192/256 encryption/decryption CCM mode */ |
Anna Bridge |
160:5571c4ff569f | 97 | }CRYP_InitTypeDef; |
Anna Bridge |
160:5571c4ff569f | 98 | |
Anna Bridge |
160:5571c4ff569f | 99 | /** |
Anna Bridge |
160:5571c4ff569f | 100 | * @} |
Anna Bridge |
160:5571c4ff569f | 101 | */ |
Anna Bridge |
160:5571c4ff569f | 102 | |
Anna Bridge |
160:5571c4ff569f | 103 | /** @defgroup CRYP_Exported_Types_Group2 CRYP State structures definition |
Anna Bridge |
160:5571c4ff569f | 104 | * @{ |
Anna Bridge |
160:5571c4ff569f | 105 | */ |
Anna Bridge |
160:5571c4ff569f | 106 | |
Anna Bridge |
160:5571c4ff569f | 107 | |
Anna Bridge |
160:5571c4ff569f | 108 | typedef enum |
Anna Bridge |
160:5571c4ff569f | 109 | { |
Anna Bridge |
160:5571c4ff569f | 110 | HAL_CRYP_STATE_RESET = 0x00U, /*!< CRYP not yet initialized or disabled */ |
Anna Bridge |
160:5571c4ff569f | 111 | HAL_CRYP_STATE_READY = 0x01U, /*!< CRYP initialized and ready for use */ |
Anna Bridge |
160:5571c4ff569f | 112 | HAL_CRYP_STATE_BUSY = 0x02U, /*!< CRYP internal processing is ongoing */ |
Anna Bridge |
160:5571c4ff569f | 113 | HAL_CRYP_STATE_TIMEOUT = 0x03U, /*!< CRYP timeout state */ |
Anna Bridge |
160:5571c4ff569f | 114 | HAL_CRYP_STATE_ERROR = 0x04U /*!< CRYP error state */ |
Anna Bridge |
160:5571c4ff569f | 115 | }HAL_CRYP_STATETypeDef; |
Anna Bridge |
160:5571c4ff569f | 116 | |
Anna Bridge |
160:5571c4ff569f | 117 | /** |
Anna Bridge |
160:5571c4ff569f | 118 | * @} |
Anna Bridge |
160:5571c4ff569f | 119 | */ |
Anna Bridge |
160:5571c4ff569f | 120 | |
Anna Bridge |
160:5571c4ff569f | 121 | /** @defgroup CRYP_Exported_Types_Group3 CRYP phase structures definition |
Anna Bridge |
160:5571c4ff569f | 122 | * @{ |
Anna Bridge |
160:5571c4ff569f | 123 | */ |
Anna Bridge |
160:5571c4ff569f | 124 | |
Anna Bridge |
160:5571c4ff569f | 125 | |
Anna Bridge |
160:5571c4ff569f | 126 | typedef enum |
Anna Bridge |
160:5571c4ff569f | 127 | { |
Anna Bridge |
160:5571c4ff569f | 128 | HAL_CRYP_PHASE_READY = 0x01U, /*!< CRYP peripheral is ready for initialization. */ |
Anna Bridge |
160:5571c4ff569f | 129 | HAL_CRYP_PHASE_PROCESS = 0x02U, /*!< CRYP peripheral is in processing phase */ |
Anna Bridge |
160:5571c4ff569f | 130 | HAL_CRYP_PHASE_FINAL = 0x03U /*!< CRYP peripheral is in final phase |
Anna Bridge |
160:5571c4ff569f | 131 | This is relevant only with CCM and GCM modes */ |
Anna Bridge |
160:5571c4ff569f | 132 | }HAL_PhaseTypeDef; |
Anna Bridge |
160:5571c4ff569f | 133 | |
Anna Bridge |
160:5571c4ff569f | 134 | /** |
Anna Bridge |
160:5571c4ff569f | 135 | * @} |
Anna Bridge |
160:5571c4ff569f | 136 | */ |
Anna Bridge |
160:5571c4ff569f | 137 | |
Anna Bridge |
160:5571c4ff569f | 138 | /** @defgroup CRYP_Exported_Types_Group4 CRYP handle Structure definition |
Anna Bridge |
160:5571c4ff569f | 139 | * @{ |
Anna Bridge |
160:5571c4ff569f | 140 | */ |
Anna Bridge |
160:5571c4ff569f | 141 | |
Anna Bridge |
160:5571c4ff569f | 142 | typedef struct |
Anna Bridge |
160:5571c4ff569f | 143 | { |
Anna Bridge |
160:5571c4ff569f | 144 | CRYP_TypeDef *Instance; /*!< CRYP registers base address */ |
Anna Bridge |
160:5571c4ff569f | 145 | |
Anna Bridge |
160:5571c4ff569f | 146 | CRYP_InitTypeDef Init; /*!< CRYP required parameters */ |
Anna Bridge |
160:5571c4ff569f | 147 | |
Anna Bridge |
160:5571c4ff569f | 148 | uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
Anna Bridge |
160:5571c4ff569f | 149 | |
Anna Bridge |
160:5571c4ff569f | 150 | uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
Anna Bridge |
160:5571c4ff569f | 151 | |
Anna Bridge |
160:5571c4ff569f | 152 | __IO uint16_t CrypInCount; /*!< Counter of inputed data */ |
Anna Bridge |
160:5571c4ff569f | 153 | |
Anna Bridge |
160:5571c4ff569f | 154 | __IO uint16_t CrypOutCount; /*!< Counter of output data */ |
Anna Bridge |
160:5571c4ff569f | 155 | |
Anna Bridge |
160:5571c4ff569f | 156 | HAL_StatusTypeDef Status; /*!< CRYP peripheral status */ |
Anna Bridge |
160:5571c4ff569f | 157 | |
Anna Bridge |
160:5571c4ff569f | 158 | HAL_PhaseTypeDef Phase; /*!< CRYP peripheral phase */ |
Anna Bridge |
160:5571c4ff569f | 159 | |
Anna Bridge |
160:5571c4ff569f | 160 | DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ |
Anna Bridge |
160:5571c4ff569f | 161 | |
Anna Bridge |
160:5571c4ff569f | 162 | DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ |
Anna Bridge |
160:5571c4ff569f | 163 | |
Anna Bridge |
160:5571c4ff569f | 164 | HAL_LockTypeDef Lock; /*!< CRYP locking object */ |
Anna Bridge |
160:5571c4ff569f | 165 | |
Anna Bridge |
160:5571c4ff569f | 166 | __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ |
Anna Bridge |
160:5571c4ff569f | 167 | }CRYP_HandleTypeDef; |
Anna Bridge |
160:5571c4ff569f | 168 | |
Anna Bridge |
160:5571c4ff569f | 169 | /** |
Anna Bridge |
160:5571c4ff569f | 170 | * @} |
Anna Bridge |
160:5571c4ff569f | 171 | */ |
Anna Bridge |
160:5571c4ff569f | 172 | |
Anna Bridge |
160:5571c4ff569f | 173 | /** |
Anna Bridge |
160:5571c4ff569f | 174 | * @} |
Anna Bridge |
160:5571c4ff569f | 175 | */ |
Anna Bridge |
160:5571c4ff569f | 176 | |
Anna Bridge |
160:5571c4ff569f | 177 | /* Exported constants --------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 178 | /** @defgroup CRYP_Exported_Constants CRYP Exported Constants |
Anna Bridge |
160:5571c4ff569f | 179 | * @{ |
Anna Bridge |
160:5571c4ff569f | 180 | */ |
Anna Bridge |
160:5571c4ff569f | 181 | |
Anna Bridge |
160:5571c4ff569f | 182 | /** @defgroup CRYP_Key_Size CRYP Key Size |
Anna Bridge |
160:5571c4ff569f | 183 | * @{ |
Anna Bridge |
160:5571c4ff569f | 184 | */ |
Anna Bridge |
160:5571c4ff569f | 185 | #define CRYP_KEYSIZE_128B 0x00000000U |
Anna Bridge |
160:5571c4ff569f | 186 | #define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0 |
Anna Bridge |
160:5571c4ff569f | 187 | #define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1 |
Anna Bridge |
160:5571c4ff569f | 188 | /** |
Anna Bridge |
160:5571c4ff569f | 189 | * @} |
Anna Bridge |
160:5571c4ff569f | 190 | */ |
Anna Bridge |
160:5571c4ff569f | 191 | |
Anna Bridge |
160:5571c4ff569f | 192 | /** @defgroup CRYP_Data_Type CRYP Data Type |
Anna Bridge |
160:5571c4ff569f | 193 | * @{ |
Anna Bridge |
160:5571c4ff569f | 194 | */ |
Anna Bridge |
160:5571c4ff569f | 195 | #define CRYP_DATATYPE_32B 0x00000000U |
Anna Bridge |
160:5571c4ff569f | 196 | #define CRYP_DATATYPE_16B CRYP_CR_DATATYPE_0 |
Anna Bridge |
160:5571c4ff569f | 197 | #define CRYP_DATATYPE_8B CRYP_CR_DATATYPE_1 |
Anna Bridge |
160:5571c4ff569f | 198 | #define CRYP_DATATYPE_1B CRYP_CR_DATATYPE |
Anna Bridge |
160:5571c4ff569f | 199 | /** |
Anna Bridge |
160:5571c4ff569f | 200 | * @} |
Anna Bridge |
160:5571c4ff569f | 201 | */ |
Anna Bridge |
160:5571c4ff569f | 202 | |
Anna Bridge |
160:5571c4ff569f | 203 | /** @defgroup CRYP_Exported_Constants_Group3 CRYP CRYP_AlgoModeDirection |
Anna Bridge |
160:5571c4ff569f | 204 | * @{ |
Anna Bridge |
160:5571c4ff569f | 205 | */ |
Anna Bridge |
160:5571c4ff569f | 206 | #define CRYP_CR_ALGOMODE_DIRECTION 0x0008003CU |
Anna Bridge |
160:5571c4ff569f | 207 | #define CRYP_CR_ALGOMODE_TDES_ECB_ENCRYPT 0x00000000U |
Anna Bridge |
160:5571c4ff569f | 208 | #define CRYP_CR_ALGOMODE_TDES_ECB_DECRYPT 0x00000004U |
Anna Bridge |
160:5571c4ff569f | 209 | #define CRYP_CR_ALGOMODE_TDES_CBC_ENCRYPT 0x00000008U |
Anna Bridge |
160:5571c4ff569f | 210 | #define CRYP_CR_ALGOMODE_TDES_CBC_DECRYPT 0x0000000CU |
Anna Bridge |
160:5571c4ff569f | 211 | #define CRYP_CR_ALGOMODE_DES_ECB_ENCRYPT 0x00000010U |
Anna Bridge |
160:5571c4ff569f | 212 | #define CRYP_CR_ALGOMODE_DES_ECB_DECRYPT 0x00000014U |
Anna Bridge |
160:5571c4ff569f | 213 | #define CRYP_CR_ALGOMODE_DES_CBC_ENCRYPT 0x00000018U |
Anna Bridge |
160:5571c4ff569f | 214 | #define CRYP_CR_ALGOMODE_DES_CBC_DECRYPT 0x0000001CU |
Anna Bridge |
160:5571c4ff569f | 215 | #define CRYP_CR_ALGOMODE_AES_ECB_ENCRYPT 0x00000020U |
Anna Bridge |
160:5571c4ff569f | 216 | #define CRYP_CR_ALGOMODE_AES_ECB_DECRYPT 0x00000024U |
Anna Bridge |
160:5571c4ff569f | 217 | #define CRYP_CR_ALGOMODE_AES_CBC_ENCRYPT 0x00000028U |
Anna Bridge |
160:5571c4ff569f | 218 | #define CRYP_CR_ALGOMODE_AES_CBC_DECRYPT 0x0000002CU |
Anna Bridge |
160:5571c4ff569f | 219 | #define CRYP_CR_ALGOMODE_AES_CTR_ENCRYPT 0x00000030U |
Anna Bridge |
160:5571c4ff569f | 220 | #define CRYP_CR_ALGOMODE_AES_CTR_DECRYPT 0x00000034U |
Anna Bridge |
160:5571c4ff569f | 221 | /** |
Anna Bridge |
160:5571c4ff569f | 222 | * @} |
Anna Bridge |
160:5571c4ff569f | 223 | */ |
Anna Bridge |
160:5571c4ff569f | 224 | |
Anna Bridge |
160:5571c4ff569f | 225 | /** @defgroup CRYP_Exported_Constants_Group4 CRYP CRYP_Interrupt |
Anna Bridge |
160:5571c4ff569f | 226 | * @{ |
Anna Bridge |
160:5571c4ff569f | 227 | */ |
Anna Bridge |
160:5571c4ff569f | 228 | #define CRYP_IT_INI ((uint32_t)CRYP_IMSCR_INIM) /*!< Input FIFO Interrupt */ |
Anna Bridge |
160:5571c4ff569f | 229 | #define CRYP_IT_OUTI ((uint32_t)CRYP_IMSCR_OUTIM) /*!< Output FIFO Interrupt */ |
Anna Bridge |
160:5571c4ff569f | 230 | /** |
Anna Bridge |
160:5571c4ff569f | 231 | * @} |
Anna Bridge |
160:5571c4ff569f | 232 | */ |
Anna Bridge |
160:5571c4ff569f | 233 | |
Anna Bridge |
160:5571c4ff569f | 234 | /** @defgroup CRYP_Exported_Constants_Group5 CRYP CRYP_Flags |
Anna Bridge |
160:5571c4ff569f | 235 | * @{ |
Anna Bridge |
160:5571c4ff569f | 236 | */ |
Anna Bridge |
160:5571c4ff569f | 237 | #define CRYP_FLAG_BUSY 0x00000010U /*!< The CRYP core is currently |
Anna Bridge |
160:5571c4ff569f | 238 | processing a block of data |
Anna Bridge |
160:5571c4ff569f | 239 | or a key preparation (for |
Anna Bridge |
160:5571c4ff569f | 240 | AES decryption). */ |
Anna Bridge |
160:5571c4ff569f | 241 | #define CRYP_FLAG_IFEM 0x00000001U /*!< Input FIFO is empty */ |
Anna Bridge |
160:5571c4ff569f | 242 | #define CRYP_FLAG_IFNF 0x00000002U /*!< Input FIFO is not Full */ |
Anna Bridge |
160:5571c4ff569f | 243 | #define CRYP_FLAG_OFNE 0x00000004U /*!< Output FIFO is not empty */ |
Anna Bridge |
160:5571c4ff569f | 244 | #define CRYP_FLAG_OFFU 0x00000008U /*!< Output FIFO is Full */ |
Anna Bridge |
160:5571c4ff569f | 245 | #define CRYP_FLAG_OUTRIS 0x01000002U /*!< Output FIFO service raw |
Anna Bridge |
160:5571c4ff569f | 246 | interrupt status */ |
Anna Bridge |
160:5571c4ff569f | 247 | #define CRYP_FLAG_INRIS 0x01000001U /*!< Input FIFO service raw |
Anna Bridge |
160:5571c4ff569f | 248 | interrupt status */ |
Anna Bridge |
160:5571c4ff569f | 249 | /** |
Anna Bridge |
160:5571c4ff569f | 250 | * @} |
Anna Bridge |
160:5571c4ff569f | 251 | */ |
Anna Bridge |
160:5571c4ff569f | 252 | |
Anna Bridge |
160:5571c4ff569f | 253 | /** |
Anna Bridge |
160:5571c4ff569f | 254 | * @} |
Anna Bridge |
160:5571c4ff569f | 255 | */ |
Anna Bridge |
160:5571c4ff569f | 256 | |
Anna Bridge |
160:5571c4ff569f | 257 | /* Exported macro ------------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 258 | /** @defgroup CRYP_Exported_Macros CRYP Exported Macros |
Anna Bridge |
160:5571c4ff569f | 259 | * @{ |
Anna Bridge |
160:5571c4ff569f | 260 | */ |
Anna Bridge |
160:5571c4ff569f | 261 | |
Anna Bridge |
160:5571c4ff569f | 262 | /** @brief Reset CRYP handle state |
Anna Bridge |
160:5571c4ff569f | 263 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 264 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 265 | */ |
Anna Bridge |
160:5571c4ff569f | 266 | #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) |
Anna Bridge |
160:5571c4ff569f | 267 | |
Anna Bridge |
160:5571c4ff569f | 268 | /** |
Anna Bridge |
160:5571c4ff569f | 269 | * @brief Enable/Disable the CRYP peripheral. |
Anna Bridge |
160:5571c4ff569f | 270 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 271 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 272 | */ |
Anna Bridge |
160:5571c4ff569f | 273 | #define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRYP_CR_CRYPEN) |
Anna Bridge |
160:5571c4ff569f | 274 | #define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~CRYP_CR_CRYPEN) |
Anna Bridge |
160:5571c4ff569f | 275 | |
Anna Bridge |
160:5571c4ff569f | 276 | /** |
Anna Bridge |
160:5571c4ff569f | 277 | * @brief Flush the data FIFO. |
Anna Bridge |
160:5571c4ff569f | 278 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 279 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 280 | */ |
Anna Bridge |
160:5571c4ff569f | 281 | #define __HAL_CRYP_FIFO_FLUSH(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRYP_CR_FFLUSH) |
Anna Bridge |
160:5571c4ff569f | 282 | |
Anna Bridge |
160:5571c4ff569f | 283 | /** |
Anna Bridge |
160:5571c4ff569f | 284 | * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC. |
Anna Bridge |
160:5571c4ff569f | 285 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 286 | * @param MODE: The algorithm mode. |
Anna Bridge |
160:5571c4ff569f | 287 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 288 | */ |
Anna Bridge |
160:5571c4ff569f | 289 | #define __HAL_CRYP_SET_MODE(__HANDLE__, MODE) ((__HANDLE__)->Instance->CR |= (uint32_t)(MODE)) |
Anna Bridge |
160:5571c4ff569f | 290 | |
Anna Bridge |
160:5571c4ff569f | 291 | /** @brief Check whether the specified CRYP flag is set or not. |
Anna Bridge |
160:5571c4ff569f | 292 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 293 | * @param __FLAG__: specifies the flag to check. |
Anna Bridge |
160:5571c4ff569f | 294 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 295 | * @arg CRYP_FLAG_BUSY: The CRYP core is currently processing a block of data |
Anna Bridge |
160:5571c4ff569f | 296 | * or a key preparation (for AES decryption). |
Anna Bridge |
160:5571c4ff569f | 297 | * @arg CRYP_FLAG_IFEM: Input FIFO is empty |
Anna Bridge |
160:5571c4ff569f | 298 | * @arg CRYP_FLAG_IFNF: Input FIFO is not full |
Anna Bridge |
160:5571c4ff569f | 299 | * @arg CRYP_FLAG_INRIS: Input FIFO service raw interrupt is pending |
Anna Bridge |
160:5571c4ff569f | 300 | * @arg CRYP_FLAG_OFNE: Output FIFO is not empty |
Anna Bridge |
160:5571c4ff569f | 301 | * @arg CRYP_FLAG_OFFU: Output FIFO is full |
Anna Bridge |
160:5571c4ff569f | 302 | * @arg CRYP_FLAG_OUTRIS: Input FIFO service raw interrupt is pending |
Anna Bridge |
160:5571c4ff569f | 303 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
Anna Bridge |
160:5571c4ff569f | 304 | */ |
Anna Bridge |
160:5571c4ff569f | 305 | |
Anna Bridge |
160:5571c4ff569f | 306 | #define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 24U)) == 0x01U)?((((__HANDLE__)->Instance->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)): \ |
Anna Bridge |
160:5571c4ff569f | 307 | ((((__HANDLE__)->Instance->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK))) |
Anna Bridge |
160:5571c4ff569f | 308 | |
Anna Bridge |
160:5571c4ff569f | 309 | /** @brief Check whether the specified CRYP interrupt is set or not. |
Anna Bridge |
160:5571c4ff569f | 310 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 311 | * @param __INTERRUPT__: specifies the interrupt to check. |
Anna Bridge |
160:5571c4ff569f | 312 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 313 | * @arg CRYP_IT_INRIS: Input FIFO service raw interrupt is pending |
Anna Bridge |
160:5571c4ff569f | 314 | * @arg CRYP_IT_OUTRIS: Output FIFO service raw interrupt is pending |
Anna Bridge |
160:5571c4ff569f | 315 | * @retval The new state of __INTERRUPT__ (TRUE or FALSE). |
Anna Bridge |
160:5571c4ff569f | 316 | */ |
Anna Bridge |
160:5571c4ff569f | 317 | #define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->MISR & (__INTERRUPT__)) == (__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 318 | |
Anna Bridge |
160:5571c4ff569f | 319 | /** |
Anna Bridge |
160:5571c4ff569f | 320 | * @brief Enable the CRYP interrupt. |
Anna Bridge |
160:5571c4ff569f | 321 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 322 | * @param __INTERRUPT__: CRYP Interrupt. |
Anna Bridge |
160:5571c4ff569f | 323 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 324 | */ |
Anna Bridge |
160:5571c4ff569f | 325 | #define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) |= (__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 326 | |
Anna Bridge |
160:5571c4ff569f | 327 | /** |
Anna Bridge |
160:5571c4ff569f | 328 | * @brief Disable the CRYP interrupt. |
Anna Bridge |
160:5571c4ff569f | 329 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 330 | * @param __INTERRUPT__: CRYP interrupt. |
Anna Bridge |
160:5571c4ff569f | 331 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 332 | */ |
Anna Bridge |
160:5571c4ff569f | 333 | #define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IMSCR) &= ~(__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 334 | |
Anna Bridge |
160:5571c4ff569f | 335 | /** |
Anna Bridge |
160:5571c4ff569f | 336 | * @} |
Anna Bridge |
160:5571c4ff569f | 337 | */ |
Anna Bridge |
160:5571c4ff569f | 338 | |
Anna Bridge |
160:5571c4ff569f | 339 | /* Include CRYP HAL Extension module */ |
Anna Bridge |
160:5571c4ff569f | 340 | #include "stm32f4xx_hal_cryp_ex.h" |
Anna Bridge |
160:5571c4ff569f | 341 | |
Anna Bridge |
160:5571c4ff569f | 342 | /* Exported functions --------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 343 | /** @defgroup CRYP_Exported_Functions CRYP Exported Functions |
Anna Bridge |
160:5571c4ff569f | 344 | * @{ |
Anna Bridge |
160:5571c4ff569f | 345 | */ |
Anna Bridge |
160:5571c4ff569f | 346 | |
Anna Bridge |
160:5571c4ff569f | 347 | /** @addtogroup CRYP_Exported_Functions_Group1 |
Anna Bridge |
160:5571c4ff569f | 348 | * @{ |
Anna Bridge |
160:5571c4ff569f | 349 | */ |
Anna Bridge |
160:5571c4ff569f | 350 | HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 351 | HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 352 | void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 353 | void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 354 | /** |
Anna Bridge |
160:5571c4ff569f | 355 | * @} |
Anna Bridge |
160:5571c4ff569f | 356 | */ |
Anna Bridge |
160:5571c4ff569f | 357 | |
Anna Bridge |
160:5571c4ff569f | 358 | /** @addtogroup CRYP_Exported_Functions_Group2 |
Anna Bridge |
160:5571c4ff569f | 359 | * @{ |
Anna Bridge |
160:5571c4ff569f | 360 | */ |
Anna Bridge |
160:5571c4ff569f | 361 | /* AES encryption/decryption using polling ***********************************/ |
Anna Bridge |
160:5571c4ff569f | 362 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 363 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 364 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 365 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 366 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 367 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 368 | |
Anna Bridge |
160:5571c4ff569f | 369 | /* AES encryption/decryption using interrupt *********************************/ |
Anna Bridge |
160:5571c4ff569f | 370 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 371 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 372 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 373 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 374 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 375 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 376 | |
Anna Bridge |
160:5571c4ff569f | 377 | /* AES encryption/decryption using DMA ***************************************/ |
Anna Bridge |
160:5571c4ff569f | 378 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 379 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 380 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 381 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 382 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 383 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 384 | /** |
Anna Bridge |
160:5571c4ff569f | 385 | * @} |
Anna Bridge |
160:5571c4ff569f | 386 | */ |
Anna Bridge |
160:5571c4ff569f | 387 | |
Anna Bridge |
160:5571c4ff569f | 388 | /** @addtogroup CRYP_Exported_Functions_Group3 |
Anna Bridge |
160:5571c4ff569f | 389 | * @{ |
Anna Bridge |
160:5571c4ff569f | 390 | */ |
Anna Bridge |
160:5571c4ff569f | 391 | /* DES encryption/decryption using polling ***********************************/ |
Anna Bridge |
160:5571c4ff569f | 392 | HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 393 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 394 | HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 395 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 396 | |
Anna Bridge |
160:5571c4ff569f | 397 | /* DES encryption/decryption using interrupt *********************************/ |
Anna Bridge |
160:5571c4ff569f | 398 | HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 399 | HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 400 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 401 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 402 | |
Anna Bridge |
160:5571c4ff569f | 403 | /* DES encryption/decryption using DMA ***************************************/ |
Anna Bridge |
160:5571c4ff569f | 404 | HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 405 | HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 406 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 407 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 408 | /** |
Anna Bridge |
160:5571c4ff569f | 409 | * @} |
Anna Bridge |
160:5571c4ff569f | 410 | */ |
Anna Bridge |
160:5571c4ff569f | 411 | |
Anna Bridge |
160:5571c4ff569f | 412 | /** @addtogroup CRYP_Exported_Functions_Group4 |
Anna Bridge |
160:5571c4ff569f | 413 | * @{ |
Anna Bridge |
160:5571c4ff569f | 414 | */ |
Anna Bridge |
160:5571c4ff569f | 415 | /* TDES encryption/decryption using polling **********************************/ |
Anna Bridge |
160:5571c4ff569f | 416 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 417 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 418 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 419 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 420 | |
Anna Bridge |
160:5571c4ff569f | 421 | /* TDES encryption/decryption using interrupt ********************************/ |
Anna Bridge |
160:5571c4ff569f | 422 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 423 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 424 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 425 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 426 | |
Anna Bridge |
160:5571c4ff569f | 427 | /* TDES encryption/decryption using DMA **************************************/ |
Anna Bridge |
160:5571c4ff569f | 428 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 429 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 430 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 431 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 432 | /** |
Anna Bridge |
160:5571c4ff569f | 433 | * @} |
Anna Bridge |
160:5571c4ff569f | 434 | */ |
Anna Bridge |
160:5571c4ff569f | 435 | |
Anna Bridge |
160:5571c4ff569f | 436 | /** @addtogroup CRYP_Exported_Functions_Group5 |
Anna Bridge |
160:5571c4ff569f | 437 | * @{ |
Anna Bridge |
160:5571c4ff569f | 438 | */ |
Anna Bridge |
160:5571c4ff569f | 439 | void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 440 | void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 441 | void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 442 | /** |
Anna Bridge |
160:5571c4ff569f | 443 | * @} |
Anna Bridge |
160:5571c4ff569f | 444 | */ |
Anna Bridge |
160:5571c4ff569f | 445 | |
Anna Bridge |
160:5571c4ff569f | 446 | /** @addtogroup CRYP_Exported_Functions_Group6 |
Anna Bridge |
160:5571c4ff569f | 447 | * @{ |
Anna Bridge |
160:5571c4ff569f | 448 | */ |
Anna Bridge |
160:5571c4ff569f | 449 | void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 450 | /** |
Anna Bridge |
160:5571c4ff569f | 451 | * @} |
Anna Bridge |
160:5571c4ff569f | 452 | */ |
Anna Bridge |
160:5571c4ff569f | 453 | |
Anna Bridge |
160:5571c4ff569f | 454 | /** @addtogroup CRYP_Exported_Functions_Group7 |
Anna Bridge |
160:5571c4ff569f | 455 | * @{ |
Anna Bridge |
160:5571c4ff569f | 456 | */ |
Anna Bridge |
160:5571c4ff569f | 457 | HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 458 | /** |
Anna Bridge |
160:5571c4ff569f | 459 | * @} |
Anna Bridge |
160:5571c4ff569f | 460 | */ |
Anna Bridge |
160:5571c4ff569f | 461 | |
Anna Bridge |
160:5571c4ff569f | 462 | /** |
Anna Bridge |
160:5571c4ff569f | 463 | * @} |
Anna Bridge |
160:5571c4ff569f | 464 | */ |
Anna Bridge |
160:5571c4ff569f | 465 | |
Anna Bridge |
160:5571c4ff569f | 466 | /* Private types -------------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 467 | /** @defgroup CRYP_Private_Types CRYP Private Types |
Anna Bridge |
160:5571c4ff569f | 468 | * @{ |
Anna Bridge |
160:5571c4ff569f | 469 | */ |
Anna Bridge |
160:5571c4ff569f | 470 | |
Anna Bridge |
160:5571c4ff569f | 471 | /** |
Anna Bridge |
160:5571c4ff569f | 472 | * @} |
Anna Bridge |
160:5571c4ff569f | 473 | */ |
Anna Bridge |
160:5571c4ff569f | 474 | |
Anna Bridge |
160:5571c4ff569f | 475 | /* Private variables ---------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 476 | /** @defgroup CRYP_Private_Variables CRYP Private Variables |
Anna Bridge |
160:5571c4ff569f | 477 | * @{ |
Anna Bridge |
160:5571c4ff569f | 478 | */ |
Anna Bridge |
160:5571c4ff569f | 479 | |
Anna Bridge |
160:5571c4ff569f | 480 | /** |
Anna Bridge |
160:5571c4ff569f | 481 | * @} |
Anna Bridge |
160:5571c4ff569f | 482 | */ |
Anna Bridge |
160:5571c4ff569f | 483 | |
Anna Bridge |
160:5571c4ff569f | 484 | /* Private constants ---------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 485 | /** @defgroup CRYP_Private_Constants CRYP Private Constants |
Anna Bridge |
160:5571c4ff569f | 486 | * @{ |
Anna Bridge |
160:5571c4ff569f | 487 | */ |
Anna Bridge |
160:5571c4ff569f | 488 | #define CRYP_FLAG_MASK 0x0000001FU |
Anna Bridge |
160:5571c4ff569f | 489 | /** |
Anna Bridge |
160:5571c4ff569f | 490 | * @} |
Anna Bridge |
160:5571c4ff569f | 491 | */ |
Anna Bridge |
160:5571c4ff569f | 492 | |
Anna Bridge |
160:5571c4ff569f | 493 | /* Private macros ------------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 494 | /** @defgroup CRYP_Private_Macros CRYP Private Macros |
Anna Bridge |
160:5571c4ff569f | 495 | * @{ |
Anna Bridge |
160:5571c4ff569f | 496 | */ |
Anna Bridge |
160:5571c4ff569f | 497 | |
Anna Bridge |
160:5571c4ff569f | 498 | #define IS_CRYP_KEYSIZE(__KEYSIZE__) (((__KEYSIZE__) == CRYP_KEYSIZE_128B) || \ |
Anna Bridge |
160:5571c4ff569f | 499 | ((__KEYSIZE__) == CRYP_KEYSIZE_192B) || \ |
Anna Bridge |
160:5571c4ff569f | 500 | ((__KEYSIZE__) == CRYP_KEYSIZE_256B)) |
Anna Bridge |
160:5571c4ff569f | 501 | |
Anna Bridge |
160:5571c4ff569f | 502 | |
Anna Bridge |
160:5571c4ff569f | 503 | #define IS_CRYP_DATATYPE(__DATATYPE__) (((__DATATYPE__) == CRYP_DATATYPE_32B) || \ |
Anna Bridge |
160:5571c4ff569f | 504 | ((__DATATYPE__) == CRYP_DATATYPE_16B) || \ |
Anna Bridge |
160:5571c4ff569f | 505 | ((__DATATYPE__) == CRYP_DATATYPE_8B) || \ |
Anna Bridge |
160:5571c4ff569f | 506 | ((__DATATYPE__) == CRYP_DATATYPE_1B)) |
Anna Bridge |
160:5571c4ff569f | 507 | |
Anna Bridge |
160:5571c4ff569f | 508 | |
Anna Bridge |
160:5571c4ff569f | 509 | /** |
Anna Bridge |
160:5571c4ff569f | 510 | * @} |
Anna Bridge |
160:5571c4ff569f | 511 | */ |
Anna Bridge |
160:5571c4ff569f | 512 | |
Anna Bridge |
160:5571c4ff569f | 513 | /* Private functions ---------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 514 | /** @defgroup CRYP_Private_Functions CRYP Private Functions |
Anna Bridge |
160:5571c4ff569f | 515 | * @{ |
Anna Bridge |
160:5571c4ff569f | 516 | */ |
Anna Bridge |
160:5571c4ff569f | 517 | |
Anna Bridge |
160:5571c4ff569f | 518 | /** |
Anna Bridge |
160:5571c4ff569f | 519 | * @} |
Anna Bridge |
160:5571c4ff569f | 520 | */ |
Anna Bridge |
160:5571c4ff569f | 521 | |
Anna Bridge |
160:5571c4ff569f | 522 | #endif /* CRYP */ |
Anna Bridge |
160:5571c4ff569f | 523 | |
Anna Bridge |
160:5571c4ff569f | 524 | #if defined (AES) |
Anna Bridge |
160:5571c4ff569f | 525 | |
Anna Bridge |
160:5571c4ff569f | 526 | /** @addtogroup STM32F4xx_HAL_Driver |
Anna Bridge |
160:5571c4ff569f | 527 | * @{ |
Anna Bridge |
160:5571c4ff569f | 528 | */ |
Anna Bridge |
160:5571c4ff569f | 529 | |
Anna Bridge |
160:5571c4ff569f | 530 | /** @addtogroup CRYP |
Anna Bridge |
160:5571c4ff569f | 531 | * @{ |
Anna Bridge |
160:5571c4ff569f | 532 | */ |
Anna Bridge |
160:5571c4ff569f | 533 | |
Anna Bridge |
160:5571c4ff569f | 534 | /* Exported types ------------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 535 | /** @defgroup CRYP_Exported_Types CRYP Exported Types |
Anna Bridge |
160:5571c4ff569f | 536 | * @{ |
Anna Bridge |
160:5571c4ff569f | 537 | */ |
Anna Bridge |
160:5571c4ff569f | 538 | |
Anna Bridge |
160:5571c4ff569f | 539 | /** |
Anna Bridge |
160:5571c4ff569f | 540 | * @brief CRYP Configuration Structure definition |
Anna Bridge |
160:5571c4ff569f | 541 | */ |
Anna Bridge |
160:5571c4ff569f | 542 | typedef struct |
Anna Bridge |
160:5571c4ff569f | 543 | { |
Anna Bridge |
160:5571c4ff569f | 544 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
Anna Bridge |
160:5571c4ff569f | 545 | This parameter can be a value of @ref CRYP_Data_Type */ |
Anna Bridge |
160:5571c4ff569f | 546 | |
Anna Bridge |
160:5571c4ff569f | 547 | uint32_t KeySize; /*!< 128 or 256-bit key length. |
Anna Bridge |
160:5571c4ff569f | 548 | This parameter can be a value of @ref CRYP_Key_Size */ |
Anna Bridge |
160:5571c4ff569f | 549 | |
Anna Bridge |
160:5571c4ff569f | 550 | uint32_t OperatingMode; /*!< AES operating mode. |
Anna Bridge |
160:5571c4ff569f | 551 | This parameter can be a value of @ref CRYP_AES_OperatingMode */ |
Anna Bridge |
160:5571c4ff569f | 552 | |
Anna Bridge |
160:5571c4ff569f | 553 | uint32_t ChainingMode; /*!< AES chaining mode. |
Anna Bridge |
160:5571c4ff569f | 554 | This parameter can be a value of @ref CRYP_AES_ChainingMode */ |
Anna Bridge |
160:5571c4ff569f | 555 | |
Anna Bridge |
160:5571c4ff569f | 556 | uint32_t KeyWriteFlag; /*!< Allows to bypass or not key write-up before decryption. |
Anna Bridge |
160:5571c4ff569f | 557 | This parameter can be a value of @ref CRYP_Key_Write */ |
Anna Bridge |
160:5571c4ff569f | 558 | |
Anna Bridge |
160:5571c4ff569f | 559 | uint32_t GCMCMACPhase; /*!< Indicates the processing phase of the Galois Counter Mode (GCM), |
Anna Bridge |
160:5571c4ff569f | 560 | Galois Message Authentication Code (GMAC) or Cipher Message |
Anna Bridge |
160:5571c4ff569f | 561 | Authentication Code (CMAC) or Counter with Cipher Mode (CCM) when |
Anna Bridge |
160:5571c4ff569f | 562 | the latter is applicable. |
Anna Bridge |
160:5571c4ff569f | 563 | This parameter can be a value of @ref CRYP_GCM_CMAC_Phase */ |
Anna Bridge |
160:5571c4ff569f | 564 | |
Anna Bridge |
160:5571c4ff569f | 565 | uint8_t* pKey; /*!< Encryption/Decryption Key */ |
Anna Bridge |
160:5571c4ff569f | 566 | |
Anna Bridge |
160:5571c4ff569f | 567 | uint8_t* pInitVect; /*!< Initialization Vector used for CTR, CBC, GCM/GMAC, CMAC, |
Anna Bridge |
160:5571c4ff569f | 568 | (and CCM when applicable) modes */ |
Anna Bridge |
160:5571c4ff569f | 569 | |
Anna Bridge |
160:5571c4ff569f | 570 | uint8_t* Header; /*!< Header used in GCM/GMAC, CMAC (and CCM when applicable) modes */ |
Anna Bridge |
160:5571c4ff569f | 571 | |
Anna Bridge |
160:5571c4ff569f | 572 | uint64_t HeaderSize; /*!< Header size in bytes */ |
Anna Bridge |
160:5571c4ff569f | 573 | |
Anna Bridge |
160:5571c4ff569f | 574 | }CRYP_InitTypeDef; |
Anna Bridge |
160:5571c4ff569f | 575 | |
Anna Bridge |
160:5571c4ff569f | 576 | /** |
Anna Bridge |
160:5571c4ff569f | 577 | * @brief HAL CRYP State structures definition |
Anna Bridge |
160:5571c4ff569f | 578 | */ |
Anna Bridge |
160:5571c4ff569f | 579 | typedef enum |
Anna Bridge |
160:5571c4ff569f | 580 | { |
Anna Bridge |
160:5571c4ff569f | 581 | HAL_CRYP_STATE_RESET = 0x00U, /*!< CRYP not yet initialized or disabled */ |
Anna Bridge |
160:5571c4ff569f | 582 | HAL_CRYP_STATE_READY = 0x01U, /*!< CRYP initialized and ready for use */ |
Anna Bridge |
160:5571c4ff569f | 583 | HAL_CRYP_STATE_BUSY = 0x02U, /*!< CRYP internal processing is ongoing */ |
Anna Bridge |
160:5571c4ff569f | 584 | HAL_CRYP_STATE_TIMEOUT = 0x03U, /*!< CRYP timeout state */ |
Anna Bridge |
160:5571c4ff569f | 585 | HAL_CRYP_STATE_ERROR = 0x04U, /*!< CRYP error state */ |
Anna Bridge |
160:5571c4ff569f | 586 | HAL_CRYP_STATE_SUSPENDED = 0x05U /*!< CRYP suspended */ |
Anna Bridge |
160:5571c4ff569f | 587 | }HAL_CRYP_STATETypeDef; |
Anna Bridge |
160:5571c4ff569f | 588 | |
Anna Bridge |
160:5571c4ff569f | 589 | /** |
Anna Bridge |
160:5571c4ff569f | 590 | * @brief HAL CRYP phase structures definition |
Anna Bridge |
160:5571c4ff569f | 591 | */ |
Anna Bridge |
160:5571c4ff569f | 592 | typedef enum |
Anna Bridge |
160:5571c4ff569f | 593 | { |
Anna Bridge |
160:5571c4ff569f | 594 | HAL_CRYP_PHASE_READY = 0x01U, /*!< CRYP peripheral is ready for initialization. */ |
Anna Bridge |
160:5571c4ff569f | 595 | HAL_CRYP_PHASE_PROCESS = 0x02U, /*!< CRYP peripheral is in processing phase */ |
Anna Bridge |
160:5571c4ff569f | 596 | HAL_CRYP_PHASE_START = 0x03U, /*!< CRYP peripheral has been initialized but |
Anna Bridge |
160:5571c4ff569f | 597 | GCM/GMAC/CMAC(/CCM) initialization phase has not started */ |
Anna Bridge |
160:5571c4ff569f | 598 | HAL_CRYP_PHASE_INIT_OVER = 0x04U, /*!< GCM/GMAC/CMAC(/CCM) init phase has been carried out */ |
Anna Bridge |
160:5571c4ff569f | 599 | HAL_CRYP_PHASE_HEADER_OVER = 0x05U, /*!< GCM/GMAC/CMAC(/CCM) header phase has been carried out */ |
Anna Bridge |
160:5571c4ff569f | 600 | HAL_CRYP_PHASE_PAYLOAD_OVER = 0x06U, /*!< GCM(/CCM) payload phase has been carried out */ |
Anna Bridge |
160:5571c4ff569f | 601 | HAL_CRYP_PHASE_FINAL_OVER = 0x07U, /*!< GCM/GMAC/CMAC(/CCM) final phase has been carried out */ |
Anna Bridge |
160:5571c4ff569f | 602 | HAL_CRYP_PHASE_HEADER_SUSPENDED = 0x08U, /*!< GCM/GMAC/CMAC(/CCM) header phase has been suspended */ |
Anna Bridge |
160:5571c4ff569f | 603 | HAL_CRYP_PHASE_PAYLOAD_SUSPENDED = 0x09U, /*!< GCM(/CCM) payload phase has been suspended */ |
Anna Bridge |
160:5571c4ff569f | 604 | HAL_CRYP_PHASE_NOT_USED = 0x0AU /*!< Phase is irrelevant to the current chaining mode */ |
Anna Bridge |
160:5571c4ff569f | 605 | }HAL_PhaseTypeDef; |
Anna Bridge |
160:5571c4ff569f | 606 | |
Anna Bridge |
160:5571c4ff569f | 607 | /** |
Anna Bridge |
160:5571c4ff569f | 608 | * @brief HAL CRYP mode suspend definitions |
Anna Bridge |
160:5571c4ff569f | 609 | */ |
Anna Bridge |
160:5571c4ff569f | 610 | typedef enum |
Anna Bridge |
160:5571c4ff569f | 611 | { |
Anna Bridge |
160:5571c4ff569f | 612 | HAL_CRYP_SUSPEND_NONE = 0x00U, /*!< CRYP peripheral suspension not requested */ |
Anna Bridge |
160:5571c4ff569f | 613 | HAL_CRYP_SUSPEND = 0x01U /*!< CRYP peripheral suspension requested */ |
Anna Bridge |
160:5571c4ff569f | 614 | }HAL_SuspendTypeDef; |
Anna Bridge |
160:5571c4ff569f | 615 | |
Anna Bridge |
160:5571c4ff569f | 616 | |
Anna Bridge |
160:5571c4ff569f | 617 | /** |
Anna Bridge |
160:5571c4ff569f | 618 | * @brief HAL CRYP Error Codes definition |
Anna Bridge |
160:5571c4ff569f | 619 | */ |
Anna Bridge |
160:5571c4ff569f | 620 | #define HAL_CRYP_ERROR_NONE 0x00000000U /*!< No error */ |
Anna Bridge |
160:5571c4ff569f | 621 | #define HAL_CRYP_WRITE_ERROR 0x00000001U /*!< Write error */ |
Anna Bridge |
160:5571c4ff569f | 622 | #define HAL_CRYP_READ_ERROR 0x00000002U /*!< Read error */ |
Anna Bridge |
160:5571c4ff569f | 623 | #define HAL_CRYP_DMA_ERROR 0x00000004U /*!< DMA error */ |
Anna Bridge |
160:5571c4ff569f | 624 | #define HAL_CRYP_BUSY_ERROR 0x00000008U /*!< Busy flag error */ |
Anna Bridge |
160:5571c4ff569f | 625 | |
Anna Bridge |
160:5571c4ff569f | 626 | /** |
Anna Bridge |
160:5571c4ff569f | 627 | * @brief CRYP handle Structure definition |
Anna Bridge |
160:5571c4ff569f | 628 | */ |
Anna Bridge |
160:5571c4ff569f | 629 | typedef struct |
Anna Bridge |
160:5571c4ff569f | 630 | { |
Anna Bridge |
160:5571c4ff569f | 631 | AES_TypeDef *Instance; /*!< Register base address */ |
Anna Bridge |
160:5571c4ff569f | 632 | |
Anna Bridge |
160:5571c4ff569f | 633 | CRYP_InitTypeDef Init; /*!< CRYP initialization parameters */ |
Anna Bridge |
160:5571c4ff569f | 634 | |
Anna Bridge |
160:5571c4ff569f | 635 | uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) input buffer */ |
Anna Bridge |
160:5571c4ff569f | 636 | |
Anna Bridge |
160:5571c4ff569f | 637 | uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) output buffer */ |
Anna Bridge |
160:5571c4ff569f | 638 | |
Anna Bridge |
160:5571c4ff569f | 639 | uint32_t CrypInCount; /*!< Input data size in bytes or, after suspension, the remaining |
Anna Bridge |
160:5571c4ff569f | 640 | number of bytes to process */ |
Anna Bridge |
160:5571c4ff569f | 641 | |
Anna Bridge |
160:5571c4ff569f | 642 | uint32_t CrypOutCount; /*!< Output data size in bytes */ |
Anna Bridge |
160:5571c4ff569f | 643 | |
Anna Bridge |
160:5571c4ff569f | 644 | HAL_PhaseTypeDef Phase; /*!< CRYP peripheral processing phase for GCM, GMAC, CMAC |
Anna Bridge |
160:5571c4ff569f | 645 | (or CCM when applicable) modes. |
Anna Bridge |
160:5571c4ff569f | 646 | Indicates the last phase carried out to ease |
Anna Bridge |
160:5571c4ff569f | 647 | phase transitions */ |
Anna Bridge |
160:5571c4ff569f | 648 | |
Anna Bridge |
160:5571c4ff569f | 649 | DMA_HandleTypeDef *hdmain; /*!< CRYP peripheral Input DMA handle parameters */ |
Anna Bridge |
160:5571c4ff569f | 650 | |
Anna Bridge |
160:5571c4ff569f | 651 | DMA_HandleTypeDef *hdmaout; /*!< CRYP peripheral Output DMA handle parameters */ |
Anna Bridge |
160:5571c4ff569f | 652 | |
Anna Bridge |
160:5571c4ff569f | 653 | HAL_LockTypeDef Lock; /*!< CRYP locking object */ |
Anna Bridge |
160:5571c4ff569f | 654 | |
Anna Bridge |
160:5571c4ff569f | 655 | __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ |
Anna Bridge |
160:5571c4ff569f | 656 | |
Anna Bridge |
160:5571c4ff569f | 657 | __IO uint32_t ErrorCode; /*!< CRYP peripheral error code */ |
Anna Bridge |
160:5571c4ff569f | 658 | |
Anna Bridge |
160:5571c4ff569f | 659 | HAL_SuspendTypeDef SuspendRequest; /*!< CRYP peripheral suspension request flag */ |
Anna Bridge |
160:5571c4ff569f | 660 | }CRYP_HandleTypeDef; |
Anna Bridge |
160:5571c4ff569f | 661 | |
Anna Bridge |
160:5571c4ff569f | 662 | /** |
Anna Bridge |
160:5571c4ff569f | 663 | * @} |
Anna Bridge |
160:5571c4ff569f | 664 | */ |
Anna Bridge |
160:5571c4ff569f | 665 | |
Anna Bridge |
160:5571c4ff569f | 666 | |
Anna Bridge |
160:5571c4ff569f | 667 | /* Exported constants --------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 668 | /** @defgroup CRYP_Exported_Constants CRYP Exported Constants |
Anna Bridge |
160:5571c4ff569f | 669 | * @{ |
Anna Bridge |
160:5571c4ff569f | 670 | */ |
Anna Bridge |
160:5571c4ff569f | 671 | |
Anna Bridge |
160:5571c4ff569f | 672 | /** @defgroup CRYP_Key_Size Key size selection |
Anna Bridge |
160:5571c4ff569f | 673 | * @{ |
Anna Bridge |
160:5571c4ff569f | 674 | */ |
Anna Bridge |
160:5571c4ff569f | 675 | #define CRYP_KEYSIZE_128B 0x00000000U /*!< 128-bit long key */ |
Anna Bridge |
160:5571c4ff569f | 676 | #define CRYP_KEYSIZE_256B AES_CR_KEYSIZE /*!< 256-bit long key */ |
Anna Bridge |
160:5571c4ff569f | 677 | /** |
Anna Bridge |
160:5571c4ff569f | 678 | * @} |
Anna Bridge |
160:5571c4ff569f | 679 | */ |
Anna Bridge |
160:5571c4ff569f | 680 | |
Anna Bridge |
160:5571c4ff569f | 681 | /** @defgroup CRYP_Data_Type AES Data Type selection |
Anna Bridge |
160:5571c4ff569f | 682 | * @{ |
Anna Bridge |
160:5571c4ff569f | 683 | */ |
Anna Bridge |
160:5571c4ff569f | 684 | #define CRYP_DATATYPE_32B 0x00000000U /*!< 32-bit data type (no swapping) */ |
Anna Bridge |
160:5571c4ff569f | 685 | #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */ |
Anna Bridge |
160:5571c4ff569f | 686 | #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */ |
Anna Bridge |
160:5571c4ff569f | 687 | #define CRYP_DATATYPE_1B AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */ |
Anna Bridge |
160:5571c4ff569f | 688 | /** |
Anna Bridge |
160:5571c4ff569f | 689 | * @} |
Anna Bridge |
160:5571c4ff569f | 690 | */ |
Anna Bridge |
160:5571c4ff569f | 691 | |
Anna Bridge |
160:5571c4ff569f | 692 | /** @defgroup CRYP_AES_State AES Enable state |
Anna Bridge |
160:5571c4ff569f | 693 | * @{ |
Anna Bridge |
160:5571c4ff569f | 694 | */ |
Anna Bridge |
160:5571c4ff569f | 695 | #define CRYP_AES_DISABLE 0x00000000U /*!< Disable AES */ |
Anna Bridge |
160:5571c4ff569f | 696 | #define CRYP_AES_ENABLE AES_CR_EN /*!< Enable AES */ |
Anna Bridge |
160:5571c4ff569f | 697 | /** |
Anna Bridge |
160:5571c4ff569f | 698 | * @} |
Anna Bridge |
160:5571c4ff569f | 699 | */ |
Anna Bridge |
160:5571c4ff569f | 700 | |
Anna Bridge |
160:5571c4ff569f | 701 | /** @defgroup CRYP_AES_OperatingMode AES operating mode |
Anna Bridge |
160:5571c4ff569f | 702 | * @{ |
Anna Bridge |
160:5571c4ff569f | 703 | */ |
Anna Bridge |
160:5571c4ff569f | 704 | #define CRYP_ALGOMODE_ENCRYPT 0x00000000U /*!< Encryption mode */ |
Anna Bridge |
160:5571c4ff569f | 705 | #define CRYP_ALGOMODE_KEYDERIVATION AES_CR_MODE_0 /*!< Key derivation mode */ |
Anna Bridge |
160:5571c4ff569f | 706 | #define CRYP_ALGOMODE_DECRYPT AES_CR_MODE_1 /*!< Decryption */ |
Anna Bridge |
160:5571c4ff569f | 707 | #define CRYP_ALGOMODE_KEYDERIVATION_DECRYPT AES_CR_MODE /*!< Key derivation and decryption */ |
Anna Bridge |
160:5571c4ff569f | 708 | #define CRYP_ALGOMODE_TAG_GENERATION 0x00000000U /*!< GMAC or CMAC authentication tag generation */ |
Anna Bridge |
160:5571c4ff569f | 709 | /** |
Anna Bridge |
160:5571c4ff569f | 710 | * @} |
Anna Bridge |
160:5571c4ff569f | 711 | */ |
Anna Bridge |
160:5571c4ff569f | 712 | |
Anna Bridge |
160:5571c4ff569f | 713 | /** @defgroup CRYP_AES_ChainingMode AES chaining mode |
Anna Bridge |
160:5571c4ff569f | 714 | * @{ |
Anna Bridge |
160:5571c4ff569f | 715 | */ |
Anna Bridge |
160:5571c4ff569f | 716 | #define CRYP_CHAINMODE_AES_ECB 0x00000000U /*!< Electronic codebook chaining algorithm */ |
Anna Bridge |
160:5571c4ff569f | 717 | #define CRYP_CHAINMODE_AES_CBC AES_CR_CHMOD_0 /*!< Cipher block chaining algorithm */ |
Anna Bridge |
160:5571c4ff569f | 718 | #define CRYP_CHAINMODE_AES_CTR AES_CR_CHMOD_1 /*!< Counter mode chaining algorithm */ |
Anna Bridge |
160:5571c4ff569f | 719 | #define CRYP_CHAINMODE_AES_GCM_GMAC (AES_CR_CHMOD_0 | AES_CR_CHMOD_1) /*!< Galois counter mode - Galois message authentication code */ |
Anna Bridge |
160:5571c4ff569f | 720 | #define CRYP_CHAINMODE_AES_CMAC AES_CR_CHMOD_2 /*!< Cipher message authentication code */ |
Anna Bridge |
160:5571c4ff569f | 721 | #if defined(AES_CR_NPBLB) |
Anna Bridge |
160:5571c4ff569f | 722 | #define CRYP_CHAINMODE_AES_CCM_CMAC AES_CR_CHMOD_2 /*!< Counter with Cipher Mode - Cipher message authentication code */ |
Anna Bridge |
160:5571c4ff569f | 723 | #endif |
Anna Bridge |
160:5571c4ff569f | 724 | /** |
Anna Bridge |
160:5571c4ff569f | 725 | * @} |
Anna Bridge |
160:5571c4ff569f | 726 | */ |
Anna Bridge |
160:5571c4ff569f | 727 | |
Anna Bridge |
160:5571c4ff569f | 728 | /** @defgroup CRYP_Key_Write AES decryption key write-up flag |
Anna Bridge |
160:5571c4ff569f | 729 | * @{ |
Anna Bridge |
160:5571c4ff569f | 730 | */ |
Anna Bridge |
160:5571c4ff569f | 731 | #define CRYP_KEY_WRITE_ENABLE 0x00000000U /*!< Enable decryption key writing */ |
Anna Bridge |
160:5571c4ff569f | 732 | #define CRYP_KEY_WRITE_DISABLE 0x00000001U /*!< Disable decryption key writing */ |
Anna Bridge |
160:5571c4ff569f | 733 | /** |
Anna Bridge |
160:5571c4ff569f | 734 | * @} |
Anna Bridge |
160:5571c4ff569f | 735 | */ |
Anna Bridge |
160:5571c4ff569f | 736 | |
Anna Bridge |
160:5571c4ff569f | 737 | /** @defgroup CRYP_DMAIN DMA Input phase management enable state |
Anna Bridge |
160:5571c4ff569f | 738 | * @{ |
Anna Bridge |
160:5571c4ff569f | 739 | */ |
Anna Bridge |
160:5571c4ff569f | 740 | #define CRYP_DMAIN_DISABLE 0x00000000U /*!< Disable DMA Input phase management */ |
Anna Bridge |
160:5571c4ff569f | 741 | #define CRYP_DMAIN_ENABLE AES_CR_DMAINEN /*!< Enable DMA Input phase management */ |
Anna Bridge |
160:5571c4ff569f | 742 | /** |
Anna Bridge |
160:5571c4ff569f | 743 | * @} |
Anna Bridge |
160:5571c4ff569f | 744 | */ |
Anna Bridge |
160:5571c4ff569f | 745 | |
Anna Bridge |
160:5571c4ff569f | 746 | /** @defgroup CRYP_DMAOUT DMA Output phase management enable state |
Anna Bridge |
160:5571c4ff569f | 747 | * @{ |
Anna Bridge |
160:5571c4ff569f | 748 | */ |
Anna Bridge |
160:5571c4ff569f | 749 | #define CRYP_DMAOUT_DISABLE 0x00000000U /*!< Disable DMA Output phase management */ |
Anna Bridge |
160:5571c4ff569f | 750 | #define CRYP_DMAOUT_ENABLE AES_CR_DMAOUTEN /*!< Enable DMA Output phase management */ |
Anna Bridge |
160:5571c4ff569f | 751 | /** |
Anna Bridge |
160:5571c4ff569f | 752 | * @} |
Anna Bridge |
160:5571c4ff569f | 753 | */ |
Anna Bridge |
160:5571c4ff569f | 754 | |
Anna Bridge |
160:5571c4ff569f | 755 | |
Anna Bridge |
160:5571c4ff569f | 756 | /** @defgroup CRYP_GCM_CMAC_Phase GCM/GMAC and CMAC processing phase selection |
Anna Bridge |
160:5571c4ff569f | 757 | * @{ |
Anna Bridge |
160:5571c4ff569f | 758 | */ |
Anna Bridge |
160:5571c4ff569f | 759 | #define CRYP_GCM_INIT_PHASE 0x00000000U /*!< GCM/GMAC (or CCM) init phase */ |
Anna Bridge |
160:5571c4ff569f | 760 | #define CRYP_GCMCMAC_HEADER_PHASE AES_CR_GCMPH_0 /*!< GCM/GMAC or (CCM/)CMAC header phase */ |
Anna Bridge |
160:5571c4ff569f | 761 | #define CRYP_GCM_PAYLOAD_PHASE AES_CR_GCMPH_1 /*!< GCM(/CCM) payload phase */ |
Anna Bridge |
160:5571c4ff569f | 762 | #define CRYP_GCMCMAC_FINAL_PHASE AES_CR_GCMPH /*!< GCM/GMAC or (CCM/)CMAC final phase */ |
Anna Bridge |
160:5571c4ff569f | 763 | /* Definitions duplication for code readibility's sake: |
Anna Bridge |
160:5571c4ff569f | 764 | supported or not supported chain modes are not specified for each phase */ |
Anna Bridge |
160:5571c4ff569f | 765 | #define CRYP_INIT_PHASE 0x00000000U /*!< Init phase */ |
Anna Bridge |
160:5571c4ff569f | 766 | #define CRYP_HEADER_PHASE AES_CR_GCMPH_0 /*!< Header phase */ |
Anna Bridge |
160:5571c4ff569f | 767 | #define CRYP_PAYLOAD_PHASE AES_CR_GCMPH_1 /*!< Payload phase */ |
Anna Bridge |
160:5571c4ff569f | 768 | #define CRYP_FINAL_PHASE AES_CR_GCMPH /*!< Final phase */ |
Anna Bridge |
160:5571c4ff569f | 769 | /** |
Anna Bridge |
160:5571c4ff569f | 770 | * @} |
Anna Bridge |
160:5571c4ff569f | 771 | */ |
Anna Bridge |
160:5571c4ff569f | 772 | |
Anna Bridge |
160:5571c4ff569f | 773 | /** @defgroup CRYP_Flags AES status flags |
Anna Bridge |
160:5571c4ff569f | 774 | * @{ |
Anna Bridge |
160:5571c4ff569f | 775 | */ |
Anna Bridge |
160:5571c4ff569f | 776 | |
Anna Bridge |
160:5571c4ff569f | 777 | #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden */ |
Anna Bridge |
160:5571c4ff569f | 778 | #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error */ |
Anna Bridge |
160:5571c4ff569f | 779 | #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read error */ |
Anna Bridge |
160:5571c4ff569f | 780 | #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed */ |
Anna Bridge |
160:5571c4ff569f | 781 | /** |
Anna Bridge |
160:5571c4ff569f | 782 | * @} |
Anna Bridge |
160:5571c4ff569f | 783 | */ |
Anna Bridge |
160:5571c4ff569f | 784 | |
Anna Bridge |
160:5571c4ff569f | 785 | /** @defgroup CRYP_Clear_Flags AES clearing flags |
Anna Bridge |
160:5571c4ff569f | 786 | * @{ |
Anna Bridge |
160:5571c4ff569f | 787 | */ |
Anna Bridge |
160:5571c4ff569f | 788 | |
Anna Bridge |
160:5571c4ff569f | 789 | #define CRYP_CCF_CLEAR AES_CR_CCFC /*!< Computation Complete Flag Clear */ |
Anna Bridge |
160:5571c4ff569f | 790 | #define CRYP_ERR_CLEAR AES_CR_ERRC /*!< Error Flag Clear */ |
Anna Bridge |
160:5571c4ff569f | 791 | /** |
Anna Bridge |
160:5571c4ff569f | 792 | * @} |
Anna Bridge |
160:5571c4ff569f | 793 | */ |
Anna Bridge |
160:5571c4ff569f | 794 | |
Anna Bridge |
160:5571c4ff569f | 795 | /** @defgroup AES_Interrupts_Enable AES Interrupts Enable bits |
Anna Bridge |
160:5571c4ff569f | 796 | * @{ |
Anna Bridge |
160:5571c4ff569f | 797 | */ |
Anna Bridge |
160:5571c4ff569f | 798 | #define CRYP_IT_CCFIE AES_CR_CCFIE /*!< Computation Complete interrupt enable */ |
Anna Bridge |
160:5571c4ff569f | 799 | #define CRYP_IT_ERRIE AES_CR_ERRIE /*!< Error interrupt enable */ |
Anna Bridge |
160:5571c4ff569f | 800 | /** |
Anna Bridge |
160:5571c4ff569f | 801 | * @} |
Anna Bridge |
160:5571c4ff569f | 802 | */ |
Anna Bridge |
160:5571c4ff569f | 803 | |
Anna Bridge |
160:5571c4ff569f | 804 | /** @defgroup CRYP_Interrupts_Flags AES Interrupts flags |
Anna Bridge |
160:5571c4ff569f | 805 | * @{ |
Anna Bridge |
160:5571c4ff569f | 806 | */ |
Anna Bridge |
160:5571c4ff569f | 807 | #define CRYP_IT_WRERR AES_SR_WRERR /*!< Write Error */ |
Anna Bridge |
160:5571c4ff569f | 808 | #define CRYP_IT_RDERR AES_SR_RDERR /*!< Read Error */ |
Anna Bridge |
160:5571c4ff569f | 809 | #define CRYP_IT_CCF AES_SR_CCF /*!< Computation completed */ |
Anna Bridge |
160:5571c4ff569f | 810 | /** |
Anna Bridge |
160:5571c4ff569f | 811 | * @} |
Anna Bridge |
160:5571c4ff569f | 812 | */ |
Anna Bridge |
160:5571c4ff569f | 813 | |
Anna Bridge |
160:5571c4ff569f | 814 | /** |
Anna Bridge |
160:5571c4ff569f | 815 | * @} |
Anna Bridge |
160:5571c4ff569f | 816 | */ |
Anna Bridge |
160:5571c4ff569f | 817 | |
Anna Bridge |
160:5571c4ff569f | 818 | /* Exported macros -----------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 819 | /** @defgroup CRYP_Exported_Macros CRYP Exported Macros |
Anna Bridge |
160:5571c4ff569f | 820 | * @{ |
Anna Bridge |
160:5571c4ff569f | 821 | */ |
Anna Bridge |
160:5571c4ff569f | 822 | |
Anna Bridge |
160:5571c4ff569f | 823 | /** @brief Reset CRYP handle state. |
Anna Bridge |
160:5571c4ff569f | 824 | * @param __HANDLE__: specifies the CRYP handle. |
Anna Bridge |
160:5571c4ff569f | 825 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 826 | */ |
Anna Bridge |
160:5571c4ff569f | 827 | #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) |
Anna Bridge |
160:5571c4ff569f | 828 | |
Anna Bridge |
160:5571c4ff569f | 829 | /** |
Anna Bridge |
160:5571c4ff569f | 830 | * @brief Enable the CRYP AES peripheral. |
Anna Bridge |
160:5571c4ff569f | 831 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 832 | */ |
Anna Bridge |
160:5571c4ff569f | 833 | #define __HAL_CRYP_ENABLE() (AES->CR |= AES_CR_EN) |
Anna Bridge |
160:5571c4ff569f | 834 | |
Anna Bridge |
160:5571c4ff569f | 835 | /** |
Anna Bridge |
160:5571c4ff569f | 836 | * @brief Disable the CRYP AES peripheral. |
Anna Bridge |
160:5571c4ff569f | 837 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 838 | */ |
Anna Bridge |
160:5571c4ff569f | 839 | #define __HAL_CRYP_DISABLE() (AES->CR &= ~AES_CR_EN) |
Anna Bridge |
160:5571c4ff569f | 840 | |
Anna Bridge |
160:5571c4ff569f | 841 | /** |
Anna Bridge |
160:5571c4ff569f | 842 | * @brief Set the algorithm operating mode. |
Anna Bridge |
160:5571c4ff569f | 843 | * @param __OPERATING_MODE__: specifies the operating mode |
Anna Bridge |
160:5571c4ff569f | 844 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 845 | * @arg @ref CRYP_ALGOMODE_ENCRYPT encryption |
Anna Bridge |
160:5571c4ff569f | 846 | * @arg @ref CRYP_ALGOMODE_KEYDERIVATION key derivation |
Anna Bridge |
160:5571c4ff569f | 847 | * @arg @ref CRYP_ALGOMODE_DECRYPT decryption |
Anna Bridge |
160:5571c4ff569f | 848 | * @arg @ref CRYP_ALGOMODE_KEYDERIVATION_DECRYPT key derivation and decryption |
Anna Bridge |
160:5571c4ff569f | 849 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 850 | */ |
Anna Bridge |
160:5571c4ff569f | 851 | #define __HAL_CRYP_SET_OPERATINGMODE(__OPERATING_MODE__) MODIFY_REG(AES->CR, AES_CR_MODE, (__OPERATING_MODE__)) |
Anna Bridge |
160:5571c4ff569f | 852 | |
Anna Bridge |
160:5571c4ff569f | 853 | |
Anna Bridge |
160:5571c4ff569f | 854 | /** |
Anna Bridge |
160:5571c4ff569f | 855 | * @brief Set the algorithm chaining mode. |
Anna Bridge |
160:5571c4ff569f | 856 | * @param __CHAINING_MODE__: specifies the chaining mode |
Anna Bridge |
160:5571c4ff569f | 857 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 858 | * @arg @ref CRYP_CHAINMODE_AES_ECB Electronic CodeBook |
Anna Bridge |
160:5571c4ff569f | 859 | * @arg @ref CRYP_CHAINMODE_AES_CBC Cipher Block Chaining |
Anna Bridge |
160:5571c4ff569f | 860 | * @arg @ref CRYP_CHAINMODE_AES_CTR CounTeR mode |
Anna Bridge |
160:5571c4ff569f | 861 | * @arg @ref CRYP_CHAINMODE_AES_GCM_GMAC Galois Counter Mode or Galois Message Authentication Code |
Anna Bridge |
160:5571c4ff569f | 862 | * @arg @ref CRYP_CHAINMODE_AES_CMAC Cipher Message Authentication Code (or Counter with Cipher Mode when applicable) |
Anna Bridge |
160:5571c4ff569f | 863 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 864 | */ |
Anna Bridge |
160:5571c4ff569f | 865 | #define __HAL_CRYP_SET_CHAININGMODE(__CHAINING_MODE__) MODIFY_REG(AES->CR, AES_CR_CHMOD, (__CHAINING_MODE__)) |
Anna Bridge |
160:5571c4ff569f | 866 | |
Anna Bridge |
160:5571c4ff569f | 867 | |
Anna Bridge |
160:5571c4ff569f | 868 | |
Anna Bridge |
160:5571c4ff569f | 869 | /** @brief Check whether the specified CRYP status flag is set or not. |
Anna Bridge |
160:5571c4ff569f | 870 | * @param __FLAG__: specifies the flag to check. |
Anna Bridge |
160:5571c4ff569f | 871 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 872 | * @arg @ref CRYP_FLAG_BUSY GCM process suspension forbidden |
Anna Bridge |
160:5571c4ff569f | 873 | * @arg @ref CRYP_IT_WRERR Write Error |
Anna Bridge |
160:5571c4ff569f | 874 | * @arg @ref CRYP_IT_RDERR Read Error |
Anna Bridge |
160:5571c4ff569f | 875 | * @arg @ref CRYP_IT_CCF Computation Complete |
Anna Bridge |
160:5571c4ff569f | 876 | * @retval The state of __FLAG__ (TRUE or FALSE). |
Anna Bridge |
160:5571c4ff569f | 877 | */ |
Anna Bridge |
160:5571c4ff569f | 878 | #define __HAL_CRYP_GET_FLAG(__FLAG__) ((AES->SR & (__FLAG__)) == (__FLAG__)) |
Anna Bridge |
160:5571c4ff569f | 879 | |
Anna Bridge |
160:5571c4ff569f | 880 | |
Anna Bridge |
160:5571c4ff569f | 881 | /** @brief Clear the CRYP pending status flag. |
Anna Bridge |
160:5571c4ff569f | 882 | * @param __FLAG__: specifies the flag to clear. |
Anna Bridge |
160:5571c4ff569f | 883 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 884 | * @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear |
Anna Bridge |
160:5571c4ff569f | 885 | * @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear |
Anna Bridge |
160:5571c4ff569f | 886 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 887 | */ |
Anna Bridge |
160:5571c4ff569f | 888 | #define __HAL_CRYP_CLEAR_FLAG(__FLAG__) SET_BIT(AES->CR, (__FLAG__)) |
Anna Bridge |
160:5571c4ff569f | 889 | |
Anna Bridge |
160:5571c4ff569f | 890 | |
Anna Bridge |
160:5571c4ff569f | 891 | |
Anna Bridge |
160:5571c4ff569f | 892 | /** @brief Check whether the specified CRYP interrupt source is enabled or not. |
Anna Bridge |
160:5571c4ff569f | 893 | * @param __INTERRUPT__: CRYP interrupt source to check |
Anna Bridge |
160:5571c4ff569f | 894 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 895 | * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR) |
Anna Bridge |
160:5571c4ff569f | 896 | * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt |
Anna Bridge |
160:5571c4ff569f | 897 | * @retval State of interruption (TRUE or FALSE). |
Anna Bridge |
160:5571c4ff569f | 898 | */ |
Anna Bridge |
160:5571c4ff569f | 899 | #define __HAL_CRYP_GET_IT_SOURCE(__INTERRUPT__) ((AES->CR & (__INTERRUPT__)) == (__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 900 | |
Anna Bridge |
160:5571c4ff569f | 901 | |
Anna Bridge |
160:5571c4ff569f | 902 | /** @brief Check whether the specified CRYP interrupt is set or not. |
Anna Bridge |
160:5571c4ff569f | 903 | * @param __INTERRUPT__: specifies the interrupt to check. |
Anna Bridge |
160:5571c4ff569f | 904 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 905 | * @arg @ref CRYP_IT_WRERR Write Error |
Anna Bridge |
160:5571c4ff569f | 906 | * @arg @ref CRYP_IT_RDERR Read Error |
Anna Bridge |
160:5571c4ff569f | 907 | * @arg @ref CRYP_IT_CCF Computation Complete |
Anna Bridge |
160:5571c4ff569f | 908 | * @retval The state of __INTERRUPT__ (TRUE or FALSE). |
Anna Bridge |
160:5571c4ff569f | 909 | */ |
Anna Bridge |
160:5571c4ff569f | 910 | #define __HAL_CRYP_GET_IT(__INTERRUPT__) ((AES->SR & (__INTERRUPT__)) == (__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 911 | |
Anna Bridge |
160:5571c4ff569f | 912 | |
Anna Bridge |
160:5571c4ff569f | 913 | |
Anna Bridge |
160:5571c4ff569f | 914 | /** @brief Clear the CRYP pending interrupt. |
Anna Bridge |
160:5571c4ff569f | 915 | * @param __INTERRUPT__: specifies the IT to clear. |
Anna Bridge |
160:5571c4ff569f | 916 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 917 | * @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear |
Anna Bridge |
160:5571c4ff569f | 918 | * @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear |
Anna Bridge |
160:5571c4ff569f | 919 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 920 | */ |
Anna Bridge |
160:5571c4ff569f | 921 | #define __HAL_CRYP_CLEAR_IT(__INTERRUPT__) SET_BIT(AES->CR, (__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 922 | |
Anna Bridge |
160:5571c4ff569f | 923 | |
Anna Bridge |
160:5571c4ff569f | 924 | /** |
Anna Bridge |
160:5571c4ff569f | 925 | * @brief Enable the CRYP interrupt. |
Anna Bridge |
160:5571c4ff569f | 926 | * @param __INTERRUPT__: CRYP Interrupt. |
Anna Bridge |
160:5571c4ff569f | 927 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 928 | * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR) |
Anna Bridge |
160:5571c4ff569f | 929 | * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt |
Anna Bridge |
160:5571c4ff569f | 930 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 931 | */ |
Anna Bridge |
160:5571c4ff569f | 932 | #define __HAL_CRYP_ENABLE_IT(__INTERRUPT__) ((AES->CR) |= (__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 933 | |
Anna Bridge |
160:5571c4ff569f | 934 | |
Anna Bridge |
160:5571c4ff569f | 935 | /** |
Anna Bridge |
160:5571c4ff569f | 936 | * @brief Disable the CRYP interrupt. |
Anna Bridge |
160:5571c4ff569f | 937 | * @param __INTERRUPT__: CRYP Interrupt. |
Anna Bridge |
160:5571c4ff569f | 938 | * This parameter can be one of the following values: |
Anna Bridge |
160:5571c4ff569f | 939 | * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR) |
Anna Bridge |
160:5571c4ff569f | 940 | * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt |
Anna Bridge |
160:5571c4ff569f | 941 | * @retval None |
Anna Bridge |
160:5571c4ff569f | 942 | */ |
Anna Bridge |
160:5571c4ff569f | 943 | #define __HAL_CRYP_DISABLE_IT(__INTERRUPT__) ((AES->CR) &= ~(__INTERRUPT__)) |
Anna Bridge |
160:5571c4ff569f | 944 | |
Anna Bridge |
160:5571c4ff569f | 945 | /** |
Anna Bridge |
160:5571c4ff569f | 946 | * @} |
Anna Bridge |
160:5571c4ff569f | 947 | */ |
Anna Bridge |
160:5571c4ff569f | 948 | |
Anna Bridge |
160:5571c4ff569f | 949 | /* Private macros --------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 950 | /** @addtogroup CRYP_Private_Macros CRYP Private Macros |
Anna Bridge |
160:5571c4ff569f | 951 | * @{ |
Anna Bridge |
160:5571c4ff569f | 952 | */ |
Anna Bridge |
160:5571c4ff569f | 953 | |
Anna Bridge |
160:5571c4ff569f | 954 | /** |
Anna Bridge |
160:5571c4ff569f | 955 | * @brief Verify the key size length. |
Anna Bridge |
160:5571c4ff569f | 956 | * @param __KEYSIZE__: Ciphering/deciphering algorithm key size. |
Anna Bridge |
160:5571c4ff569f | 957 | * @retval SET (__KEYSIZE__ is a valid value) or RESET (__KEYSIZE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 958 | */ |
Anna Bridge |
160:5571c4ff569f | 959 | #define IS_CRYP_KEYSIZE(__KEYSIZE__) (((__KEYSIZE__) == CRYP_KEYSIZE_128B) || \ |
Anna Bridge |
160:5571c4ff569f | 960 | ((__KEYSIZE__) == CRYP_KEYSIZE_256B)) |
Anna Bridge |
160:5571c4ff569f | 961 | |
Anna Bridge |
160:5571c4ff569f | 962 | /** |
Anna Bridge |
160:5571c4ff569f | 963 | * @brief Verify the input data type. |
Anna Bridge |
160:5571c4ff569f | 964 | * @param __DATATYPE__: Ciphering/deciphering algorithm input data type. |
Anna Bridge |
160:5571c4ff569f | 965 | * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 966 | */ |
Anna Bridge |
160:5571c4ff569f | 967 | #define IS_CRYP_DATATYPE(__DATATYPE__) (((__DATATYPE__) == CRYP_DATATYPE_32B) || \ |
Anna Bridge |
160:5571c4ff569f | 968 | ((__DATATYPE__) == CRYP_DATATYPE_16B) || \ |
Anna Bridge |
160:5571c4ff569f | 969 | ((__DATATYPE__) == CRYP_DATATYPE_8B) || \ |
Anna Bridge |
160:5571c4ff569f | 970 | ((__DATATYPE__) == CRYP_DATATYPE_1B)) |
Anna Bridge |
160:5571c4ff569f | 971 | |
Anna Bridge |
160:5571c4ff569f | 972 | /** |
Anna Bridge |
160:5571c4ff569f | 973 | * @brief Verify the CRYP AES IP running mode. |
Anna Bridge |
160:5571c4ff569f | 974 | * @param __MODE__: CRYP AES IP running mode. |
Anna Bridge |
160:5571c4ff569f | 975 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 976 | */ |
Anna Bridge |
160:5571c4ff569f | 977 | #define IS_CRYP_AES(__MODE__) (((__MODE__) == CRYP_AES_DISABLE) || \ |
Anna Bridge |
160:5571c4ff569f | 978 | ((__MODE__) == CRYP_AES_ENABLE)) |
Anna Bridge |
160:5571c4ff569f | 979 | |
Anna Bridge |
160:5571c4ff569f | 980 | /** |
Anna Bridge |
160:5571c4ff569f | 981 | * @brief Verify the selected CRYP algorithm. |
Anna Bridge |
160:5571c4ff569f | 982 | * @param __ALGOMODE__: Selected CRYP algorithm (ciphering, deciphering, key derivation or a combination of the latter). |
Anna Bridge |
160:5571c4ff569f | 983 | * @retval SET (__ALGOMODE__ is valid) or RESET (__ALGOMODE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 984 | */ |
Anna Bridge |
160:5571c4ff569f | 985 | #define IS_CRYP_ALGOMODE(__ALGOMODE__) (((__ALGOMODE__) == CRYP_ALGOMODE_ENCRYPT) || \ |
Anna Bridge |
160:5571c4ff569f | 986 | ((__ALGOMODE__) == CRYP_ALGOMODE_KEYDERIVATION) || \ |
Anna Bridge |
160:5571c4ff569f | 987 | ((__ALGOMODE__) == CRYP_ALGOMODE_DECRYPT) || \ |
Anna Bridge |
160:5571c4ff569f | 988 | ((__ALGOMODE__) == CRYP_ALGOMODE_TAG_GENERATION) || \ |
Anna Bridge |
160:5571c4ff569f | 989 | ((__ALGOMODE__) == CRYP_ALGOMODE_KEYDERIVATION_DECRYPT)) |
Anna Bridge |
160:5571c4ff569f | 990 | |
Anna Bridge |
160:5571c4ff569f | 991 | /** |
Anna Bridge |
160:5571c4ff569f | 992 | * @brief Verify the selected CRYP chaining algorithm. |
Anna Bridge |
160:5571c4ff569f | 993 | * @param __CHAINMODE__: Selected CRYP chaining algorithm. |
Anna Bridge |
160:5571c4ff569f | 994 | * @retval SET (__CHAINMODE__ is valid) or RESET (__CHAINMODE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 995 | */ |
Anna Bridge |
160:5571c4ff569f | 996 | #if defined(AES_CR_NPBLB) |
Anna Bridge |
160:5571c4ff569f | 997 | #define IS_CRYP_CHAINMODE(__CHAINMODE__) (((__CHAINMODE__) == CRYP_CHAINMODE_AES_ECB) || \ |
Anna Bridge |
160:5571c4ff569f | 998 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CBC) || \ |
Anna Bridge |
160:5571c4ff569f | 999 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CTR) || \ |
Anna Bridge |
160:5571c4ff569f | 1000 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_GCM_GMAC) || \ |
Anna Bridge |
160:5571c4ff569f | 1001 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CCM_CMAC)) |
Anna Bridge |
160:5571c4ff569f | 1002 | #else |
Anna Bridge |
160:5571c4ff569f | 1003 | #define IS_CRYP_CHAINMODE(__CHAINMODE__) (((__CHAINMODE__) == CRYP_CHAINMODE_AES_ECB) || \ |
Anna Bridge |
160:5571c4ff569f | 1004 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CBC) || \ |
Anna Bridge |
160:5571c4ff569f | 1005 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CTR) || \ |
Anna Bridge |
160:5571c4ff569f | 1006 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_GCM_GMAC) || \ |
Anna Bridge |
160:5571c4ff569f | 1007 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CMAC)) |
Anna Bridge |
160:5571c4ff569f | 1008 | #endif |
Anna Bridge |
160:5571c4ff569f | 1009 | |
Anna Bridge |
160:5571c4ff569f | 1010 | /** |
Anna Bridge |
160:5571c4ff569f | 1011 | * @brief Verify the deciphering key write option. |
Anna Bridge |
160:5571c4ff569f | 1012 | * @param __WRITE__: deciphering key write option. |
Anna Bridge |
160:5571c4ff569f | 1013 | * @retval SET (__WRITE__ is valid) or RESET (__WRITE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 1014 | */ |
Anna Bridge |
160:5571c4ff569f | 1015 | #define IS_CRYP_WRITE(__WRITE__) (((__WRITE__) == CRYP_KEY_WRITE_ENABLE) || \ |
Anna Bridge |
160:5571c4ff569f | 1016 | ((__WRITE__) == CRYP_KEY_WRITE_DISABLE)) |
Anna Bridge |
160:5571c4ff569f | 1017 | |
Anna Bridge |
160:5571c4ff569f | 1018 | /** |
Anna Bridge |
160:5571c4ff569f | 1019 | * @brief Verify the CRYP input data DMA mode. |
Anna Bridge |
160:5571c4ff569f | 1020 | * @param __MODE__: CRYP input data DMA mode. |
Anna Bridge |
160:5571c4ff569f | 1021 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 1022 | */ |
Anna Bridge |
160:5571c4ff569f | 1023 | #define IS_CRYP_DMAIN(__MODE__) (((__MODE__) == CRYP_DMAIN_DISABLE) || \ |
Anna Bridge |
160:5571c4ff569f | 1024 | ((__MODE__) == CRYP_DMAIN_ENABLE)) |
Anna Bridge |
160:5571c4ff569f | 1025 | |
Anna Bridge |
160:5571c4ff569f | 1026 | /** |
Anna Bridge |
160:5571c4ff569f | 1027 | * @brief Verify the CRYP output data DMA mode. |
Anna Bridge |
160:5571c4ff569f | 1028 | * @param __MODE__: CRYP output data DMA mode. |
Anna Bridge |
160:5571c4ff569f | 1029 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 1030 | */ |
Anna Bridge |
160:5571c4ff569f | 1031 | #define IS_CRYP_DMAOUT(__MODE__) (((__MODE__) == CRYP_DMAOUT_DISABLE) || \ |
Anna Bridge |
160:5571c4ff569f | 1032 | ((__MODE__) == CRYP_DMAOUT_ENABLE)) |
Anna Bridge |
160:5571c4ff569f | 1033 | |
Anna Bridge |
160:5571c4ff569f | 1034 | /** |
Anna Bridge |
160:5571c4ff569f | 1035 | * @brief Verify the CRYP AES ciphering/deciphering/authentication algorithm phase. |
Anna Bridge |
160:5571c4ff569f | 1036 | * @param __PHASE__: CRYP AES ciphering/deciphering/authentication algorithm phase. |
Anna Bridge |
160:5571c4ff569f | 1037 | * @retval SET (__PHASE__ is valid) or RESET (__PHASE__ is invalid) |
Anna Bridge |
160:5571c4ff569f | 1038 | */ |
Anna Bridge |
160:5571c4ff569f | 1039 | #define IS_CRYP_GCMCMAC_PHASE(__PHASE__) (((__PHASE__) == CRYP_GCM_INIT_PHASE) || \ |
Anna Bridge |
160:5571c4ff569f | 1040 | ((__PHASE__) == CRYP_GCMCMAC_HEADER_PHASE) || \ |
Anna Bridge |
160:5571c4ff569f | 1041 | ((__PHASE__) == CRYP_GCM_PAYLOAD_PHASE) || \ |
Anna Bridge |
160:5571c4ff569f | 1042 | ((__PHASE__) == CRYP_GCMCMAC_FINAL_PHASE)) |
Anna Bridge |
160:5571c4ff569f | 1043 | |
Anna Bridge |
160:5571c4ff569f | 1044 | /** |
Anna Bridge |
160:5571c4ff569f | 1045 | * @} |
Anna Bridge |
160:5571c4ff569f | 1046 | */ |
Anna Bridge |
160:5571c4ff569f | 1047 | |
Anna Bridge |
160:5571c4ff569f | 1048 | /* Include CRYP HAL Extended module */ |
Anna Bridge |
160:5571c4ff569f | 1049 | #include "stm32f4xx_hal_cryp_ex.h" |
Anna Bridge |
160:5571c4ff569f | 1050 | |
Anna Bridge |
160:5571c4ff569f | 1051 | /* Exported functions --------------------------------------------------------*/ |
Anna Bridge |
160:5571c4ff569f | 1052 | /** @addtogroup CRYP_Exported_Functions CRYP Exported Functions |
Anna Bridge |
160:5571c4ff569f | 1053 | * @{ |
Anna Bridge |
160:5571c4ff569f | 1054 | */ |
Anna Bridge |
160:5571c4ff569f | 1055 | |
Anna Bridge |
160:5571c4ff569f | 1056 | /** @addtogroup CRYP_Exported_Functions_Group1 Initialization and deinitialization functions |
Anna Bridge |
160:5571c4ff569f | 1057 | * @{ |
Anna Bridge |
160:5571c4ff569f | 1058 | */ |
Anna Bridge |
160:5571c4ff569f | 1059 | |
Anna Bridge |
160:5571c4ff569f | 1060 | /* Initialization/de-initialization functions ********************************/ |
Anna Bridge |
160:5571c4ff569f | 1061 | HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1062 | HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1063 | |
Anna Bridge |
160:5571c4ff569f | 1064 | /* MSP initialization/de-initialization functions ****************************/ |
Anna Bridge |
160:5571c4ff569f | 1065 | void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1066 | void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1067 | |
Anna Bridge |
160:5571c4ff569f | 1068 | /** |
Anna Bridge |
160:5571c4ff569f | 1069 | * @} |
Anna Bridge |
160:5571c4ff569f | 1070 | */ |
Anna Bridge |
160:5571c4ff569f | 1071 | |
Anna Bridge |
160:5571c4ff569f | 1072 | /** @addtogroup CRYP_Exported_Functions_Group2 AES processing functions |
Anna Bridge |
160:5571c4ff569f | 1073 | * @{ |
Anna Bridge |
160:5571c4ff569f | 1074 | */ |
Anna Bridge |
160:5571c4ff569f | 1075 | |
Anna Bridge |
160:5571c4ff569f | 1076 | /* AES encryption/decryption processing functions ****************************/ |
Anna Bridge |
160:5571c4ff569f | 1077 | |
Anna Bridge |
160:5571c4ff569f | 1078 | /* AES encryption/decryption using polling ***********************************/ |
Anna Bridge |
160:5571c4ff569f | 1079 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 1080 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 1081 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 1082 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 1083 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 1084 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Anna Bridge |
160:5571c4ff569f | 1085 | |
Anna Bridge |
160:5571c4ff569f | 1086 | /* AES encryption/decryption using interrupt *********************************/ |
Anna Bridge |
160:5571c4ff569f | 1087 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 1088 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 1089 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 1090 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 1091 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 1092 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 1093 | |
Anna Bridge |
160:5571c4ff569f | 1094 | /* AES encryption/decryption using DMA ***************************************/ |
Anna Bridge |
160:5571c4ff569f | 1095 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 1096 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 1097 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 1098 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 1099 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Anna Bridge |
160:5571c4ff569f | 1100 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Anna Bridge |
160:5571c4ff569f | 1101 | |
Anna Bridge |
160:5571c4ff569f | 1102 | /** |
Anna Bridge |
160:5571c4ff569f | 1103 | * @} |
Anna Bridge |
160:5571c4ff569f | 1104 | */ |
Anna Bridge |
160:5571c4ff569f | 1105 | |
Anna Bridge |
160:5571c4ff569f | 1106 | /** @addtogroup CRYP_Exported_Functions_Group3 Callback functions |
Anna Bridge |
160:5571c4ff569f | 1107 | * @{ |
Anna Bridge |
160:5571c4ff569f | 1108 | */ |
Anna Bridge |
160:5571c4ff569f | 1109 | /* CallBack functions ********************************************************/ |
Anna Bridge |
160:5571c4ff569f | 1110 | void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1111 | void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1112 | void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1113 | |
Anna Bridge |
160:5571c4ff569f | 1114 | /** |
Anna Bridge |
160:5571c4ff569f | 1115 | * @} |
Anna Bridge |
160:5571c4ff569f | 1116 | */ |
Anna Bridge |
160:5571c4ff569f | 1117 | |
Anna Bridge |
160:5571c4ff569f | 1118 | /** @addtogroup CRYP_Exported_Functions_Group4 CRYP IRQ handler |
Anna Bridge |
160:5571c4ff569f | 1119 | * @{ |
Anna Bridge |
160:5571c4ff569f | 1120 | */ |
Anna Bridge |
160:5571c4ff569f | 1121 | |
Anna Bridge |
160:5571c4ff569f | 1122 | /* AES interrupt handling function *******************************************/ |
Anna Bridge |
160:5571c4ff569f | 1123 | void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1124 | |
Anna Bridge |
160:5571c4ff569f | 1125 | /** |
Anna Bridge |
160:5571c4ff569f | 1126 | * @} |
Anna Bridge |
160:5571c4ff569f | 1127 | */ |
Anna Bridge |
160:5571c4ff569f | 1128 | |
Anna Bridge |
160:5571c4ff569f | 1129 | /** @addtogroup CRYP_Exported_Functions_Group5 Peripheral State functions |
Anna Bridge |
160:5571c4ff569f | 1130 | * @{ |
Anna Bridge |
160:5571c4ff569f | 1131 | */ |
Anna Bridge |
160:5571c4ff569f | 1132 | |
Anna Bridge |
160:5571c4ff569f | 1133 | /* Peripheral State functions ************************************************/ |
Anna Bridge |
160:5571c4ff569f | 1134 | HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1135 | uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp); |
Anna Bridge |
160:5571c4ff569f | 1136 | |
Anna Bridge |
160:5571c4ff569f | 1137 | /** |
Anna Bridge |
160:5571c4ff569f | 1138 | * @} |
Anna Bridge |
160:5571c4ff569f | 1139 | */ |
Anna Bridge |
160:5571c4ff569f | 1140 | |
Anna Bridge |
160:5571c4ff569f | 1141 | /** |
Anna Bridge |
160:5571c4ff569f | 1142 | * @} |
Anna Bridge |
160:5571c4ff569f | 1143 | */ |
Anna Bridge |
160:5571c4ff569f | 1144 | |
Anna Bridge |
160:5571c4ff569f | 1145 | |
Anna Bridge |
160:5571c4ff569f | 1146 | #endif /* AES */ |
Anna Bridge |
160:5571c4ff569f | 1147 | |
Anna Bridge |
160:5571c4ff569f | 1148 | /** |
Anna Bridge |
160:5571c4ff569f | 1149 | * @} |
Anna Bridge |
160:5571c4ff569f | 1150 | */ |
Anna Bridge |
160:5571c4ff569f | 1151 | |
Anna Bridge |
160:5571c4ff569f | 1152 | /** |
Anna Bridge |
160:5571c4ff569f | 1153 | * @} |
Anna Bridge |
160:5571c4ff569f | 1154 | */ |
Anna Bridge |
160:5571c4ff569f | 1155 | |
Anna Bridge |
160:5571c4ff569f | 1156 | #ifdef __cplusplus |
Anna Bridge |
160:5571c4ff569f | 1157 | } |
Anna Bridge |
160:5571c4ff569f | 1158 | #endif |
Anna Bridge |
160:5571c4ff569f | 1159 | |
Anna Bridge |
160:5571c4ff569f | 1160 | #endif /* __STM32F4xx_HAL_CRYP_H */ |
Anna Bridge |
160:5571c4ff569f | 1161 | |
Anna Bridge |
160:5571c4ff569f | 1162 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |