Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.
Dependents: 1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB
Fork of mbed by
TARGET_DISCO_L476VG/stm32l4xx_hal_cryp.h@107:4f6c30876dfa, 2015-09-16 (annotated)
- Committer:
- Kojto
- Date:
- Wed Sep 16 15:32:31 2015 +0100
- Revision:
- 107:4f6c30876dfa
Release 107 of the mbed library
Changes:
- new platforms - DISCO_F746NG, DISCO_L476VG, NUCLEO_L476RG
- KL43Z - bugfix RTC init function
- K20 - SPI mode fix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 107:4f6c30876dfa | 1 | /** |
Kojto | 107:4f6c30876dfa | 2 | ****************************************************************************** |
Kojto | 107:4f6c30876dfa | 3 | * @file stm32l4xx_hal_cryp.h |
Kojto | 107:4f6c30876dfa | 4 | * @author MCD Application Team |
Kojto | 107:4f6c30876dfa | 5 | * @version V1.0.0 |
Kojto | 107:4f6c30876dfa | 6 | * @date 26-June-2015 |
Kojto | 107:4f6c30876dfa | 7 | * @brief Header file of CRYP HAL module. |
Kojto | 107:4f6c30876dfa | 8 | ****************************************************************************** |
Kojto | 107:4f6c30876dfa | 9 | * @attention |
Kojto | 107:4f6c30876dfa | 10 | * |
Kojto | 107:4f6c30876dfa | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
Kojto | 107:4f6c30876dfa | 12 | * |
Kojto | 107:4f6c30876dfa | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Kojto | 107:4f6c30876dfa | 14 | * are permitted provided that the following conditions are met: |
Kojto | 107:4f6c30876dfa | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Kojto | 107:4f6c30876dfa | 16 | * this list of conditions and the following disclaimer. |
Kojto | 107:4f6c30876dfa | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Kojto | 107:4f6c30876dfa | 18 | * this list of conditions and the following disclaimer in the documentation |
Kojto | 107:4f6c30876dfa | 19 | * and/or other materials provided with the distribution. |
Kojto | 107:4f6c30876dfa | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Kojto | 107:4f6c30876dfa | 21 | * may be used to endorse or promote products derived from this software |
Kojto | 107:4f6c30876dfa | 22 | * without specific prior written permission. |
Kojto | 107:4f6c30876dfa | 23 | * |
Kojto | 107:4f6c30876dfa | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Kojto | 107:4f6c30876dfa | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Kojto | 107:4f6c30876dfa | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Kojto | 107:4f6c30876dfa | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Kojto | 107:4f6c30876dfa | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Kojto | 107:4f6c30876dfa | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Kojto | 107:4f6c30876dfa | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Kojto | 107:4f6c30876dfa | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Kojto | 107:4f6c30876dfa | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Kojto | 107:4f6c30876dfa | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 107:4f6c30876dfa | 34 | * |
Kojto | 107:4f6c30876dfa | 35 | ****************************************************************************** |
Kojto | 107:4f6c30876dfa | 36 | */ |
Kojto | 107:4f6c30876dfa | 37 | |
Kojto | 107:4f6c30876dfa | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 39 | #ifndef __STM32L4xx_HAL_CRYP_H |
Kojto | 107:4f6c30876dfa | 40 | #define __STM32L4xx_HAL_CRYP_H |
Kojto | 107:4f6c30876dfa | 41 | |
Kojto | 107:4f6c30876dfa | 42 | #ifdef __cplusplus |
Kojto | 107:4f6c30876dfa | 43 | extern "C" { |
Kojto | 107:4f6c30876dfa | 44 | #endif |
Kojto | 107:4f6c30876dfa | 45 | |
Kojto | 107:4f6c30876dfa | 46 | #if defined(STM32L485xx) || defined(STM32L486xx) |
Kojto | 107:4f6c30876dfa | 47 | |
Kojto | 107:4f6c30876dfa | 48 | /* Includes ------------------------------------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 49 | #include "stm32l4xx_hal_def.h" |
Kojto | 107:4f6c30876dfa | 50 | |
Kojto | 107:4f6c30876dfa | 51 | /** @addtogroup STM32L4xx_HAL_Driver |
Kojto | 107:4f6c30876dfa | 52 | * @{ |
Kojto | 107:4f6c30876dfa | 53 | */ |
Kojto | 107:4f6c30876dfa | 54 | |
Kojto | 107:4f6c30876dfa | 55 | /** @addtogroup CRYP |
Kojto | 107:4f6c30876dfa | 56 | * @{ |
Kojto | 107:4f6c30876dfa | 57 | */ |
Kojto | 107:4f6c30876dfa | 58 | |
Kojto | 107:4f6c30876dfa | 59 | /* Exported types ------------------------------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 60 | /** @defgroup CRYP_Exported_Types CRYP Exported Types |
Kojto | 107:4f6c30876dfa | 61 | * @{ |
Kojto | 107:4f6c30876dfa | 62 | */ |
Kojto | 107:4f6c30876dfa | 63 | |
Kojto | 107:4f6c30876dfa | 64 | /** |
Kojto | 107:4f6c30876dfa | 65 | * @brief CRYP Configuration Structure definition |
Kojto | 107:4f6c30876dfa | 66 | */ |
Kojto | 107:4f6c30876dfa | 67 | typedef struct |
Kojto | 107:4f6c30876dfa | 68 | { |
Kojto | 107:4f6c30876dfa | 69 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
Kojto | 107:4f6c30876dfa | 70 | This parameter can be a value of @ref CRYP_Data_Type */ |
Kojto | 107:4f6c30876dfa | 71 | |
Kojto | 107:4f6c30876dfa | 72 | uint32_t KeySize; /*!< 128 or 256-bit key length. |
Kojto | 107:4f6c30876dfa | 73 | This parameter can be a value of @ref CRYP_Key_Size */ |
Kojto | 107:4f6c30876dfa | 74 | |
Kojto | 107:4f6c30876dfa | 75 | uint32_t OperatingMode; /*!< AES operating mode. |
Kojto | 107:4f6c30876dfa | 76 | This parameter can be a value of @ref CRYP_AES_OperatingMode */ |
Kojto | 107:4f6c30876dfa | 77 | |
Kojto | 107:4f6c30876dfa | 78 | uint32_t ChainingMode; /*!< AES chaining mode. |
Kojto | 107:4f6c30876dfa | 79 | This parameter can be a value of @ref CRYP_AES_ChainingMode */ |
Kojto | 107:4f6c30876dfa | 80 | |
Kojto | 107:4f6c30876dfa | 81 | uint32_t KeyWriteFlag; /*!< Allows to bypass or not key write-up before decryption. |
Kojto | 107:4f6c30876dfa | 82 | This parameter can be a value of @ref CRYP_Key_Write */ |
Kojto | 107:4f6c30876dfa | 83 | |
Kojto | 107:4f6c30876dfa | 84 | uint32_t GCMCMACPhase; /*!< Indicates the processing phase of the Galois Counter Mode (GCM), |
Kojto | 107:4f6c30876dfa | 85 | Galois Message Authentication Code (GMAC) or Cipher Message |
Kojto | 107:4f6c30876dfa | 86 | Authentication Code (CMAC) mode. |
Kojto | 107:4f6c30876dfa | 87 | This parameter can be a value of @ref CRYP_GCM_CMAC_Phase */ |
Kojto | 107:4f6c30876dfa | 88 | |
Kojto | 107:4f6c30876dfa | 89 | uint8_t* pKey; /*!< Encryption/Decryption Key */ |
Kojto | 107:4f6c30876dfa | 90 | |
Kojto | 107:4f6c30876dfa | 91 | uint8_t* pInitVect; /*!< Initialization Vector used for CTR, CBC, GCM/GMAC and CMAC modes */ |
Kojto | 107:4f6c30876dfa | 92 | |
Kojto | 107:4f6c30876dfa | 93 | uint8_t* Header; /*!< Header used in GCM/GMAC and CMAC modes */ |
Kojto | 107:4f6c30876dfa | 94 | |
Kojto | 107:4f6c30876dfa | 95 | uint64_t HeaderSize; /*!< Header size in bytes */ |
Kojto | 107:4f6c30876dfa | 96 | |
Kojto | 107:4f6c30876dfa | 97 | }CRYP_InitTypeDef; |
Kojto | 107:4f6c30876dfa | 98 | |
Kojto | 107:4f6c30876dfa | 99 | /** |
Kojto | 107:4f6c30876dfa | 100 | * @brief HAL CRYP State structures definition |
Kojto | 107:4f6c30876dfa | 101 | */ |
Kojto | 107:4f6c30876dfa | 102 | typedef enum |
Kojto | 107:4f6c30876dfa | 103 | { |
Kojto | 107:4f6c30876dfa | 104 | HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */ |
Kojto | 107:4f6c30876dfa | 105 | HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */ |
Kojto | 107:4f6c30876dfa | 106 | HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */ |
Kojto | 107:4f6c30876dfa | 107 | HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */ |
Kojto | 107:4f6c30876dfa | 108 | HAL_CRYP_STATE_ERROR = 0x04, /*!< CRYP error state */ |
Kojto | 107:4f6c30876dfa | 109 | HAL_CRYP_STATE_SUSPENDED = 0x05 /*!< CRYP suspended */ |
Kojto | 107:4f6c30876dfa | 110 | }HAL_CRYP_STATETypeDef; |
Kojto | 107:4f6c30876dfa | 111 | |
Kojto | 107:4f6c30876dfa | 112 | /** |
Kojto | 107:4f6c30876dfa | 113 | * @brief HAL CRYP phase structures definition |
Kojto | 107:4f6c30876dfa | 114 | */ |
Kojto | 107:4f6c30876dfa | 115 | typedef enum |
Kojto | 107:4f6c30876dfa | 116 | { |
Kojto | 107:4f6c30876dfa | 117 | HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */ |
Kojto | 107:4f6c30876dfa | 118 | HAL_CRYP_PHASE_PROCESS = 0x02, /*!< CRYP peripheral is in processing phase */ |
Kojto | 107:4f6c30876dfa | 119 | HAL_CRYP_PHASE_START = 0x03, /*!< CRYP peripheral has been initialized but GCM/GMAC/CMAC |
Kojto | 107:4f6c30876dfa | 120 | initialization phase has not started */ |
Kojto | 107:4f6c30876dfa | 121 | HAL_CRYP_PHASE_INIT_OVER = 0x04, /*!< GCM/GMAC/CMAC init phase has been carried out */ |
Kojto | 107:4f6c30876dfa | 122 | HAL_CRYP_PHASE_HEADER_OVER = 0x05, /*!< GCM/GMAC/CMAC header phase has been carried out */ |
Kojto | 107:4f6c30876dfa | 123 | HAL_CRYP_PHASE_PAYLOAD_OVER = 0x06, /*!< GCM/GMAC/CMAC payload phase has been carried out */ |
Kojto | 107:4f6c30876dfa | 124 | HAL_CRYP_PHASE_FINAL_OVER = 0x07, /*!< GCM/GMAC/CMAC final phase has been carried out */ |
Kojto | 107:4f6c30876dfa | 125 | HAL_CRYP_PHASE_HEADER_SUSPENDED = 0x08, /*!< GCM/GMAC/CMAC header phase has been suspended */ |
Kojto | 107:4f6c30876dfa | 126 | HAL_CRYP_PHASE_PAYLOAD_SUSPENDED = 0x09, /*!< GCM/GMAC payload phase has been suspended */ |
Kojto | 107:4f6c30876dfa | 127 | HAL_CRYP_PHASE_NOT_USED = 0x0a /*!< Phase is irrelevant to the current chaining mode */ |
Kojto | 107:4f6c30876dfa | 128 | }HAL_PhaseTypeDef; |
Kojto | 107:4f6c30876dfa | 129 | |
Kojto | 107:4f6c30876dfa | 130 | /** |
Kojto | 107:4f6c30876dfa | 131 | * @brief HAL CRYP mode suspend definitions |
Kojto | 107:4f6c30876dfa | 132 | */ |
Kojto | 107:4f6c30876dfa | 133 | typedef enum |
Kojto | 107:4f6c30876dfa | 134 | { |
Kojto | 107:4f6c30876dfa | 135 | HAL_CRYP_SUSPEND_NONE = 0x00, /*!< CRYP peripheral suspension not requested */ |
Kojto | 107:4f6c30876dfa | 136 | HAL_CRYP_SUSPEND = 0x01 /*!< CRYP peripheral suspension requested */ |
Kojto | 107:4f6c30876dfa | 137 | }HAL_SuspendTypeDef; |
Kojto | 107:4f6c30876dfa | 138 | |
Kojto | 107:4f6c30876dfa | 139 | |
Kojto | 107:4f6c30876dfa | 140 | /** |
Kojto | 107:4f6c30876dfa | 141 | * @brief HAL CRYP Error Codes definition |
Kojto | 107:4f6c30876dfa | 142 | */ |
Kojto | 107:4f6c30876dfa | 143 | #define HAL_CRYP_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ |
Kojto | 107:4f6c30876dfa | 144 | #define HAL_CRYP_WRITE_ERROR ((uint32_t)0x00000001) /*!< Write error */ |
Kojto | 107:4f6c30876dfa | 145 | #define HAL_CRYP_READ_ERROR ((uint32_t)0x00000002) /*!< Read error */ |
Kojto | 107:4f6c30876dfa | 146 | #define HAL_CRYP_DMA_ERROR ((uint32_t)0x00000004) /*!< DMA error */ |
Kojto | 107:4f6c30876dfa | 147 | |
Kojto | 107:4f6c30876dfa | 148 | |
Kojto | 107:4f6c30876dfa | 149 | /** |
Kojto | 107:4f6c30876dfa | 150 | * @brief CRYP handle Structure definition |
Kojto | 107:4f6c30876dfa | 151 | */ |
Kojto | 107:4f6c30876dfa | 152 | typedef struct |
Kojto | 107:4f6c30876dfa | 153 | { |
Kojto | 107:4f6c30876dfa | 154 | AES_TypeDef *Instance; /*!< Register base address */ |
Kojto | 107:4f6c30876dfa | 155 | |
Kojto | 107:4f6c30876dfa | 156 | CRYP_InitTypeDef Init; /*!< CRYP initialization parameters */ |
Kojto | 107:4f6c30876dfa | 157 | |
Kojto | 107:4f6c30876dfa | 158 | uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) input buffer */ |
Kojto | 107:4f6c30876dfa | 159 | |
Kojto | 107:4f6c30876dfa | 160 | uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) output buffer */ |
Kojto | 107:4f6c30876dfa | 161 | |
Kojto | 107:4f6c30876dfa | 162 | __IO uint16_t CrypInCount; /*!< Input data size in bytes or, after suspension, the remaining |
Kojto | 107:4f6c30876dfa | 163 | number of bytes to process */ |
Kojto | 107:4f6c30876dfa | 164 | |
Kojto | 107:4f6c30876dfa | 165 | __IO uint16_t CrypOutCount; /*!< Output data size in bytes */ |
Kojto | 107:4f6c30876dfa | 166 | |
Kojto | 107:4f6c30876dfa | 167 | HAL_PhaseTypeDef Phase; /*!< CRYP peripheral processing phase for GCM, GMAC or CMAC modes. |
Kojto | 107:4f6c30876dfa | 168 | Indicates the last phase carried out to ease |
Kojto | 107:4f6c30876dfa | 169 | phase transitions */ |
Kojto | 107:4f6c30876dfa | 170 | |
Kojto | 107:4f6c30876dfa | 171 | DMA_HandleTypeDef *hdmain; /*!< CRYP peripheral Input DMA handle parameters */ |
Kojto | 107:4f6c30876dfa | 172 | |
Kojto | 107:4f6c30876dfa | 173 | DMA_HandleTypeDef *hdmaout; /*!< CRYP peripheral Output DMA handle parameters */ |
Kojto | 107:4f6c30876dfa | 174 | |
Kojto | 107:4f6c30876dfa | 175 | HAL_LockTypeDef Lock; /*!< CRYP locking object */ |
Kojto | 107:4f6c30876dfa | 176 | |
Kojto | 107:4f6c30876dfa | 177 | __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ |
Kojto | 107:4f6c30876dfa | 178 | |
Kojto | 107:4f6c30876dfa | 179 | __IO uint32_t ErrorCode; /*!< CRYP peripheral error code */ |
Kojto | 107:4f6c30876dfa | 180 | |
Kojto | 107:4f6c30876dfa | 181 | HAL_SuspendTypeDef SuspendRequest; /*!< CRYP peripheral suspension request flag */ |
Kojto | 107:4f6c30876dfa | 182 | }CRYP_HandleTypeDef; |
Kojto | 107:4f6c30876dfa | 183 | |
Kojto | 107:4f6c30876dfa | 184 | /** |
Kojto | 107:4f6c30876dfa | 185 | * @} |
Kojto | 107:4f6c30876dfa | 186 | */ |
Kojto | 107:4f6c30876dfa | 187 | |
Kojto | 107:4f6c30876dfa | 188 | |
Kojto | 107:4f6c30876dfa | 189 | /* Exported constants --------------------------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 190 | /** @defgroup CRYP_Exported_Constants CRYP Exported Constants |
Kojto | 107:4f6c30876dfa | 191 | * @{ |
Kojto | 107:4f6c30876dfa | 192 | */ |
Kojto | 107:4f6c30876dfa | 193 | |
Kojto | 107:4f6c30876dfa | 194 | /** @defgroup CRYP_Key_Size Key size selection |
Kojto | 107:4f6c30876dfa | 195 | * @{ |
Kojto | 107:4f6c30876dfa | 196 | */ |
Kojto | 107:4f6c30876dfa | 197 | #define CRYP_KEYSIZE_128B ((uint32_t)0x00000000) /*!< 128-bit long key */ |
Kojto | 107:4f6c30876dfa | 198 | #define CRYP_KEYSIZE_256B AES_CR_KEYSIZE /*!< 256-bit long key */ |
Kojto | 107:4f6c30876dfa | 199 | /** |
Kojto | 107:4f6c30876dfa | 200 | * @} |
Kojto | 107:4f6c30876dfa | 201 | */ |
Kojto | 107:4f6c30876dfa | 202 | |
Kojto | 107:4f6c30876dfa | 203 | /** @defgroup CRYP_Data_Type AES Data Type selection |
Kojto | 107:4f6c30876dfa | 204 | * @{ |
Kojto | 107:4f6c30876dfa | 205 | */ |
Kojto | 107:4f6c30876dfa | 206 | #define CRYP_DATATYPE_32B ((uint32_t)0x00000000) /*!< 32-bit data type (no swapping) */ |
Kojto | 107:4f6c30876dfa | 207 | #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */ |
Kojto | 107:4f6c30876dfa | 208 | #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */ |
Kojto | 107:4f6c30876dfa | 209 | #define CRYP_DATATYPE_1B AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */ |
Kojto | 107:4f6c30876dfa | 210 | /** |
Kojto | 107:4f6c30876dfa | 211 | * @} |
Kojto | 107:4f6c30876dfa | 212 | */ |
Kojto | 107:4f6c30876dfa | 213 | |
Kojto | 107:4f6c30876dfa | 214 | /** @defgroup CRYP_AES_State AES Enable state |
Kojto | 107:4f6c30876dfa | 215 | * @{ |
Kojto | 107:4f6c30876dfa | 216 | */ |
Kojto | 107:4f6c30876dfa | 217 | #define CRYP_AES_DISABLE ((uint32_t)0x00000000) /*!< Disable AES */ |
Kojto | 107:4f6c30876dfa | 218 | #define CRYP_AES_ENABLE AES_CR_EN /*!< Enable AES */ |
Kojto | 107:4f6c30876dfa | 219 | /** |
Kojto | 107:4f6c30876dfa | 220 | * @} |
Kojto | 107:4f6c30876dfa | 221 | */ |
Kojto | 107:4f6c30876dfa | 222 | |
Kojto | 107:4f6c30876dfa | 223 | /** @defgroup CRYP_AES_OperatingMode AES operating mode |
Kojto | 107:4f6c30876dfa | 224 | * @{ |
Kojto | 107:4f6c30876dfa | 225 | */ |
Kojto | 107:4f6c30876dfa | 226 | #define CRYP_ALGOMODE_ENCRYPT ((uint32_t)0x00000000) /*!< Encryption mode */ |
Kojto | 107:4f6c30876dfa | 227 | #define CRYP_ALGOMODE_KEYDERIVATION AES_CR_MODE_0 /*!< Key derivation mode */ |
Kojto | 107:4f6c30876dfa | 228 | #define CRYP_ALGOMODE_DECRYPT AES_CR_MODE_1 /*!< Decryption */ |
Kojto | 107:4f6c30876dfa | 229 | #define CRYP_ALGOMODE_KEYDERIVATION_DECRYPT AES_CR_MODE /*!< Key derivation and decryption */ |
Kojto | 107:4f6c30876dfa | 230 | #define CRYP_ALGOMODE_TAG_GENERATION ((uint32_t)0x00000000) /*!< GMAC or CMAC authentication tag generation */ |
Kojto | 107:4f6c30876dfa | 231 | /** |
Kojto | 107:4f6c30876dfa | 232 | * @} |
Kojto | 107:4f6c30876dfa | 233 | */ |
Kojto | 107:4f6c30876dfa | 234 | |
Kojto | 107:4f6c30876dfa | 235 | /** @defgroup CRYP_AES_ChainingMode AES chaining mode |
Kojto | 107:4f6c30876dfa | 236 | * @{ |
Kojto | 107:4f6c30876dfa | 237 | */ |
Kojto | 107:4f6c30876dfa | 238 | #define CRYP_CHAINMODE_AES_ECB ((uint32_t)0x00000000) /*!< Electronic codebook chaining algorithm */ |
Kojto | 107:4f6c30876dfa | 239 | #define CRYP_CHAINMODE_AES_CBC AES_CR_CHMOD_0 /*!< Cipher block chaining algorithm */ |
Kojto | 107:4f6c30876dfa | 240 | #define CRYP_CHAINMODE_AES_CTR AES_CR_CHMOD_1 /*!< Counter mode chaining algorithm */ |
Kojto | 107:4f6c30876dfa | 241 | #define CRYP_CHAINMODE_AES_GCM_GMAC (AES_CR_CHMOD_0 | AES_CR_CHMOD_1) /*!< Galois counter mode - Galois message authentication code */ |
Kojto | 107:4f6c30876dfa | 242 | #define CRYP_CHAINMODE_AES_CMAC AES_CR_CHMOD_2 /*!< Cipher message authentication code */ |
Kojto | 107:4f6c30876dfa | 243 | /** |
Kojto | 107:4f6c30876dfa | 244 | * @} |
Kojto | 107:4f6c30876dfa | 245 | */ |
Kojto | 107:4f6c30876dfa | 246 | |
Kojto | 107:4f6c30876dfa | 247 | /** @defgroup CRYP_Key_Write AES decryption key write-up flag |
Kojto | 107:4f6c30876dfa | 248 | * @{ |
Kojto | 107:4f6c30876dfa | 249 | */ |
Kojto | 107:4f6c30876dfa | 250 | #define CRYP_KEY_WRITE_ENABLE ((uint32_t)0x00000000) /*!< Enable decryption key writing */ |
Kojto | 107:4f6c30876dfa | 251 | #define CRYP_KEY_WRITE_DISABLE ((uint32_t)0x00000001) /*!< Disable decryption key writing */ |
Kojto | 107:4f6c30876dfa | 252 | /** |
Kojto | 107:4f6c30876dfa | 253 | * @} |
Kojto | 107:4f6c30876dfa | 254 | */ |
Kojto | 107:4f6c30876dfa | 255 | |
Kojto | 107:4f6c30876dfa | 256 | /** @defgroup CRYP_DMAIN DMA Input phase management enable state |
Kojto | 107:4f6c30876dfa | 257 | * @{ |
Kojto | 107:4f6c30876dfa | 258 | */ |
Kojto | 107:4f6c30876dfa | 259 | #define CRYP_DMAIN_DISABLE ((uint32_t)0x00000000) /*!< Disable DMA Input phase management */ |
Kojto | 107:4f6c30876dfa | 260 | #define CRYP_DMAIN_ENABLE AES_CR_DMAINEN /*!< Enable DMA Input phase management */ |
Kojto | 107:4f6c30876dfa | 261 | /** |
Kojto | 107:4f6c30876dfa | 262 | * @} |
Kojto | 107:4f6c30876dfa | 263 | */ |
Kojto | 107:4f6c30876dfa | 264 | |
Kojto | 107:4f6c30876dfa | 265 | /** @defgroup CRYP_DMAOUT DMA Output phase management enable state |
Kojto | 107:4f6c30876dfa | 266 | * @{ |
Kojto | 107:4f6c30876dfa | 267 | */ |
Kojto | 107:4f6c30876dfa | 268 | #define CRYP_DMAOUT_DISABLE ((uint32_t)0x00000000) /*!< Disable DMA Output phase management */ |
Kojto | 107:4f6c30876dfa | 269 | #define CRYP_DMAOUT_ENABLE AES_CR_DMAOUTEN /*!< Enable DMA Output phase management */ |
Kojto | 107:4f6c30876dfa | 270 | /** |
Kojto | 107:4f6c30876dfa | 271 | * @} |
Kojto | 107:4f6c30876dfa | 272 | */ |
Kojto | 107:4f6c30876dfa | 273 | |
Kojto | 107:4f6c30876dfa | 274 | |
Kojto | 107:4f6c30876dfa | 275 | /** @defgroup CRYP_GCM_CMAC_Phase GCM/GMAC and CMAC processing phase selection |
Kojto | 107:4f6c30876dfa | 276 | * @{ |
Kojto | 107:4f6c30876dfa | 277 | */ |
Kojto | 107:4f6c30876dfa | 278 | #define CRYP_GCM_INIT_PHASE ((uint32_t)0x00000000) /*!< GCM/GMAC init phase */ |
Kojto | 107:4f6c30876dfa | 279 | #define CRYP_GCMCMAC_HEADER_PHASE AES_CR_GCMPH_0 /*!< GCM/GMAC or CMAC header phase */ |
Kojto | 107:4f6c30876dfa | 280 | #define CRYP_GCM_PAYLOAD_PHASE AES_CR_GCMPH_1 /*!< GCM payload phaset */ |
Kojto | 107:4f6c30876dfa | 281 | #define CRYP_GCMCMAC_FINAL_PHASE AES_CR_GCMPH /*!< GCM/GMAC or CMAC final phase */ |
Kojto | 107:4f6c30876dfa | 282 | /** |
Kojto | 107:4f6c30876dfa | 283 | * @} |
Kojto | 107:4f6c30876dfa | 284 | */ |
Kojto | 107:4f6c30876dfa | 285 | |
Kojto | 107:4f6c30876dfa | 286 | /** @defgroup CRYP_Flags AES status flags |
Kojto | 107:4f6c30876dfa | 287 | * @{ |
Kojto | 107:4f6c30876dfa | 288 | */ |
Kojto | 107:4f6c30876dfa | 289 | |
Kojto | 107:4f6c30876dfa | 290 | #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden */ |
Kojto | 107:4f6c30876dfa | 291 | #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error */ |
Kojto | 107:4f6c30876dfa | 292 | #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read error */ |
Kojto | 107:4f6c30876dfa | 293 | #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed */ |
Kojto | 107:4f6c30876dfa | 294 | /** |
Kojto | 107:4f6c30876dfa | 295 | * @} |
Kojto | 107:4f6c30876dfa | 296 | */ |
Kojto | 107:4f6c30876dfa | 297 | |
Kojto | 107:4f6c30876dfa | 298 | /** @defgroup CRYP_Clear_Flags AES clearing flags |
Kojto | 107:4f6c30876dfa | 299 | * @{ |
Kojto | 107:4f6c30876dfa | 300 | */ |
Kojto | 107:4f6c30876dfa | 301 | |
Kojto | 107:4f6c30876dfa | 302 | #define CRYP_CCF_CLEAR AES_CR_CCFC /*!< Computation Complete Flag Clear */ |
Kojto | 107:4f6c30876dfa | 303 | #define CRYP_ERR_CLEAR AES_CR_ERRC /*!< Error Flag Clear */ |
Kojto | 107:4f6c30876dfa | 304 | /** |
Kojto | 107:4f6c30876dfa | 305 | * @} |
Kojto | 107:4f6c30876dfa | 306 | */ |
Kojto | 107:4f6c30876dfa | 307 | |
Kojto | 107:4f6c30876dfa | 308 | /** @defgroup AES_Interrupts_Enable AES Interrupts Enable bits |
Kojto | 107:4f6c30876dfa | 309 | * @{ |
Kojto | 107:4f6c30876dfa | 310 | */ |
Kojto | 107:4f6c30876dfa | 311 | #define CRYP_IT_CCFIE AES_CR_CCFIE /*!< Computation Complete interrupt enable */ |
Kojto | 107:4f6c30876dfa | 312 | #define CRYP_IT_ERRIE AES_CR_ERRIE /*!< Error interrupt enable */ |
Kojto | 107:4f6c30876dfa | 313 | /** |
Kojto | 107:4f6c30876dfa | 314 | * @} |
Kojto | 107:4f6c30876dfa | 315 | */ |
Kojto | 107:4f6c30876dfa | 316 | |
Kojto | 107:4f6c30876dfa | 317 | /** @defgroup CRYP_Interrupts_Flags AES Interrupts flags |
Kojto | 107:4f6c30876dfa | 318 | * @{ |
Kojto | 107:4f6c30876dfa | 319 | */ |
Kojto | 107:4f6c30876dfa | 320 | #define CRYP_IT_WRERR AES_SR_WRERR /*!< Write Error */ |
Kojto | 107:4f6c30876dfa | 321 | #define CRYP_IT_RDERR AES_SR_RDERR /*!< Read Error */ |
Kojto | 107:4f6c30876dfa | 322 | #define CRYP_IT_CCF AES_SR_CCF /*!< Computation completed */ |
Kojto | 107:4f6c30876dfa | 323 | /** |
Kojto | 107:4f6c30876dfa | 324 | * @} |
Kojto | 107:4f6c30876dfa | 325 | */ |
Kojto | 107:4f6c30876dfa | 326 | |
Kojto | 107:4f6c30876dfa | 327 | /** |
Kojto | 107:4f6c30876dfa | 328 | * @} |
Kojto | 107:4f6c30876dfa | 329 | */ |
Kojto | 107:4f6c30876dfa | 330 | |
Kojto | 107:4f6c30876dfa | 331 | /* Exported macros -----------------------------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 332 | /** @defgroup CRYP_Exported_Macros CRYP Exported Macros |
Kojto | 107:4f6c30876dfa | 333 | * @{ |
Kojto | 107:4f6c30876dfa | 334 | */ |
Kojto | 107:4f6c30876dfa | 335 | |
Kojto | 107:4f6c30876dfa | 336 | /** @brief Reset CRYP handle state. |
Kojto | 107:4f6c30876dfa | 337 | * @param __HANDLE__: specifies the CRYP handle. |
Kojto | 107:4f6c30876dfa | 338 | * @retval None |
Kojto | 107:4f6c30876dfa | 339 | */ |
Kojto | 107:4f6c30876dfa | 340 | #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) |
Kojto | 107:4f6c30876dfa | 341 | |
Kojto | 107:4f6c30876dfa | 342 | /** |
Kojto | 107:4f6c30876dfa | 343 | * @brief Enable the CRYP AES peripheral. |
Kojto | 107:4f6c30876dfa | 344 | * @retval None |
Kojto | 107:4f6c30876dfa | 345 | */ |
Kojto | 107:4f6c30876dfa | 346 | #define __HAL_CRYP_ENABLE() (AES->CR |= AES_CR_EN) |
Kojto | 107:4f6c30876dfa | 347 | |
Kojto | 107:4f6c30876dfa | 348 | /** |
Kojto | 107:4f6c30876dfa | 349 | * @brief Disable the CRYP AES peripheral. |
Kojto | 107:4f6c30876dfa | 350 | * @retval None |
Kojto | 107:4f6c30876dfa | 351 | */ |
Kojto | 107:4f6c30876dfa | 352 | #define __HAL_CRYP_DISABLE() (AES->CR &= ~AES_CR_EN) |
Kojto | 107:4f6c30876dfa | 353 | |
Kojto | 107:4f6c30876dfa | 354 | /** |
Kojto | 107:4f6c30876dfa | 355 | * @brief Set the algorithm operating mode. |
Kojto | 107:4f6c30876dfa | 356 | * @param __OPERATING_MODE__: specifies the operating mode |
Kojto | 107:4f6c30876dfa | 357 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 358 | * @arg CRYP_ALGOMODE_ENCRYPT: encryption |
Kojto | 107:4f6c30876dfa | 359 | * @arg CRYP_ALGOMODE_KEYDERIVATION: key derivation |
Kojto | 107:4f6c30876dfa | 360 | * @arg CRYP_ALGOMODE_DECRYPT: decryption |
Kojto | 107:4f6c30876dfa | 361 | * @arg CRYP_ALGOMODE_KEYDERIVATION_DECRYPT: key derivation and decryption |
Kojto | 107:4f6c30876dfa | 362 | * @retval None |
Kojto | 107:4f6c30876dfa | 363 | */ |
Kojto | 107:4f6c30876dfa | 364 | #define __HAL_CRYP_SET_OPERATINGMODE(__OPERATING_MODE__) MODIFY_REG(AES->CR, AES_CR_MODE, (__OPERATING_MODE__)) |
Kojto | 107:4f6c30876dfa | 365 | |
Kojto | 107:4f6c30876dfa | 366 | |
Kojto | 107:4f6c30876dfa | 367 | /** |
Kojto | 107:4f6c30876dfa | 368 | * @brief Set the algorithm chaining mode. |
Kojto | 107:4f6c30876dfa | 369 | * @param __CHAINING_MODE__: specifies the chaining mode |
Kojto | 107:4f6c30876dfa | 370 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 371 | * @arg CRYP_CHAINMODE_AES_ECB: Electronic CodeBook |
Kojto | 107:4f6c30876dfa | 372 | * @arg CRYP_CHAINMODE_AES_CBC: Cipher Block Chaining |
Kojto | 107:4f6c30876dfa | 373 | * @arg CRYP_CHAINMODE_AES_CTR: CounTeR mode |
Kojto | 107:4f6c30876dfa | 374 | * @arg CRYP_CHAINMODE_AES_GCM_GMAC: Galois Counter Mode or Galois Message Authentication Code |
Kojto | 107:4f6c30876dfa | 375 | * @arg CRYP_CHAINMODE_AES_CMAC: Cipher Message Authentication Code |
Kojto | 107:4f6c30876dfa | 376 | * @retval None |
Kojto | 107:4f6c30876dfa | 377 | */ |
Kojto | 107:4f6c30876dfa | 378 | #define __HAL_CRYP_SET_CHAININGMODE(__CHAINING_MODE__) MODIFY_REG(AES->CR, AES_CR_CHMOD, (__CHAINING_MODE__)) |
Kojto | 107:4f6c30876dfa | 379 | |
Kojto | 107:4f6c30876dfa | 380 | |
Kojto | 107:4f6c30876dfa | 381 | |
Kojto | 107:4f6c30876dfa | 382 | /** @brief Check whether the specified CRYP status flag is set or not. |
Kojto | 107:4f6c30876dfa | 383 | * @param __FLAG__: specifies the flag to check. |
Kojto | 107:4f6c30876dfa | 384 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 385 | * @arg CRYP_FLAG_BUSY: GCM process suspension forbidden |
Kojto | 107:4f6c30876dfa | 386 | * @arg CRYP_IT_WRERR: Write Error |
Kojto | 107:4f6c30876dfa | 387 | * @arg CRYP_IT_RDERR: Read Error |
Kojto | 107:4f6c30876dfa | 388 | * @arg CRYP_IT_CCF: Computation Complete |
Kojto | 107:4f6c30876dfa | 389 | * @retval The state of __FLAG__ (TRUE or FALSE). |
Kojto | 107:4f6c30876dfa | 390 | */ |
Kojto | 107:4f6c30876dfa | 391 | #define __HAL_CRYP_GET_FLAG(__FLAG__) ((AES->SR & (__FLAG__)) == (__FLAG__)) |
Kojto | 107:4f6c30876dfa | 392 | |
Kojto | 107:4f6c30876dfa | 393 | |
Kojto | 107:4f6c30876dfa | 394 | /** @brief Clear the CRYP pending status flag. |
Kojto | 107:4f6c30876dfa | 395 | * @param __FLAG__: specifies the flag to clear. |
Kojto | 107:4f6c30876dfa | 396 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 397 | * @arg CRYP_ERR_CLEAR: Read (RDERR) or Write Error (WRERR) Flag Clear |
Kojto | 107:4f6c30876dfa | 398 | * @arg CRYP_CCF_CLEAR: Computation Complete Flag (CCF) Clear |
Kojto | 107:4f6c30876dfa | 399 | * @retval None |
Kojto | 107:4f6c30876dfa | 400 | */ |
Kojto | 107:4f6c30876dfa | 401 | #define __HAL_CRYP_CLEAR_FLAG(__FLAG__) SET_BIT(AES->CR, (__FLAG__)) |
Kojto | 107:4f6c30876dfa | 402 | |
Kojto | 107:4f6c30876dfa | 403 | |
Kojto | 107:4f6c30876dfa | 404 | |
Kojto | 107:4f6c30876dfa | 405 | /** @brief Check whether the specified CRYP interrupt source is enabled or not. |
Kojto | 107:4f6c30876dfa | 406 | * @param __INTERRUPT__: CRYP interrupt source to check |
Kojto | 107:4f6c30876dfa | 407 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 408 | * @arg CRYP_IT_ERRIE: Error interrupt (used for RDERR and WRERR) |
Kojto | 107:4f6c30876dfa | 409 | * @arg CRYP_IT_CCFIE: Computation Complete interrupt |
Kojto | 107:4f6c30876dfa | 410 | * @retval State of interruption (TRUE or FALSE). |
Kojto | 107:4f6c30876dfa | 411 | */ |
Kojto | 107:4f6c30876dfa | 412 | #define __HAL_CRYP_GET_IT_SOURCE(__INTERRUPT__) ((AES->CR & (__INTERRUPT__)) == (__INTERRUPT__)) |
Kojto | 107:4f6c30876dfa | 413 | |
Kojto | 107:4f6c30876dfa | 414 | |
Kojto | 107:4f6c30876dfa | 415 | /** @brief Check whether the specified CRYP interrupt is set or not. |
Kojto | 107:4f6c30876dfa | 416 | * @param __INTERRUPT__: specifies the interrupt to check. |
Kojto | 107:4f6c30876dfa | 417 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 418 | * @arg CRYP_IT_WRERR: Write Error |
Kojto | 107:4f6c30876dfa | 419 | * @arg CRYP_IT_RDERR: Read Error |
Kojto | 107:4f6c30876dfa | 420 | * @arg CRYP_IT_CCF: Computation Complete |
Kojto | 107:4f6c30876dfa | 421 | * @retval The state of __INTERRUPT__ (TRUE or FALSE). |
Kojto | 107:4f6c30876dfa | 422 | */ |
Kojto | 107:4f6c30876dfa | 423 | #define __HAL_CRYP_GET_IT(__INTERRUPT__) ((AES->SR & (__INTERRUPT__)) == (__INTERRUPT__)) |
Kojto | 107:4f6c30876dfa | 424 | |
Kojto | 107:4f6c30876dfa | 425 | |
Kojto | 107:4f6c30876dfa | 426 | |
Kojto | 107:4f6c30876dfa | 427 | /** @brief Clear the CRYP pending interrupt. |
Kojto | 107:4f6c30876dfa | 428 | * @param __INTERRUPT__: specifies the IT to clear. |
Kojto | 107:4f6c30876dfa | 429 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 430 | * @arg CRYP_ERR_CLEAR: Read (RDERR) or Write Error (WRERR) Flag Clear |
Kojto | 107:4f6c30876dfa | 431 | * @arg CRYP_CCF_CLEAR: Computation Complete Flag (CCF) Clear |
Kojto | 107:4f6c30876dfa | 432 | * @retval None |
Kojto | 107:4f6c30876dfa | 433 | */ |
Kojto | 107:4f6c30876dfa | 434 | #define __HAL_CRYP_CLEAR_IT(__INTERRUPT__) SET_BIT(AES->CR, (__INTERRUPT__)) |
Kojto | 107:4f6c30876dfa | 435 | |
Kojto | 107:4f6c30876dfa | 436 | |
Kojto | 107:4f6c30876dfa | 437 | /** |
Kojto | 107:4f6c30876dfa | 438 | * @brief Enable the CRYP interrupt. |
Kojto | 107:4f6c30876dfa | 439 | * @param __INTERRUPT__: CRYP Interrupt. |
Kojto | 107:4f6c30876dfa | 440 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 441 | * @arg CRYP_IT_ERRIE: Error interrupt (used for RDERR and WRERR) |
Kojto | 107:4f6c30876dfa | 442 | * @arg CRYP_IT_CCFIE: Computation Complete interrupt |
Kojto | 107:4f6c30876dfa | 443 | * @retval None |
Kojto | 107:4f6c30876dfa | 444 | */ |
Kojto | 107:4f6c30876dfa | 445 | #define __HAL_CRYP_ENABLE_IT(__INTERRUPT__) ((AES->CR) |= (__INTERRUPT__)) |
Kojto | 107:4f6c30876dfa | 446 | |
Kojto | 107:4f6c30876dfa | 447 | |
Kojto | 107:4f6c30876dfa | 448 | /** |
Kojto | 107:4f6c30876dfa | 449 | * @brief Disable the CRYP interrupt. |
Kojto | 107:4f6c30876dfa | 450 | * @param __INTERRUPT__: CRYP Interrupt. |
Kojto | 107:4f6c30876dfa | 451 | * This parameter can be one of the following values: |
Kojto | 107:4f6c30876dfa | 452 | * @arg CRYP_IT_ERRIE: Error interrupt (used for RDERR and WRERR) |
Kojto | 107:4f6c30876dfa | 453 | * @arg CRYP_IT_CCFIE: Computation Complete interrupt |
Kojto | 107:4f6c30876dfa | 454 | * @retval None |
Kojto | 107:4f6c30876dfa | 455 | */ |
Kojto | 107:4f6c30876dfa | 456 | #define __HAL_CRYP_DISABLE_IT(__INTERRUPT__) ((AES->CR) &= ~(__INTERRUPT__)) |
Kojto | 107:4f6c30876dfa | 457 | |
Kojto | 107:4f6c30876dfa | 458 | /** |
Kojto | 107:4f6c30876dfa | 459 | * @} |
Kojto | 107:4f6c30876dfa | 460 | */ |
Kojto | 107:4f6c30876dfa | 461 | |
Kojto | 107:4f6c30876dfa | 462 | /* Private macros --------------------------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 463 | /** @addtogroup CRYP_Private_Macros CRYP Private Macros |
Kojto | 107:4f6c30876dfa | 464 | * @{ |
Kojto | 107:4f6c30876dfa | 465 | */ |
Kojto | 107:4f6c30876dfa | 466 | |
Kojto | 107:4f6c30876dfa | 467 | /** |
Kojto | 107:4f6c30876dfa | 468 | * @brief Verify the key size length. |
Kojto | 107:4f6c30876dfa | 469 | * @param __KEYSIZE__: Ciphering/deciphering algorithm key size. |
Kojto | 107:4f6c30876dfa | 470 | * @retval SET (__KEYSIZE__ is a valid value) or RESET (__KEYSIZE__ is invalid) |
Kojto | 107:4f6c30876dfa | 471 | */ |
Kojto | 107:4f6c30876dfa | 472 | #define IS_CRYP_KEYSIZE(__KEYSIZE__) (((__KEYSIZE__) == CRYP_KEYSIZE_128B) || \ |
Kojto | 107:4f6c30876dfa | 473 | ((__KEYSIZE__) == CRYP_KEYSIZE_256B)) |
Kojto | 107:4f6c30876dfa | 474 | |
Kojto | 107:4f6c30876dfa | 475 | /** |
Kojto | 107:4f6c30876dfa | 476 | * @brief Verify the input data type. |
Kojto | 107:4f6c30876dfa | 477 | * @param __DATATYPE__: Ciphering/deciphering algorithm input data type. |
Kojto | 107:4f6c30876dfa | 478 | * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid) |
Kojto | 107:4f6c30876dfa | 479 | */ |
Kojto | 107:4f6c30876dfa | 480 | #define IS_CRYP_DATATYPE(__DATATYPE__) (((__DATATYPE__) == CRYP_DATATYPE_32B) || \ |
Kojto | 107:4f6c30876dfa | 481 | ((__DATATYPE__) == CRYP_DATATYPE_16B) || \ |
Kojto | 107:4f6c30876dfa | 482 | ((__DATATYPE__) == CRYP_DATATYPE_8B) || \ |
Kojto | 107:4f6c30876dfa | 483 | ((__DATATYPE__) == CRYP_DATATYPE_1B)) |
Kojto | 107:4f6c30876dfa | 484 | |
Kojto | 107:4f6c30876dfa | 485 | /** |
Kojto | 107:4f6c30876dfa | 486 | * @brief Verify the CRYP AES IP running mode. |
Kojto | 107:4f6c30876dfa | 487 | * @param __MODE__: CRYP AES IP running mode. |
Kojto | 107:4f6c30876dfa | 488 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Kojto | 107:4f6c30876dfa | 489 | */ |
Kojto | 107:4f6c30876dfa | 490 | #define IS_CRYP_AES(__MODE__) (((__MODE__) == CRYP_AES_DISABLE) || \ |
Kojto | 107:4f6c30876dfa | 491 | ((__MODE__) == CRYP_AES_ENABLE)) |
Kojto | 107:4f6c30876dfa | 492 | |
Kojto | 107:4f6c30876dfa | 493 | /** |
Kojto | 107:4f6c30876dfa | 494 | * @brief Verify the selected CRYP algorithm. |
Kojto | 107:4f6c30876dfa | 495 | * @param __ALGOMODE__: Selected CRYP algorithm (ciphering, deciphering, key derivation or a combination of the latter). |
Kojto | 107:4f6c30876dfa | 496 | * @retval SET (__ALGOMODE__ is valid) or RESET (__ALGOMODE__ is invalid) |
Kojto | 107:4f6c30876dfa | 497 | */ |
Kojto | 107:4f6c30876dfa | 498 | #define IS_CRYP_ALGOMODE(__ALGOMODE__) (((__ALGOMODE__) == CRYP_ALGOMODE_ENCRYPT) || \ |
Kojto | 107:4f6c30876dfa | 499 | ((__ALGOMODE__) == CRYP_ALGOMODE_KEYDERIVATION) || \ |
Kojto | 107:4f6c30876dfa | 500 | ((__ALGOMODE__) == CRYP_ALGOMODE_DECRYPT) || \ |
Kojto | 107:4f6c30876dfa | 501 | ((__ALGOMODE__) == CRYP_ALGOMODE_TAG_GENERATION) || \ |
Kojto | 107:4f6c30876dfa | 502 | ((__ALGOMODE__) == CRYP_ALGOMODE_KEYDERIVATION_DECRYPT)) |
Kojto | 107:4f6c30876dfa | 503 | |
Kojto | 107:4f6c30876dfa | 504 | /** |
Kojto | 107:4f6c30876dfa | 505 | * @brief Verify the selected CRYP chaining algorithm. |
Kojto | 107:4f6c30876dfa | 506 | * @param __CHAINMODE__: Selected CRYP chaining algorithm. |
Kojto | 107:4f6c30876dfa | 507 | * @retval SET (__CHAINMODE__ is valid) or RESET (__CHAINMODE__ is invalid) |
Kojto | 107:4f6c30876dfa | 508 | */ |
Kojto | 107:4f6c30876dfa | 509 | #define IS_CRYP_CHAINMODE(__CHAINMODE__) (((__CHAINMODE__) == CRYP_CHAINMODE_AES_ECB) || \ |
Kojto | 107:4f6c30876dfa | 510 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CBC) || \ |
Kojto | 107:4f6c30876dfa | 511 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CTR) || \ |
Kojto | 107:4f6c30876dfa | 512 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_GCM_GMAC) || \ |
Kojto | 107:4f6c30876dfa | 513 | ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CMAC)) |
Kojto | 107:4f6c30876dfa | 514 | |
Kojto | 107:4f6c30876dfa | 515 | /** |
Kojto | 107:4f6c30876dfa | 516 | * @brief Verify the deciphering key write option. |
Kojto | 107:4f6c30876dfa | 517 | * @param __WRITE__: deciphering key write option. |
Kojto | 107:4f6c30876dfa | 518 | * @retval SET (__WRITE__ is valid) or RESET (__WRITE__ is invalid) |
Kojto | 107:4f6c30876dfa | 519 | */ |
Kojto | 107:4f6c30876dfa | 520 | #define IS_CRYP_WRITE(__WRITE__) (((__WRITE__) == CRYP_KEY_WRITE_ENABLE) || \ |
Kojto | 107:4f6c30876dfa | 521 | ((__WRITE__) == CRYP_KEY_WRITE_DISABLE)) |
Kojto | 107:4f6c30876dfa | 522 | |
Kojto | 107:4f6c30876dfa | 523 | /** |
Kojto | 107:4f6c30876dfa | 524 | * @brief Verify the CRYP input data DMA mode. |
Kojto | 107:4f6c30876dfa | 525 | * @param __MODE__: CRYP input data DMA mode. |
Kojto | 107:4f6c30876dfa | 526 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Kojto | 107:4f6c30876dfa | 527 | */ |
Kojto | 107:4f6c30876dfa | 528 | #define IS_CRYP_DMAIN(__MODE__) (((__MODE__) == CRYP_DMAIN_DISABLE) || \ |
Kojto | 107:4f6c30876dfa | 529 | ((__MODE__) == CRYP_DMAIN_ENABLE)) |
Kojto | 107:4f6c30876dfa | 530 | |
Kojto | 107:4f6c30876dfa | 531 | /** |
Kojto | 107:4f6c30876dfa | 532 | * @brief Verify the CRYP output data DMA mode. |
Kojto | 107:4f6c30876dfa | 533 | * @param __MODE__: CRYP output data DMA mode. |
Kojto | 107:4f6c30876dfa | 534 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
Kojto | 107:4f6c30876dfa | 535 | */ |
Kojto | 107:4f6c30876dfa | 536 | #define IS_CRYP_DMAOUT(__MODE__) (((__MODE__) == CRYP_DMAOUT_DISABLE) || \ |
Kojto | 107:4f6c30876dfa | 537 | ((__MODE__) == CRYP_DMAOUT_ENABLE)) |
Kojto | 107:4f6c30876dfa | 538 | |
Kojto | 107:4f6c30876dfa | 539 | /** |
Kojto | 107:4f6c30876dfa | 540 | * @brief Verify the CRYP AES ciphering/deciphering/authentication algorithm phase. |
Kojto | 107:4f6c30876dfa | 541 | * @param __PHASE__: CRYP AES ciphering/deciphering/authentication algorithm phase. |
Kojto | 107:4f6c30876dfa | 542 | * @retval SET (__PHASE__ is valid) or RESET (__PHASE__ is invalid) |
Kojto | 107:4f6c30876dfa | 543 | */ |
Kojto | 107:4f6c30876dfa | 544 | #define IS_CRYP_GCMCMAC_PHASE(__PHASE__) (((__PHASE__) == CRYP_GCM_INIT_PHASE) || \ |
Kojto | 107:4f6c30876dfa | 545 | ((__PHASE__) == CRYP_GCMCMAC_HEADER_PHASE) || \ |
Kojto | 107:4f6c30876dfa | 546 | ((__PHASE__) == CRYP_GCM_PAYLOAD_PHASE) || \ |
Kojto | 107:4f6c30876dfa | 547 | ((__PHASE__) == CRYP_GCMCMAC_FINAL_PHASE)) |
Kojto | 107:4f6c30876dfa | 548 | |
Kojto | 107:4f6c30876dfa | 549 | /** |
Kojto | 107:4f6c30876dfa | 550 | * @} |
Kojto | 107:4f6c30876dfa | 551 | */ |
Kojto | 107:4f6c30876dfa | 552 | |
Kojto | 107:4f6c30876dfa | 553 | /* Include CRYP HAL Extended module */ |
Kojto | 107:4f6c30876dfa | 554 | #include "stm32l4xx_hal_cryp_ex.h" |
Kojto | 107:4f6c30876dfa | 555 | |
Kojto | 107:4f6c30876dfa | 556 | /* Exported functions --------------------------------------------------------*/ |
Kojto | 107:4f6c30876dfa | 557 | /** @addtogroup CRYP_Exported_Functions CRYP Exported Functions |
Kojto | 107:4f6c30876dfa | 558 | * @{ |
Kojto | 107:4f6c30876dfa | 559 | */ |
Kojto | 107:4f6c30876dfa | 560 | |
Kojto | 107:4f6c30876dfa | 561 | /** @addtogroup CRYP_Group1 Initialization and deinitialization functions |
Kojto | 107:4f6c30876dfa | 562 | * @{ |
Kojto | 107:4f6c30876dfa | 563 | */ |
Kojto | 107:4f6c30876dfa | 564 | |
Kojto | 107:4f6c30876dfa | 565 | /* Initialization/de-initialization functions ********************************/ |
Kojto | 107:4f6c30876dfa | 566 | HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 567 | HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 568 | |
Kojto | 107:4f6c30876dfa | 569 | /* MSP initialization/de-initialization functions ****************************/ |
Kojto | 107:4f6c30876dfa | 570 | void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 571 | void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 572 | |
Kojto | 107:4f6c30876dfa | 573 | /** |
Kojto | 107:4f6c30876dfa | 574 | * @} |
Kojto | 107:4f6c30876dfa | 575 | */ |
Kojto | 107:4f6c30876dfa | 576 | |
Kojto | 107:4f6c30876dfa | 577 | /** @addtogroup CRYP_Group2 AES processing functions |
Kojto | 107:4f6c30876dfa | 578 | * @{ |
Kojto | 107:4f6c30876dfa | 579 | */ |
Kojto | 107:4f6c30876dfa | 580 | |
Kojto | 107:4f6c30876dfa | 581 | /* AES encryption/decryption processing functions ****************************/ |
Kojto | 107:4f6c30876dfa | 582 | |
Kojto | 107:4f6c30876dfa | 583 | /* AES encryption/decryption using polling ***********************************/ |
Kojto | 107:4f6c30876dfa | 584 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Kojto | 107:4f6c30876dfa | 585 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Kojto | 107:4f6c30876dfa | 586 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Kojto | 107:4f6c30876dfa | 587 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Kojto | 107:4f6c30876dfa | 588 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
Kojto | 107:4f6c30876dfa | 589 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
Kojto | 107:4f6c30876dfa | 590 | |
Kojto | 107:4f6c30876dfa | 591 | /* AES encryption/decryption using interrupt *********************************/ |
Kojto | 107:4f6c30876dfa | 592 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Kojto | 107:4f6c30876dfa | 593 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Kojto | 107:4f6c30876dfa | 594 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Kojto | 107:4f6c30876dfa | 595 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Kojto | 107:4f6c30876dfa | 596 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Kojto | 107:4f6c30876dfa | 597 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Kojto | 107:4f6c30876dfa | 598 | |
Kojto | 107:4f6c30876dfa | 599 | /* AES encryption/decryption using DMA ***************************************/ |
Kojto | 107:4f6c30876dfa | 600 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Kojto | 107:4f6c30876dfa | 601 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Kojto | 107:4f6c30876dfa | 602 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Kojto | 107:4f6c30876dfa | 603 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Kojto | 107:4f6c30876dfa | 604 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
Kojto | 107:4f6c30876dfa | 605 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
Kojto | 107:4f6c30876dfa | 606 | |
Kojto | 107:4f6c30876dfa | 607 | /** |
Kojto | 107:4f6c30876dfa | 608 | * @} |
Kojto | 107:4f6c30876dfa | 609 | */ |
Kojto | 107:4f6c30876dfa | 610 | |
Kojto | 107:4f6c30876dfa | 611 | /** @addtogroup CRYP_Group3 Callback functions |
Kojto | 107:4f6c30876dfa | 612 | * @{ |
Kojto | 107:4f6c30876dfa | 613 | */ |
Kojto | 107:4f6c30876dfa | 614 | /* CallBack functions ********************************************************/ |
Kojto | 107:4f6c30876dfa | 615 | void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 616 | void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 617 | void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 618 | |
Kojto | 107:4f6c30876dfa | 619 | /** |
Kojto | 107:4f6c30876dfa | 620 | * @} |
Kojto | 107:4f6c30876dfa | 621 | */ |
Kojto | 107:4f6c30876dfa | 622 | |
Kojto | 107:4f6c30876dfa | 623 | /** @addtogroup CRYP_Group4 CRYP IRQ handler |
Kojto | 107:4f6c30876dfa | 624 | * @{ |
Kojto | 107:4f6c30876dfa | 625 | */ |
Kojto | 107:4f6c30876dfa | 626 | |
Kojto | 107:4f6c30876dfa | 627 | /* AES interrupt handling function *******************************************/ |
Kojto | 107:4f6c30876dfa | 628 | void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 629 | |
Kojto | 107:4f6c30876dfa | 630 | /** |
Kojto | 107:4f6c30876dfa | 631 | * @} |
Kojto | 107:4f6c30876dfa | 632 | */ |
Kojto | 107:4f6c30876dfa | 633 | |
Kojto | 107:4f6c30876dfa | 634 | /** @addtogroup CRYP_Group5 Peripheral State functions |
Kojto | 107:4f6c30876dfa | 635 | * @{ |
Kojto | 107:4f6c30876dfa | 636 | */ |
Kojto | 107:4f6c30876dfa | 637 | |
Kojto | 107:4f6c30876dfa | 638 | /* Peripheral State functions ************************************************/ |
Kojto | 107:4f6c30876dfa | 639 | HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 640 | uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp); |
Kojto | 107:4f6c30876dfa | 641 | |
Kojto | 107:4f6c30876dfa | 642 | /** |
Kojto | 107:4f6c30876dfa | 643 | * @} |
Kojto | 107:4f6c30876dfa | 644 | */ |
Kojto | 107:4f6c30876dfa | 645 | |
Kojto | 107:4f6c30876dfa | 646 | /** |
Kojto | 107:4f6c30876dfa | 647 | * @} |
Kojto | 107:4f6c30876dfa | 648 | */ |
Kojto | 107:4f6c30876dfa | 649 | |
Kojto | 107:4f6c30876dfa | 650 | /** |
Kojto | 107:4f6c30876dfa | 651 | * @} |
Kojto | 107:4f6c30876dfa | 652 | */ |
Kojto | 107:4f6c30876dfa | 653 | |
Kojto | 107:4f6c30876dfa | 654 | /** |
Kojto | 107:4f6c30876dfa | 655 | * @} |
Kojto | 107:4f6c30876dfa | 656 | */ |
Kojto | 107:4f6c30876dfa | 657 | |
Kojto | 107:4f6c30876dfa | 658 | #endif /* defined(STM32L485xx) || defined(STM32L486xx) */ |
Kojto | 107:4f6c30876dfa | 659 | |
Kojto | 107:4f6c30876dfa | 660 | #ifdef __cplusplus |
Kojto | 107:4f6c30876dfa | 661 | } |
Kojto | 107:4f6c30876dfa | 662 | #endif |
Kojto | 107:4f6c30876dfa | 663 | |
Kojto | 107:4f6c30876dfa | 664 | #endif /* __STM32L4xx_HAL_CRYP_H */ |
Kojto | 107:4f6c30876dfa | 665 | |
Kojto | 107:4f6c30876dfa | 666 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |