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.

Committer:
AnnaBridge
Date:
Wed Jun 21 17:31:38 2017 +0100
Revision:
145:64910690c574
Parent:
128:9bcdf88f62b0
Release 145 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew 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
AnnaBridge 145:64910690c574 5 * @version V1.7.1
AnnaBridge 145:64910690c574 6 * @date 21-April-2017
Kojto 122:f9eeca106725 7 * @brief Header file of CRYP HAL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
AnnaBridge 145:64910690c574 11 * <h2><center>&copy; COPYRIGHT(c) 2017 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
AnnaBridge 145:64910690c574 46 #if defined (STM32L442xx) || defined (STM32L443xx) || defined (STM32L462xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L4A6xx)
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),
AnnaBridge 145:64910690c574 85 Galois Message Authentication Code (GMAC), Cipher Message
AnnaBridge 145:64910690c574 86 Authentication Code (CMAC) (when applicable) or Counter with Cipher
AnnaBridge 145:64910690c574 87 Mode (CCM) (when applicable).
Kojto 122:f9eeca106725 88 This parameter can be a value of @ref CRYP_GCM_CMAC_Phase */
Kojto 122:f9eeca106725 89
Kojto 122:f9eeca106725 90 uint8_t* pKey; /*!< Encryption/Decryption Key */
Kojto 122:f9eeca106725 91
AnnaBridge 145:64910690c574 92 uint8_t* pInitVect; /*!< Initialization Vector used for CTR, CBC, GCM/GMAC, CMAC (when applicable)
AnnaBridge 145:64910690c574 93 and CCM (when applicable) modes */
Kojto 122:f9eeca106725 94
AnnaBridge 145:64910690c574 95 uint8_t* Header; /*!< Header used in GCM/GMAC, CMAC (when applicable) and CCM (when applicable) modes */
Kojto 122:f9eeca106725 96
Kojto 122:f9eeca106725 97 uint64_t HeaderSize; /*!< Header size in bytes */
Kojto 122:f9eeca106725 98
Kojto 122:f9eeca106725 99 }CRYP_InitTypeDef;
Kojto 122:f9eeca106725 100
Kojto 122:f9eeca106725 101 /**
Kojto 122:f9eeca106725 102 * @brief HAL CRYP State structures definition
Kojto 122:f9eeca106725 103 */
Kojto 122:f9eeca106725 104 typedef enum
Kojto 122:f9eeca106725 105 {
Kojto 122:f9eeca106725 106 HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */
Kojto 122:f9eeca106725 107 HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */
Kojto 122:f9eeca106725 108 HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */
Kojto 122:f9eeca106725 109 HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */
Kojto 122:f9eeca106725 110 HAL_CRYP_STATE_ERROR = 0x04, /*!< CRYP error state */
Kojto 122:f9eeca106725 111 HAL_CRYP_STATE_SUSPENDED = 0x05 /*!< CRYP suspended */
Kojto 122:f9eeca106725 112 }HAL_CRYP_STATETypeDef;
Kojto 122:f9eeca106725 113
Kojto 122:f9eeca106725 114 /**
Kojto 122:f9eeca106725 115 * @brief HAL CRYP phase structures definition
Kojto 122:f9eeca106725 116 */
Kojto 122:f9eeca106725 117 typedef enum
Kojto 122:f9eeca106725 118 {
AnnaBridge 145:64910690c574 119 HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */
AnnaBridge 145:64910690c574 120 HAL_CRYP_PHASE_PROCESS = 0x02, /*!< CRYP peripheral is in processing phase */
AnnaBridge 145:64910690c574 121 HAL_CRYP_PHASE_START = 0x03, /*!< CRYP peripheral has been initialized but
AnnaBridge 145:64910690c574 122 GCM/GMAC(/CMAC)(/CCM) initialization phase has not started */
AnnaBridge 145:64910690c574 123 HAL_CRYP_PHASE_INIT_OVER = 0x04, /*!< GCM/GMAC(/CMAC)(/CCM) init phase has been carried out */
AnnaBridge 145:64910690c574 124 HAL_CRYP_PHASE_HEADER_OVER = 0x05, /*!< GCM/GMAC(/CMAC)(/CCM) header phase has been carried out */
AnnaBridge 145:64910690c574 125 HAL_CRYP_PHASE_PAYLOAD_OVER = 0x06, /*!< GCM(/CCM) payload phase has been carried out */
AnnaBridge 145:64910690c574 126 HAL_CRYP_PHASE_FINAL_OVER = 0x07, /*!< GCM/GMAC(/CMAC)(/CCM) final phase has been carried out */
AnnaBridge 145:64910690c574 127 HAL_CRYP_PHASE_HEADER_SUSPENDED = 0x08, /*!< GCM/GMAC(/CMAC)(/CCM) header phase has been suspended */
AnnaBridge 145:64910690c574 128 HAL_CRYP_PHASE_PAYLOAD_SUSPENDED = 0x09, /*!< GCM(/CCM) payload phase has been suspended */
AnnaBridge 145:64910690c574 129 HAL_CRYP_PHASE_NOT_USED = 0x0a /*!< Phase is irrelevant to the current chaining mode */
Kojto 122:f9eeca106725 130 }HAL_PhaseTypeDef;
Kojto 122:f9eeca106725 131
Kojto 122:f9eeca106725 132 /**
Kojto 122:f9eeca106725 133 * @brief HAL CRYP mode suspend definitions
Kojto 122:f9eeca106725 134 */
Kojto 122:f9eeca106725 135 typedef enum
Kojto 122:f9eeca106725 136 {
Kojto 122:f9eeca106725 137 HAL_CRYP_SUSPEND_NONE = 0x00, /*!< CRYP peripheral suspension not requested */
Kojto 122:f9eeca106725 138 HAL_CRYP_SUSPEND = 0x01 /*!< CRYP peripheral suspension requested */
Kojto 122:f9eeca106725 139 }HAL_SuspendTypeDef;
Kojto 122:f9eeca106725 140
Kojto 122:f9eeca106725 141
Kojto 122:f9eeca106725 142 /**
Kojto 122:f9eeca106725 143 * @brief HAL CRYP Error Codes definition
Kojto 122:f9eeca106725 144 */
Kojto 122:f9eeca106725 145 #define HAL_CRYP_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 122:f9eeca106725 146 #define HAL_CRYP_WRITE_ERROR ((uint32_t)0x00000001) /*!< Write error */
Kojto 122:f9eeca106725 147 #define HAL_CRYP_READ_ERROR ((uint32_t)0x00000002) /*!< Read error */
Kojto 122:f9eeca106725 148 #define HAL_CRYP_DMA_ERROR ((uint32_t)0x00000004) /*!< DMA error */
Kojto 122:f9eeca106725 149 #define HAL_CRYP_BUSY_ERROR ((uint32_t)0x00000008) /*!< Busy flag error */
Kojto 122:f9eeca106725 150
Kojto 122:f9eeca106725 151 /**
Kojto 122:f9eeca106725 152 * @brief CRYP handle Structure definition
Kojto 122:f9eeca106725 153 */
Kojto 122:f9eeca106725 154 typedef struct
Kojto 122:f9eeca106725 155 {
Kojto 122:f9eeca106725 156 AES_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 157
Kojto 122:f9eeca106725 158 CRYP_InitTypeDef Init; /*!< CRYP initialization parameters */
Kojto 122:f9eeca106725 159
Kojto 122:f9eeca106725 160 uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) input buffer */
Kojto 122:f9eeca106725 161
Kojto 122:f9eeca106725 162 uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) output buffer */
Kojto 122:f9eeca106725 163
Kojto 122:f9eeca106725 164 uint32_t CrypInCount; /*!< Input data size in bytes or, after suspension, the remaining
Kojto 122:f9eeca106725 165 number of bytes to process */
Kojto 122:f9eeca106725 166
Kojto 122:f9eeca106725 167 uint32_t CrypOutCount; /*!< Output data size in bytes */
Kojto 122:f9eeca106725 168
AnnaBridge 145:64910690c574 169 HAL_PhaseTypeDef Phase; /*!< CRYP peripheral processing phase for GCM, GMAC, CMAC (when applicable)
AnnaBridge 145:64910690c574 170 or CCM (when applicable) modes.
AnnaBridge 145:64910690c574 171 Indicates the last phase carried out to ease
AnnaBridge 145:64910690c574 172 phase transitions */
Kojto 122:f9eeca106725 173
Kojto 122:f9eeca106725 174 DMA_HandleTypeDef *hdmain; /*!< CRYP peripheral Input DMA handle parameters */
Kojto 122:f9eeca106725 175
Kojto 122:f9eeca106725 176 DMA_HandleTypeDef *hdmaout; /*!< CRYP peripheral Output DMA handle parameters */
Kojto 122:f9eeca106725 177
Kojto 122:f9eeca106725 178 HAL_LockTypeDef Lock; /*!< CRYP locking object */
Kojto 122:f9eeca106725 179
Kojto 122:f9eeca106725 180 __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */
Kojto 122:f9eeca106725 181
Kojto 122:f9eeca106725 182 __IO uint32_t ErrorCode; /*!< CRYP peripheral error code */
Kojto 122:f9eeca106725 183
Kojto 122:f9eeca106725 184 HAL_SuspendTypeDef SuspendRequest; /*!< CRYP peripheral suspension request flag */
Kojto 122:f9eeca106725 185 }CRYP_HandleTypeDef;
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 /**
Kojto 122:f9eeca106725 188 * @}
Kojto 122:f9eeca106725 189 */
Kojto 122:f9eeca106725 190
Kojto 122:f9eeca106725 191
Kojto 122:f9eeca106725 192 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 193 /** @defgroup CRYP_Exported_Constants CRYP Exported Constants
Kojto 122:f9eeca106725 194 * @{
Kojto 122:f9eeca106725 195 */
Kojto 122:f9eeca106725 196
Kojto 122:f9eeca106725 197 /** @defgroup CRYP_Key_Size Key size selection
Kojto 122:f9eeca106725 198 * @{
Kojto 122:f9eeca106725 199 */
Kojto 122:f9eeca106725 200 #define CRYP_KEYSIZE_128B ((uint32_t)0x00000000) /*!< 128-bit long key */
Kojto 122:f9eeca106725 201 #define CRYP_KEYSIZE_256B AES_CR_KEYSIZE /*!< 256-bit long key */
Kojto 122:f9eeca106725 202 /**
Kojto 122:f9eeca106725 203 * @}
Kojto 122:f9eeca106725 204 */
Kojto 122:f9eeca106725 205
Kojto 122:f9eeca106725 206 /** @defgroup CRYP_Data_Type AES Data Type selection
Kojto 122:f9eeca106725 207 * @{
Kojto 122:f9eeca106725 208 */
Kojto 122:f9eeca106725 209 #define CRYP_DATATYPE_32B ((uint32_t)0x00000000) /*!< 32-bit data type (no swapping) */
Kojto 122:f9eeca106725 210 #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */
Kojto 122:f9eeca106725 211 #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */
Kojto 122:f9eeca106725 212 #define CRYP_DATATYPE_1B AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */
Kojto 122:f9eeca106725 213 /**
Kojto 122:f9eeca106725 214 * @}
Kojto 122:f9eeca106725 215 */
Kojto 122:f9eeca106725 216
Kojto 122:f9eeca106725 217 /** @defgroup CRYP_AES_State AES Enable state
Kojto 122:f9eeca106725 218 * @{
Kojto 122:f9eeca106725 219 */
Kojto 122:f9eeca106725 220 #define CRYP_AES_DISABLE ((uint32_t)0x00000000) /*!< Disable AES */
Kojto 122:f9eeca106725 221 #define CRYP_AES_ENABLE AES_CR_EN /*!< Enable AES */
Kojto 122:f9eeca106725 222 /**
Kojto 122:f9eeca106725 223 * @}
Kojto 122:f9eeca106725 224 */
Kojto 122:f9eeca106725 225
Kojto 122:f9eeca106725 226 /** @defgroup CRYP_AES_OperatingMode AES operating mode
Kojto 122:f9eeca106725 227 * @{
Kojto 122:f9eeca106725 228 */
AnnaBridge 145:64910690c574 229 #define CRYP_ALGOMODE_ENCRYPT ((uint32_t)0x00000000) /*!< Encryption mode */
AnnaBridge 145:64910690c574 230 #define CRYP_ALGOMODE_KEYDERIVATION AES_CR_MODE_0 /*!< Key derivation mode */
AnnaBridge 145:64910690c574 231 #define CRYP_ALGOMODE_DECRYPT AES_CR_MODE_1 /*!< Decryption */
AnnaBridge 145:64910690c574 232 #define CRYP_ALGOMODE_KEYDERIVATION_DECRYPT AES_CR_MODE /*!< Key derivation and decryption */
AnnaBridge 145:64910690c574 233 #define CRYP_ALGOMODE_TAG_GENERATION ((uint32_t)0x00000000) /*!< GMAC or CMAC (when applicable) authentication tag generation */
Kojto 122:f9eeca106725 234 /**
Kojto 122:f9eeca106725 235 * @}
Kojto 122:f9eeca106725 236 */
Kojto 122:f9eeca106725 237
Kojto 122:f9eeca106725 238 /** @defgroup CRYP_AES_ChainingMode AES chaining mode
Kojto 122:f9eeca106725 239 * @{
AnnaBridge 145:64910690c574 240 */
Kojto 122:f9eeca106725 241 #define CRYP_CHAINMODE_AES_ECB ((uint32_t)0x00000000) /*!< Electronic codebook chaining algorithm */
Kojto 122:f9eeca106725 242 #define CRYP_CHAINMODE_AES_CBC AES_CR_CHMOD_0 /*!< Cipher block chaining algorithm */
Kojto 122:f9eeca106725 243 #define CRYP_CHAINMODE_AES_CTR AES_CR_CHMOD_1 /*!< Counter mode chaining algorithm */
Kojto 122:f9eeca106725 244 #define CRYP_CHAINMODE_AES_GCM_GMAC (AES_CR_CHMOD_0 | AES_CR_CHMOD_1) /*!< Galois counter mode - Galois message authentication code */
AnnaBridge 145:64910690c574 245 #if defined(AES_CR_NPBLB)
AnnaBridge 145:64910690c574 246 #define CRYP_CHAINMODE_AES_CCM AES_CR_CHMOD_2 /*!< Counter with Cipher Mode */
AnnaBridge 145:64910690c574 247 #else
Kojto 122:f9eeca106725 248 #define CRYP_CHAINMODE_AES_CMAC AES_CR_CHMOD_2 /*!< Cipher message authentication code */
AnnaBridge 145:64910690c574 249 #endif
AnnaBridge 145:64910690c574 250 /**
Kojto 122:f9eeca106725 251 * @}
Kojto 122:f9eeca106725 252 */
Kojto 122:f9eeca106725 253
Kojto 122:f9eeca106725 254 /** @defgroup CRYP_Key_Write AES decryption key write-up flag
Kojto 122:f9eeca106725 255 * @{
Kojto 122:f9eeca106725 256 */
Kojto 122:f9eeca106725 257 #define CRYP_KEY_WRITE_ENABLE ((uint32_t)0x00000000) /*!< Enable decryption key writing */
Kojto 122:f9eeca106725 258 #define CRYP_KEY_WRITE_DISABLE ((uint32_t)0x00000001) /*!< Disable decryption key writing */
Kojto 122:f9eeca106725 259 /**
Kojto 122:f9eeca106725 260 * @}
Kojto 122:f9eeca106725 261 */
Kojto 122:f9eeca106725 262
Kojto 122:f9eeca106725 263 /** @defgroup CRYP_DMAIN DMA Input phase management enable state
Kojto 122:f9eeca106725 264 * @{
Kojto 122:f9eeca106725 265 */
Kojto 122:f9eeca106725 266 #define CRYP_DMAIN_DISABLE ((uint32_t)0x00000000) /*!< Disable DMA Input phase management */
Kojto 122:f9eeca106725 267 #define CRYP_DMAIN_ENABLE AES_CR_DMAINEN /*!< Enable DMA Input phase management */
Kojto 122:f9eeca106725 268 /**
Kojto 122:f9eeca106725 269 * @}
Kojto 122:f9eeca106725 270 */
Kojto 122:f9eeca106725 271
Kojto 122:f9eeca106725 272 /** @defgroup CRYP_DMAOUT DMA Output phase management enable state
Kojto 122:f9eeca106725 273 * @{
Kojto 122:f9eeca106725 274 */
Kojto 122:f9eeca106725 275 #define CRYP_DMAOUT_DISABLE ((uint32_t)0x00000000) /*!< Disable DMA Output phase management */
Kojto 122:f9eeca106725 276 #define CRYP_DMAOUT_ENABLE AES_CR_DMAOUTEN /*!< Enable DMA Output phase management */
Kojto 122:f9eeca106725 277 /**
Kojto 122:f9eeca106725 278 * @}
Kojto 122:f9eeca106725 279 */
Kojto 122:f9eeca106725 280
Kojto 122:f9eeca106725 281
AnnaBridge 145:64910690c574 282 /** @defgroup CRYP_GCM_CMAC_Phase GCM/GMAC and CCM/CMAC (when applicable) processing phase selection
Kojto 122:f9eeca106725 283 * @{
Kojto 122:f9eeca106725 284 */
AnnaBridge 145:64910690c574 285 #define CRYP_GCM_INIT_PHASE ((uint32_t)0x00000000) /*!< GCM/GMAC (or CCM) init phase */
AnnaBridge 145:64910690c574 286 #define CRYP_GCMCMAC_HEADER_PHASE AES_CR_GCMPH_0 /*!< GCM/GMAC/CCM/CMAC header phase */
AnnaBridge 145:64910690c574 287 #define CRYP_GCM_PAYLOAD_PHASE AES_CR_GCMPH_1 /*!< GCM/CCM payload phase */
AnnaBridge 145:64910690c574 288 #define CRYP_GCMCMAC_FINAL_PHASE AES_CR_GCMPH /*!< GCM/GMAC/CCM/CMAC final phase */
AnnaBridge 145:64910690c574 289 /* Definitions duplication for code readibility's sake:
AnnaBridge 145:64910690c574 290 supported or not supported chain modes are not specified for each phase */
AnnaBridge 145:64910690c574 291 #define CRYP_INIT_PHASE ((uint32_t)0x00000000) /*!< Init phase */
AnnaBridge 145:64910690c574 292 #define CRYP_HEADER_PHASE AES_CR_GCMPH_0 /*!< Header phase */
AnnaBridge 145:64910690c574 293 #define CRYP_PAYLOAD_PHASE AES_CR_GCMPH_1 /*!< Payload phase */
AnnaBridge 145:64910690c574 294 #define CRYP_FINAL_PHASE AES_CR_GCMPH /*!< Final phase */
Kojto 122:f9eeca106725 295 /**
Kojto 122:f9eeca106725 296 * @}
Kojto 122:f9eeca106725 297 */
Kojto 122:f9eeca106725 298
Kojto 122:f9eeca106725 299 /** @defgroup CRYP_Flags AES status flags
Kojto 122:f9eeca106725 300 * @{
Kojto 122:f9eeca106725 301 */
Kojto 122:f9eeca106725 302
Kojto 122:f9eeca106725 303 #define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden */
Kojto 122:f9eeca106725 304 #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error */
Kojto 122:f9eeca106725 305 #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read error */
Kojto 122:f9eeca106725 306 #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed */
Kojto 122:f9eeca106725 307 /**
Kojto 122:f9eeca106725 308 * @}
Kojto 122:f9eeca106725 309 */
Kojto 122:f9eeca106725 310
Kojto 122:f9eeca106725 311 /** @defgroup CRYP_Clear_Flags AES clearing flags
Kojto 122:f9eeca106725 312 * @{
Kojto 122:f9eeca106725 313 */
Kojto 122:f9eeca106725 314
Kojto 122:f9eeca106725 315 #define CRYP_CCF_CLEAR AES_CR_CCFC /*!< Computation Complete Flag Clear */
Kojto 122:f9eeca106725 316 #define CRYP_ERR_CLEAR AES_CR_ERRC /*!< Error Flag Clear */
Kojto 122:f9eeca106725 317 /**
Kojto 122:f9eeca106725 318 * @}
Kojto 122:f9eeca106725 319 */
Kojto 122:f9eeca106725 320
Kojto 122:f9eeca106725 321 /** @defgroup AES_Interrupts_Enable AES Interrupts Enable bits
Kojto 122:f9eeca106725 322 * @{
Kojto 122:f9eeca106725 323 */
Kojto 122:f9eeca106725 324 #define CRYP_IT_CCFIE AES_CR_CCFIE /*!< Computation Complete interrupt enable */
Kojto 122:f9eeca106725 325 #define CRYP_IT_ERRIE AES_CR_ERRIE /*!< Error interrupt enable */
Kojto 122:f9eeca106725 326 /**
Kojto 122:f9eeca106725 327 * @}
Kojto 122:f9eeca106725 328 */
Kojto 122:f9eeca106725 329
Kojto 122:f9eeca106725 330 /** @defgroup CRYP_Interrupts_Flags AES Interrupts flags
Kojto 122:f9eeca106725 331 * @{
Kojto 122:f9eeca106725 332 */
Kojto 122:f9eeca106725 333 #define CRYP_IT_WRERR AES_SR_WRERR /*!< Write Error */
Kojto 122:f9eeca106725 334 #define CRYP_IT_RDERR AES_SR_RDERR /*!< Read Error */
Kojto 122:f9eeca106725 335 #define CRYP_IT_CCF AES_SR_CCF /*!< Computation completed */
Kojto 122:f9eeca106725 336 /**
Kojto 122:f9eeca106725 337 * @}
Kojto 122:f9eeca106725 338 */
Kojto 122:f9eeca106725 339
Kojto 122:f9eeca106725 340 /**
Kojto 122:f9eeca106725 341 * @}
Kojto 122:f9eeca106725 342 */
Kojto 122:f9eeca106725 343
Kojto 122:f9eeca106725 344 /* Exported macros -----------------------------------------------------------*/
Kojto 122:f9eeca106725 345 /** @defgroup CRYP_Exported_Macros CRYP Exported Macros
Kojto 122:f9eeca106725 346 * @{
Kojto 122:f9eeca106725 347 */
Kojto 122:f9eeca106725 348
Kojto 122:f9eeca106725 349 /** @brief Reset CRYP handle state.
Kojto 122:f9eeca106725 350 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 351 * @retval None
Kojto 122:f9eeca106725 352 */
Kojto 122:f9eeca106725 353 #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET)
Kojto 122:f9eeca106725 354
Kojto 122:f9eeca106725 355 /**
Kojto 122:f9eeca106725 356 * @brief Enable the CRYP AES peripheral.
AnnaBridge 145:64910690c574 357 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 358 * @retval None
Kojto 122:f9eeca106725 359 */
AnnaBridge 145:64910690c574 360 #define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= AES_CR_EN)
Kojto 122:f9eeca106725 361
Kojto 122:f9eeca106725 362 /**
Kojto 122:f9eeca106725 363 * @brief Disable the CRYP AES peripheral.
AnnaBridge 145:64910690c574 364 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 365 * @retval None
Kojto 122:f9eeca106725 366 */
AnnaBridge 145:64910690c574 367 #define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~AES_CR_EN)
Kojto 122:f9eeca106725 368
Kojto 122:f9eeca106725 369 /**
Kojto 122:f9eeca106725 370 * @brief Set the algorithm operating mode.
AnnaBridge 145:64910690c574 371 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 372 * @param __OPERATING_MODE__: specifies the operating mode
Kojto 122:f9eeca106725 373 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 374 * @arg @ref CRYP_ALGOMODE_ENCRYPT encryption
Kojto 122:f9eeca106725 375 * @arg @ref CRYP_ALGOMODE_KEYDERIVATION key derivation
Kojto 122:f9eeca106725 376 * @arg @ref CRYP_ALGOMODE_DECRYPT decryption
Kojto 122:f9eeca106725 377 * @arg @ref CRYP_ALGOMODE_KEYDERIVATION_DECRYPT key derivation and decryption
Kojto 122:f9eeca106725 378 * @retval None
Kojto 122:f9eeca106725 379 */
AnnaBridge 145:64910690c574 380 #define __HAL_CRYP_SET_OPERATINGMODE(__HANDLE__, __OPERATING_MODE__) MODIFY_REG((__HANDLE__)->Instance->CR, AES_CR_MODE, (__OPERATING_MODE__))
Kojto 122:f9eeca106725 381
Kojto 122:f9eeca106725 382
Kojto 122:f9eeca106725 383 /**
Kojto 122:f9eeca106725 384 * @brief Set the algorithm chaining mode.
AnnaBridge 145:64910690c574 385 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 386 * @param __CHAINING_MODE__: specifies the chaining mode
Kojto 122:f9eeca106725 387 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 388 * @arg @ref CRYP_CHAINMODE_AES_ECB Electronic CodeBook
Kojto 122:f9eeca106725 389 * @arg @ref CRYP_CHAINMODE_AES_CBC Cipher Block Chaining
Kojto 122:f9eeca106725 390 * @arg @ref CRYP_CHAINMODE_AES_CTR CounTeR mode
Kojto 122:f9eeca106725 391 * @arg @ref CRYP_CHAINMODE_AES_GCM_GMAC Galois Counter Mode or Galois Message Authentication Code
AnnaBridge 145:64910690c574 392 * @arg @ref CRYP_CHAINMODE_AES_CMAC Cipher Message Authentication Code (or Counter with Cipher Mode when applicable)
Kojto 122:f9eeca106725 393 * @retval None
Kojto 122:f9eeca106725 394 */
AnnaBridge 145:64910690c574 395 #define __HAL_CRYP_SET_CHAININGMODE(__HANDLE__, __CHAINING_MODE__) MODIFY_REG((__HANDLE__)->Instance->CR, AES_CR_CHMOD, (__CHAINING_MODE__))
Kojto 122:f9eeca106725 396
Kojto 122:f9eeca106725 397
Kojto 122:f9eeca106725 398
Kojto 122:f9eeca106725 399 /** @brief Check whether the specified CRYP status flag is set or not.
AnnaBridge 145:64910690c574 400 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 401 * @param __FLAG__: specifies the flag to check.
Kojto 122:f9eeca106725 402 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 403 * @arg @ref CRYP_FLAG_BUSY GCM process suspension forbidden
Kojto 122:f9eeca106725 404 * @arg @ref CRYP_IT_WRERR Write Error
Kojto 122:f9eeca106725 405 * @arg @ref CRYP_IT_RDERR Read Error
Kojto 122:f9eeca106725 406 * @arg @ref CRYP_IT_CCF Computation Complete
Kojto 122:f9eeca106725 407 * @retval The state of __FLAG__ (TRUE or FALSE).
Kojto 122:f9eeca106725 408 */
AnnaBridge 145:64910690c574 409 #define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
Kojto 122:f9eeca106725 410
Kojto 122:f9eeca106725 411
Kojto 122:f9eeca106725 412 /** @brief Clear the CRYP pending status flag.
AnnaBridge 145:64910690c574 413 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 414 * @param __FLAG__: specifies the flag to clear.
Kojto 122:f9eeca106725 415 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 416 * @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear
Kojto 122:f9eeca106725 417 * @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear
Kojto 122:f9eeca106725 418 * @retval None
Kojto 122:f9eeca106725 419 */
AnnaBridge 145:64910690c574 420 #define __HAL_CRYP_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT((__HANDLE__)->Instance->CR, (__FLAG__))
Kojto 122:f9eeca106725 421
Kojto 122:f9eeca106725 422
Kojto 122:f9eeca106725 423
Kojto 122:f9eeca106725 424 /** @brief Check whether the specified CRYP interrupt source is enabled or not.
AnnaBridge 145:64910690c574 425 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 426 * @param __INTERRUPT__: CRYP interrupt source to check
Kojto 122:f9eeca106725 427 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 428 * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
Kojto 122:f9eeca106725 429 * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
Kojto 122:f9eeca106725 430 * @retval State of interruption (TRUE or FALSE).
Kojto 122:f9eeca106725 431 */
AnnaBridge 145:64910690c574 432 #define __HAL_CRYP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 122:f9eeca106725 433
Kojto 122:f9eeca106725 434
Kojto 122:f9eeca106725 435 /** @brief Check whether the specified CRYP interrupt is set or not.
AnnaBridge 145:64910690c574 436 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 437 * @param __INTERRUPT__: specifies the interrupt to check.
Kojto 122:f9eeca106725 438 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 439 * @arg @ref CRYP_IT_WRERR Write Error
Kojto 122:f9eeca106725 440 * @arg @ref CRYP_IT_RDERR Read Error
Kojto 122:f9eeca106725 441 * @arg @ref CRYP_IT_CCF Computation Complete
Kojto 122:f9eeca106725 442 * @retval The state of __INTERRUPT__ (TRUE or FALSE).
Kojto 122:f9eeca106725 443 */
AnnaBridge 145:64910690c574 444 #define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 122:f9eeca106725 445
Kojto 122:f9eeca106725 446
Kojto 122:f9eeca106725 447
Kojto 122:f9eeca106725 448 /** @brief Clear the CRYP pending interrupt.
AnnaBridge 145:64910690c574 449 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 450 * @param __INTERRUPT__: specifies the IT to clear.
Kojto 122:f9eeca106725 451 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 452 * @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear
Kojto 122:f9eeca106725 453 * @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear
Kojto 122:f9eeca106725 454 * @retval None
Kojto 122:f9eeca106725 455 */
AnnaBridge 145:64910690c574 456 #define __HAL_CRYP_CLEAR_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
Kojto 122:f9eeca106725 457
Kojto 122:f9eeca106725 458
Kojto 122:f9eeca106725 459 /**
Kojto 122:f9eeca106725 460 * @brief Enable the CRYP interrupt.
AnnaBridge 145:64910690c574 461 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 462 * @param __INTERRUPT__: CRYP Interrupt.
Kojto 122:f9eeca106725 463 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 464 * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
Kojto 122:f9eeca106725 465 * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
Kojto 122:f9eeca106725 466 * @retval None
Kojto 122:f9eeca106725 467 */
AnnaBridge 145:64910690c574 468 #define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__))
Kojto 122:f9eeca106725 469
Kojto 122:f9eeca106725 470
Kojto 122:f9eeca106725 471 /**
Kojto 122:f9eeca106725 472 * @brief Disable the CRYP interrupt.
AnnaBridge 145:64910690c574 473 * @param __HANDLE__: specifies the CRYP handle.
Kojto 122:f9eeca106725 474 * @param __INTERRUPT__: CRYP Interrupt.
Kojto 122:f9eeca106725 475 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 476 * @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR)
Kojto 122:f9eeca106725 477 * @arg @ref CRYP_IT_CCFIE Computation Complete interrupt
Kojto 122:f9eeca106725 478 * @retval None
Kojto 122:f9eeca106725 479 */
AnnaBridge 145:64910690c574 480 #define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__))
Kojto 122:f9eeca106725 481
Kojto 122:f9eeca106725 482 /**
Kojto 122:f9eeca106725 483 * @}
Kojto 122:f9eeca106725 484 */
Kojto 122:f9eeca106725 485
Kojto 122:f9eeca106725 486 /* Private macros --------------------------------------------------------*/
Kojto 122:f9eeca106725 487 /** @addtogroup CRYP_Private_Macros CRYP Private Macros
Kojto 122:f9eeca106725 488 * @{
Kojto 122:f9eeca106725 489 */
Kojto 122:f9eeca106725 490
Kojto 122:f9eeca106725 491 /**
Kojto 122:f9eeca106725 492 * @brief Verify the key size length.
Kojto 122:f9eeca106725 493 * @param __KEYSIZE__: Ciphering/deciphering algorithm key size.
Kojto 122:f9eeca106725 494 * @retval SET (__KEYSIZE__ is a valid value) or RESET (__KEYSIZE__ is invalid)
Kojto 122:f9eeca106725 495 */
Kojto 122:f9eeca106725 496 #define IS_CRYP_KEYSIZE(__KEYSIZE__) (((__KEYSIZE__) == CRYP_KEYSIZE_128B) || \
Kojto 122:f9eeca106725 497 ((__KEYSIZE__) == CRYP_KEYSIZE_256B))
Kojto 122:f9eeca106725 498
Kojto 122:f9eeca106725 499 /**
Kojto 122:f9eeca106725 500 * @brief Verify the input data type.
Kojto 122:f9eeca106725 501 * @param __DATATYPE__: Ciphering/deciphering algorithm input data type.
Kojto 122:f9eeca106725 502 * @retval SET (__DATATYPE__ is valid) or RESET (__DATATYPE__ is invalid)
Kojto 122:f9eeca106725 503 */
Kojto 122:f9eeca106725 504 #define IS_CRYP_DATATYPE(__DATATYPE__) (((__DATATYPE__) == CRYP_DATATYPE_32B) || \
Kojto 122:f9eeca106725 505 ((__DATATYPE__) == CRYP_DATATYPE_16B) || \
Kojto 122:f9eeca106725 506 ((__DATATYPE__) == CRYP_DATATYPE_8B) || \
Kojto 122:f9eeca106725 507 ((__DATATYPE__) == CRYP_DATATYPE_1B))
Kojto 122:f9eeca106725 508
Kojto 122:f9eeca106725 509 /**
Kojto 122:f9eeca106725 510 * @brief Verify the CRYP AES IP running mode.
Kojto 122:f9eeca106725 511 * @param __MODE__: CRYP AES IP running mode.
Kojto 122:f9eeca106725 512 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 513 */
Kojto 122:f9eeca106725 514 #define IS_CRYP_AES(__MODE__) (((__MODE__) == CRYP_AES_DISABLE) || \
Kojto 122:f9eeca106725 515 ((__MODE__) == CRYP_AES_ENABLE))
Kojto 122:f9eeca106725 516
Kojto 122:f9eeca106725 517 /**
Kojto 122:f9eeca106725 518 * @brief Verify the selected CRYP algorithm.
Kojto 122:f9eeca106725 519 * @param __ALGOMODE__: Selected CRYP algorithm (ciphering, deciphering, key derivation or a combination of the latter).
Kojto 122:f9eeca106725 520 * @retval SET (__ALGOMODE__ is valid) or RESET (__ALGOMODE__ is invalid)
Kojto 122:f9eeca106725 521 */
Kojto 122:f9eeca106725 522 #define IS_CRYP_ALGOMODE(__ALGOMODE__) (((__ALGOMODE__) == CRYP_ALGOMODE_ENCRYPT) || \
Kojto 122:f9eeca106725 523 ((__ALGOMODE__) == CRYP_ALGOMODE_KEYDERIVATION) || \
Kojto 122:f9eeca106725 524 ((__ALGOMODE__) == CRYP_ALGOMODE_DECRYPT) || \
Kojto 122:f9eeca106725 525 ((__ALGOMODE__) == CRYP_ALGOMODE_TAG_GENERATION) || \
Kojto 122:f9eeca106725 526 ((__ALGOMODE__) == CRYP_ALGOMODE_KEYDERIVATION_DECRYPT))
Kojto 122:f9eeca106725 527
Kojto 122:f9eeca106725 528 /**
Kojto 122:f9eeca106725 529 * @brief Verify the selected CRYP chaining algorithm.
Kojto 122:f9eeca106725 530 * @param __CHAINMODE__: Selected CRYP chaining algorithm.
Kojto 122:f9eeca106725 531 * @retval SET (__CHAINMODE__ is valid) or RESET (__CHAINMODE__ is invalid)
AnnaBridge 145:64910690c574 532 */
AnnaBridge 145:64910690c574 533 #if defined(AES_CR_NPBLB)
Kojto 122:f9eeca106725 534 #define IS_CRYP_CHAINMODE(__CHAINMODE__) (((__CHAINMODE__) == CRYP_CHAINMODE_AES_ECB) || \
Kojto 122:f9eeca106725 535 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CBC) || \
Kojto 122:f9eeca106725 536 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CTR) || \
Kojto 122:f9eeca106725 537 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_GCM_GMAC) || \
AnnaBridge 145:64910690c574 538 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CCM))
AnnaBridge 145:64910690c574 539 #else
AnnaBridge 145:64910690c574 540 #define IS_CRYP_CHAINMODE(__CHAINMODE__) (((__CHAINMODE__) == CRYP_CHAINMODE_AES_ECB) || \
AnnaBridge 145:64910690c574 541 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CBC) || \
AnnaBridge 145:64910690c574 542 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CTR) || \
AnnaBridge 145:64910690c574 543 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_GCM_GMAC) || \
AnnaBridge 145:64910690c574 544 ((__CHAINMODE__) == CRYP_CHAINMODE_AES_CMAC))
AnnaBridge 145:64910690c574 545 #endif
Kojto 122:f9eeca106725 546
Kojto 122:f9eeca106725 547 /**
Kojto 122:f9eeca106725 548 * @brief Verify the deciphering key write option.
Kojto 122:f9eeca106725 549 * @param __WRITE__: deciphering key write option.
Kojto 122:f9eeca106725 550 * @retval SET (__WRITE__ is valid) or RESET (__WRITE__ is invalid)
Kojto 122:f9eeca106725 551 */
Kojto 122:f9eeca106725 552 #define IS_CRYP_WRITE(__WRITE__) (((__WRITE__) == CRYP_KEY_WRITE_ENABLE) || \
Kojto 122:f9eeca106725 553 ((__WRITE__) == CRYP_KEY_WRITE_DISABLE))
Kojto 122:f9eeca106725 554
Kojto 122:f9eeca106725 555 /**
Kojto 122:f9eeca106725 556 * @brief Verify the CRYP input data DMA mode.
Kojto 122:f9eeca106725 557 * @param __MODE__: CRYP input data DMA mode.
Kojto 122:f9eeca106725 558 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 559 */
Kojto 122:f9eeca106725 560 #define IS_CRYP_DMAIN(__MODE__) (((__MODE__) == CRYP_DMAIN_DISABLE) || \
Kojto 122:f9eeca106725 561 ((__MODE__) == CRYP_DMAIN_ENABLE))
Kojto 122:f9eeca106725 562
Kojto 122:f9eeca106725 563 /**
Kojto 122:f9eeca106725 564 * @brief Verify the CRYP output data DMA mode.
Kojto 122:f9eeca106725 565 * @param __MODE__: CRYP output data DMA mode.
Kojto 122:f9eeca106725 566 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 567 */
Kojto 122:f9eeca106725 568 #define IS_CRYP_DMAOUT(__MODE__) (((__MODE__) == CRYP_DMAOUT_DISABLE) || \
Kojto 122:f9eeca106725 569 ((__MODE__) == CRYP_DMAOUT_ENABLE))
Kojto 122:f9eeca106725 570
Kojto 122:f9eeca106725 571 /**
Kojto 122:f9eeca106725 572 * @brief Verify the CRYP AES ciphering/deciphering/authentication algorithm phase.
Kojto 122:f9eeca106725 573 * @param __PHASE__: CRYP AES ciphering/deciphering/authentication algorithm phase.
Kojto 122:f9eeca106725 574 * @retval SET (__PHASE__ is valid) or RESET (__PHASE__ is invalid)
Kojto 122:f9eeca106725 575 */
AnnaBridge 145:64910690c574 576 #define IS_CRYP_GCMCMAC_PHASE(__PHASE__) (((__PHASE__) == CRYP_INIT_PHASE) || \
AnnaBridge 145:64910690c574 577 ((__PHASE__) == CRYP_HEADER_PHASE) || \
AnnaBridge 145:64910690c574 578 ((__PHASE__) == CRYP_PAYLOAD_PHASE) || \
AnnaBridge 145:64910690c574 579 ((__PHASE__) == CRYP_FINAL_PHASE))
Kojto 122:f9eeca106725 580
Kojto 122:f9eeca106725 581 /**
Kojto 122:f9eeca106725 582 * @}
Kojto 122:f9eeca106725 583 */
Kojto 122:f9eeca106725 584
Kojto 122:f9eeca106725 585 /* Include CRYP HAL Extended module */
Kojto 122:f9eeca106725 586 #include "stm32l4xx_hal_cryp_ex.h"
Kojto 122:f9eeca106725 587
Kojto 122:f9eeca106725 588 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 589 /** @addtogroup CRYP_Exported_Functions CRYP Exported Functions
Kojto 122:f9eeca106725 590 * @{
Kojto 122:f9eeca106725 591 */
Kojto 122:f9eeca106725 592
Kojto 122:f9eeca106725 593 /** @addtogroup CRYP_Exported_Functions_Group1 Initialization and deinitialization functions
Kojto 122:f9eeca106725 594 * @{
Kojto 122:f9eeca106725 595 */
Kojto 122:f9eeca106725 596
Kojto 122:f9eeca106725 597 /* Initialization/de-initialization functions ********************************/
Kojto 122:f9eeca106725 598 HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 599 HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 600
Kojto 122:f9eeca106725 601 /* MSP initialization/de-initialization functions ****************************/
Kojto 122:f9eeca106725 602 void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 603 void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 604
Kojto 122:f9eeca106725 605 /**
Kojto 122:f9eeca106725 606 * @}
Kojto 122:f9eeca106725 607 */
Kojto 122:f9eeca106725 608
Kojto 122:f9eeca106725 609 /** @addtogroup CRYP_Exported_Functions_Group2 AES processing functions
Kojto 122:f9eeca106725 610 * @{
Kojto 122:f9eeca106725 611 */
Kojto 122:f9eeca106725 612
Kojto 122:f9eeca106725 613 /* AES encryption/decryption processing functions ****************************/
Kojto 122:f9eeca106725 614
Kojto 122:f9eeca106725 615 /* AES encryption/decryption using polling ***********************************/
Kojto 122:f9eeca106725 616 HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout);
Kojto 122:f9eeca106725 617 HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout);
Kojto 122:f9eeca106725 618 HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout);
Kojto 122:f9eeca106725 619 HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout);
Kojto 122:f9eeca106725 620 HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout);
Kojto 122:f9eeca106725 621 HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout);
Kojto 122:f9eeca106725 622
Kojto 122:f9eeca106725 623 /* AES encryption/decryption using interrupt *********************************/
Kojto 122:f9eeca106725 624 HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
Kojto 122:f9eeca106725 625 HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
Kojto 122:f9eeca106725 626 HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
Kojto 122:f9eeca106725 627 HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
Kojto 122:f9eeca106725 628 HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
Kojto 122:f9eeca106725 629 HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
Kojto 122:f9eeca106725 630
Kojto 122:f9eeca106725 631 /* AES encryption/decryption using DMA ***************************************/
Kojto 122:f9eeca106725 632 HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
Kojto 122:f9eeca106725 633 HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
Kojto 122:f9eeca106725 634 HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
Kojto 122:f9eeca106725 635 HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
Kojto 122:f9eeca106725 636 HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData);
Kojto 122:f9eeca106725 637 HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData);
Kojto 122:f9eeca106725 638
Kojto 122:f9eeca106725 639 /**
Kojto 122:f9eeca106725 640 * @}
Kojto 122:f9eeca106725 641 */
Kojto 122:f9eeca106725 642
Kojto 122:f9eeca106725 643 /** @addtogroup CRYP_Exported_Functions_Group3 Callback functions
Kojto 122:f9eeca106725 644 * @{
Kojto 122:f9eeca106725 645 */
Kojto 122:f9eeca106725 646 /* CallBack functions ********************************************************/
Kojto 122:f9eeca106725 647 void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 648 void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 649 void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 650
Kojto 122:f9eeca106725 651 /**
Kojto 122:f9eeca106725 652 * @}
Kojto 122:f9eeca106725 653 */
Kojto 122:f9eeca106725 654
Kojto 122:f9eeca106725 655 /** @addtogroup CRYP_Exported_Functions_Group4 CRYP IRQ handler
Kojto 122:f9eeca106725 656 * @{
Kojto 122:f9eeca106725 657 */
Kojto 122:f9eeca106725 658
Kojto 122:f9eeca106725 659 /* AES interrupt handling function *******************************************/
Kojto 122:f9eeca106725 660 void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 661
Kojto 122:f9eeca106725 662 /**
Kojto 122:f9eeca106725 663 * @}
Kojto 122:f9eeca106725 664 */
Kojto 122:f9eeca106725 665
Kojto 122:f9eeca106725 666 /** @addtogroup CRYP_Exported_Functions_Group5 Peripheral State functions
Kojto 122:f9eeca106725 667 * @{
Kojto 122:f9eeca106725 668 */
Kojto 122:f9eeca106725 669
Kojto 122:f9eeca106725 670 /* Peripheral State functions ************************************************/
Kojto 122:f9eeca106725 671 HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 672 uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp);
Kojto 122:f9eeca106725 673
Kojto 122:f9eeca106725 674 /**
Kojto 122:f9eeca106725 675 * @}
Kojto 122:f9eeca106725 676 */
Kojto 122:f9eeca106725 677
Kojto 122:f9eeca106725 678 /**
Kojto 122:f9eeca106725 679 * @}
Kojto 122:f9eeca106725 680 */
Kojto 122:f9eeca106725 681
Kojto 122:f9eeca106725 682 /**
Kojto 122:f9eeca106725 683 * @}
Kojto 122:f9eeca106725 684 */
Kojto 122:f9eeca106725 685
Kojto 122:f9eeca106725 686 /**
Kojto 122:f9eeca106725 687 * @}
Kojto 122:f9eeca106725 688 */
Kojto 122:f9eeca106725 689
AnnaBridge 145:64910690c574 690 #endif /* defined (STM32L442xx) || defined (STM32L443xx) || defined (STM32L462xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L4A6xx) */
Kojto 122:f9eeca106725 691
Kojto 122:f9eeca106725 692 #ifdef __cplusplus
Kojto 122:f9eeca106725 693 }
Kojto 122:f9eeca106725 694 #endif
Kojto 122:f9eeca106725 695
Kojto 122:f9eeca106725 696 #endif /* __STM32L4xx_HAL_CRYP_H */
Kojto 122:f9eeca106725 697
Kojto 122:f9eeca106725 698 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/