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