ads1115 only
Fork of mbed by
TARGET_NUCLEO_L152RE/stm32l1xx_aes.h@77:869cf507173a, 2014-02-14 (annotated)
- Committer:
- emilmont
- Date:
- Fri Feb 14 14:36:43 2014 +0000
- Revision:
- 77:869cf507173a
- Child:
- 81:7d30d6019079
Release 77 of the mbed library
Main changes:
* Add target NUCLEO_F030R8
* Add target NUCLEO_F401RE
* Add target NUCLEO_F103RB
* Add target NUCLEO_L152RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 77:869cf507173a | 1 | /** |
emilmont | 77:869cf507173a | 2 | ****************************************************************************** |
emilmont | 77:869cf507173a | 3 | * @file stm32l1xx_aes.h |
emilmont | 77:869cf507173a | 4 | * @author MCD Application Team |
emilmont | 77:869cf507173a | 5 | * @version V1.3.0 |
emilmont | 77:869cf507173a | 6 | * @date 31-January-2014 |
emilmont | 77:869cf507173a | 7 | * @brief This file contains all the functions prototypes for the AES firmware |
emilmont | 77:869cf507173a | 8 | * library. |
emilmont | 77:869cf507173a | 9 | ****************************************************************************** |
emilmont | 77:869cf507173a | 10 | * @attention |
emilmont | 77:869cf507173a | 11 | * |
emilmont | 77:869cf507173a | 12 | * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
emilmont | 77:869cf507173a | 13 | * |
emilmont | 77:869cf507173a | 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
emilmont | 77:869cf507173a | 15 | * You may not use this file except in compliance with the License. |
emilmont | 77:869cf507173a | 16 | * You may obtain a copy of the License at: |
emilmont | 77:869cf507173a | 17 | * |
emilmont | 77:869cf507173a | 18 | * http://www.st.com/software_license_agreement_liberty_v2 |
emilmont | 77:869cf507173a | 19 | * |
emilmont | 77:869cf507173a | 20 | * Unless required by applicable law or agreed to in writing, software |
emilmont | 77:869cf507173a | 21 | * distributed under the License is distributed on an "AS IS" BASIS, |
emilmont | 77:869cf507173a | 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
emilmont | 77:869cf507173a | 23 | * See the License for the specific language governing permissions and |
emilmont | 77:869cf507173a | 24 | * limitations under the License. |
emilmont | 77:869cf507173a | 25 | * |
emilmont | 77:869cf507173a | 26 | ****************************************************************************** |
emilmont | 77:869cf507173a | 27 | */ |
emilmont | 77:869cf507173a | 28 | |
emilmont | 77:869cf507173a | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ |
emilmont | 77:869cf507173a | 30 | #ifndef __STM32L1xx_AES_H |
emilmont | 77:869cf507173a | 31 | #define __STM32L1xx_AES_H |
emilmont | 77:869cf507173a | 32 | |
emilmont | 77:869cf507173a | 33 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 34 | extern "C" { |
emilmont | 77:869cf507173a | 35 | #endif |
emilmont | 77:869cf507173a | 36 | |
emilmont | 77:869cf507173a | 37 | /* Includes ------------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 38 | #include "stm32l1xx.h" |
emilmont | 77:869cf507173a | 39 | |
emilmont | 77:869cf507173a | 40 | /** @addtogroup STM32L1xx_StdPeriph_Driver |
emilmont | 77:869cf507173a | 41 | * @{ |
emilmont | 77:869cf507173a | 42 | */ |
emilmont | 77:869cf507173a | 43 | |
emilmont | 77:869cf507173a | 44 | /** @addtogroup AES |
emilmont | 77:869cf507173a | 45 | * @{ |
emilmont | 77:869cf507173a | 46 | */ |
emilmont | 77:869cf507173a | 47 | |
emilmont | 77:869cf507173a | 48 | /* Exported types ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 49 | |
emilmont | 77:869cf507173a | 50 | /** |
emilmont | 77:869cf507173a | 51 | * @brief AES Init structure definition |
emilmont | 77:869cf507173a | 52 | */ |
emilmont | 77:869cf507173a | 53 | typedef struct |
emilmont | 77:869cf507173a | 54 | { |
emilmont | 77:869cf507173a | 55 | uint32_t AES_Operation; /*!< Specifies the AES mode of operation. |
emilmont | 77:869cf507173a | 56 | This parameter can be a value of @ref AES_possible_Operation_modes */ |
emilmont | 77:869cf507173a | 57 | uint32_t AES_Chaining; /*!< Specifies the AES Chaining modes: ECB, CBC or CTR. |
emilmont | 77:869cf507173a | 58 | This parameter can be a value of @ref AES_possible_chaining_modes */ |
emilmont | 77:869cf507173a | 59 | uint32_t AES_DataType; /*!< Specifies the AES data swapping: 32-bit, 16-bit, 8-bit or 1-bit. |
emilmont | 77:869cf507173a | 60 | This parameter can be a value of @ref AES_Data_Types */ |
emilmont | 77:869cf507173a | 61 | }AES_InitTypeDef; |
emilmont | 77:869cf507173a | 62 | |
emilmont | 77:869cf507173a | 63 | /** |
emilmont | 77:869cf507173a | 64 | * @brief AES Key(s) structure definition |
emilmont | 77:869cf507173a | 65 | */ |
emilmont | 77:869cf507173a | 66 | typedef struct |
emilmont | 77:869cf507173a | 67 | { |
emilmont | 77:869cf507173a | 68 | uint32_t AES_Key0; /*!< Key[31:0] */ |
emilmont | 77:869cf507173a | 69 | uint32_t AES_Key1; /*!< Key[63:32] */ |
emilmont | 77:869cf507173a | 70 | uint32_t AES_Key2; /*!< Key[95:64] */ |
emilmont | 77:869cf507173a | 71 | uint32_t AES_Key3; /*!< Key[127:96] */ |
emilmont | 77:869cf507173a | 72 | }AES_KeyInitTypeDef; |
emilmont | 77:869cf507173a | 73 | |
emilmont | 77:869cf507173a | 74 | /** |
emilmont | 77:869cf507173a | 75 | * @brief AES Initialization Vectors (IV) structure definition |
emilmont | 77:869cf507173a | 76 | */ |
emilmont | 77:869cf507173a | 77 | typedef struct |
emilmont | 77:869cf507173a | 78 | { |
emilmont | 77:869cf507173a | 79 | uint32_t AES_IV0; /*!< Init Vector IV[31:0] */ |
emilmont | 77:869cf507173a | 80 | uint32_t AES_IV1; /*!< Init Vector IV[63:32] */ |
emilmont | 77:869cf507173a | 81 | uint32_t AES_IV2; /*!< Init Vector IV[95:64] */ |
emilmont | 77:869cf507173a | 82 | uint32_t AES_IV3; /*!< Init Vector IV[127:96] */ |
emilmont | 77:869cf507173a | 83 | }AES_IVInitTypeDef; |
emilmont | 77:869cf507173a | 84 | |
emilmont | 77:869cf507173a | 85 | /* Exported constants --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 86 | |
emilmont | 77:869cf507173a | 87 | /** @defgroup AES_Exported_Constants |
emilmont | 77:869cf507173a | 88 | * @{ |
emilmont | 77:869cf507173a | 89 | */ |
emilmont | 77:869cf507173a | 90 | |
emilmont | 77:869cf507173a | 91 | /** @defgroup AES_possible_Operation_modes |
emilmont | 77:869cf507173a | 92 | * @{ |
emilmont | 77:869cf507173a | 93 | */ |
emilmont | 77:869cf507173a | 94 | #define AES_Operation_Encryp ((uint32_t)0x00000000) /*!< AES in Encryption mode */ |
emilmont | 77:869cf507173a | 95 | #define AES_Operation_KeyDeriv AES_CR_MODE_0 /*!< AES in Key Derivation mode */ |
emilmont | 77:869cf507173a | 96 | #define AES_Operation_Decryp AES_CR_MODE_1 /*!< AES in Decryption mode */ |
emilmont | 77:869cf507173a | 97 | #define AES_Operation_KeyDerivAndDecryp AES_CR_MODE /*!< AES in Key Derivation and Decryption mode */ |
emilmont | 77:869cf507173a | 98 | |
emilmont | 77:869cf507173a | 99 | #define IS_AES_MODE(OPERATION) (((OPERATION) == AES_Operation_Encryp) || \ |
emilmont | 77:869cf507173a | 100 | ((OPERATION) == AES_Operation_KeyDeriv) || \ |
emilmont | 77:869cf507173a | 101 | ((OPERATION) == AES_Operation_Decryp) || \ |
emilmont | 77:869cf507173a | 102 | ((OPERATION) == AES_Operation_KeyDerivAndDecryp)) |
emilmont | 77:869cf507173a | 103 | |
emilmont | 77:869cf507173a | 104 | /** |
emilmont | 77:869cf507173a | 105 | * @} |
emilmont | 77:869cf507173a | 106 | */ |
emilmont | 77:869cf507173a | 107 | |
emilmont | 77:869cf507173a | 108 | /** @defgroup AES_possible_chaining_modes |
emilmont | 77:869cf507173a | 109 | * @{ |
emilmont | 77:869cf507173a | 110 | */ |
emilmont | 77:869cf507173a | 111 | #define AES_Chaining_ECB ((uint32_t)0x00000000) /*!< AES in ECB chaining mode */ |
emilmont | 77:869cf507173a | 112 | #define AES_Chaining_CBC AES_CR_CHMOD_0 /*!< AES in CBC chaining mode */ |
emilmont | 77:869cf507173a | 113 | #define AES_Chaining_CTR AES_CR_CHMOD_1 /*!< AES in CTR chaining mode */ |
emilmont | 77:869cf507173a | 114 | |
emilmont | 77:869cf507173a | 115 | #define IS_AES_CHAINING(CHAINING) (((CHAINING) == AES_Chaining_ECB) || \ |
emilmont | 77:869cf507173a | 116 | ((CHAINING) == AES_Chaining_CBC) || \ |
emilmont | 77:869cf507173a | 117 | ((CHAINING) == AES_Chaining_CTR)) |
emilmont | 77:869cf507173a | 118 | /** |
emilmont | 77:869cf507173a | 119 | * @} |
emilmont | 77:869cf507173a | 120 | */ |
emilmont | 77:869cf507173a | 121 | |
emilmont | 77:869cf507173a | 122 | /** @defgroup AES_Data_Types |
emilmont | 77:869cf507173a | 123 | * @{ |
emilmont | 77:869cf507173a | 124 | */ |
emilmont | 77:869cf507173a | 125 | #define AES_DataType_32b ((uint32_t)0x00000000) /*!< 32-bit data. No swapping */ |
emilmont | 77:869cf507173a | 126 | #define AES_DataType_16b AES_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */ |
emilmont | 77:869cf507173a | 127 | #define AES_DataType_8b AES_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */ |
emilmont | 77:869cf507173a | 128 | #define AES_DataType_1b AES_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */ |
emilmont | 77:869cf507173a | 129 | |
emilmont | 77:869cf507173a | 130 | #define IS_AES_DATATYPE(DATATYPE) (((DATATYPE) == AES_DataType_32b) || \ |
emilmont | 77:869cf507173a | 131 | ((DATATYPE) == AES_DataType_16b)|| \ |
emilmont | 77:869cf507173a | 132 | ((DATATYPE) == AES_DataType_8b) || \ |
emilmont | 77:869cf507173a | 133 | ((DATATYPE) == AES_DataType_1b)) |
emilmont | 77:869cf507173a | 134 | /** |
emilmont | 77:869cf507173a | 135 | * @} |
emilmont | 77:869cf507173a | 136 | */ |
emilmont | 77:869cf507173a | 137 | |
emilmont | 77:869cf507173a | 138 | /** @defgroup AES_Flags |
emilmont | 77:869cf507173a | 139 | * @{ |
emilmont | 77:869cf507173a | 140 | */ |
emilmont | 77:869cf507173a | 141 | #define AES_FLAG_CCF AES_SR_CCF /*!< Computation Complete Flag */ |
emilmont | 77:869cf507173a | 142 | #define AES_FLAG_RDERR AES_SR_RDERR /*!< Read Error Flag */ |
emilmont | 77:869cf507173a | 143 | #define AES_FLAG_WRERR AES_SR_WRERR /*!< Write Error Flag */ |
emilmont | 77:869cf507173a | 144 | |
emilmont | 77:869cf507173a | 145 | #define IS_AES_FLAG(FLAG) (((FLAG) == AES_FLAG_CCF) || \ |
emilmont | 77:869cf507173a | 146 | ((FLAG) == AES_FLAG_RDERR) || \ |
emilmont | 77:869cf507173a | 147 | ((FLAG) == AES_FLAG_WRERR)) |
emilmont | 77:869cf507173a | 148 | /** |
emilmont | 77:869cf507173a | 149 | * @} |
emilmont | 77:869cf507173a | 150 | */ |
emilmont | 77:869cf507173a | 151 | |
emilmont | 77:869cf507173a | 152 | /** @defgroup AES_Interrupts |
emilmont | 77:869cf507173a | 153 | * @{ |
emilmont | 77:869cf507173a | 154 | */ |
emilmont | 77:869cf507173a | 155 | #define AES_IT_CC AES_CR_CCIE /*!< Computation Complete interrupt */ |
emilmont | 77:869cf507173a | 156 | #define AES_IT_ERR AES_CR_ERRIE /*!< Error interrupt */ |
emilmont | 77:869cf507173a | 157 | |
emilmont | 77:869cf507173a | 158 | #define IS_AES_IT(IT) ((((IT) & (uint32_t)0xFFFFF9FF) == 0x00) && ((IT) != 0x00)) |
emilmont | 77:869cf507173a | 159 | #define IS_AES_GET_IT(IT) (((IT) == AES_IT_CC) || ((IT) == AES_IT_ERR)) |
emilmont | 77:869cf507173a | 160 | |
emilmont | 77:869cf507173a | 161 | /** |
emilmont | 77:869cf507173a | 162 | * @} |
emilmont | 77:869cf507173a | 163 | */ |
emilmont | 77:869cf507173a | 164 | |
emilmont | 77:869cf507173a | 165 | /** @defgroup AES_DMA_Transfer_modes |
emilmont | 77:869cf507173a | 166 | * @{ |
emilmont | 77:869cf507173a | 167 | */ |
emilmont | 77:869cf507173a | 168 | #define AES_DMATransfer_In AES_CR_DMAINEN /*!< DMA requests enabled for input transfer phase */ |
emilmont | 77:869cf507173a | 169 | #define AES_DMATransfer_Out AES_CR_DMAOUTEN /*!< DMA requests enabled for input transfer phase */ |
emilmont | 77:869cf507173a | 170 | #define AES_DMATransfer_InOut (AES_CR_DMAINEN | AES_CR_DMAOUTEN) /*!< DMA requests enabled for both input and output phases */ |
emilmont | 77:869cf507173a | 171 | |
emilmont | 77:869cf507173a | 172 | #define IS_AES_DMA_TRANSFER(TRANSFER) (((TRANSFER) == AES_DMATransfer_In) || \ |
emilmont | 77:869cf507173a | 173 | ((TRANSFER) == AES_DMATransfer_Out) || \ |
emilmont | 77:869cf507173a | 174 | ((TRANSFER) == AES_DMATransfer_InOut)) |
emilmont | 77:869cf507173a | 175 | /** |
emilmont | 77:869cf507173a | 176 | * @} |
emilmont | 77:869cf507173a | 177 | */ |
emilmont | 77:869cf507173a | 178 | |
emilmont | 77:869cf507173a | 179 | /** |
emilmont | 77:869cf507173a | 180 | * @} |
emilmont | 77:869cf507173a | 181 | */ |
emilmont | 77:869cf507173a | 182 | |
emilmont | 77:869cf507173a | 183 | /* Exported macro ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 184 | /* Exported functions ------------------------------------------------------- */ |
emilmont | 77:869cf507173a | 185 | |
emilmont | 77:869cf507173a | 186 | /* Initialization and configuration functions *********************************/ |
emilmont | 77:869cf507173a | 187 | void AES_DeInit(void); |
emilmont | 77:869cf507173a | 188 | void AES_Init(AES_InitTypeDef* AES_InitStruct); |
emilmont | 77:869cf507173a | 189 | void AES_KeyInit(AES_KeyInitTypeDef* AES_KeyInitStruct); |
emilmont | 77:869cf507173a | 190 | void AES_IVInit(AES_IVInitTypeDef* AES_IVInitStruct); |
emilmont | 77:869cf507173a | 191 | void AES_Cmd(FunctionalState NewState); |
emilmont | 77:869cf507173a | 192 | |
emilmont | 77:869cf507173a | 193 | /* Structures initialization functions ****************************************/ |
emilmont | 77:869cf507173a | 194 | void AES_StructInit(AES_InitTypeDef* AES_InitStruct); |
emilmont | 77:869cf507173a | 195 | void AES_KeyStructInit(AES_KeyInitTypeDef* AES_KeyInitStruct); |
emilmont | 77:869cf507173a | 196 | void AES_IVStructInit(AES_IVInitTypeDef* AES_IVInitStruct); |
emilmont | 77:869cf507173a | 197 | |
emilmont | 77:869cf507173a | 198 | /* AES Read and Write functions **********************************************/ |
emilmont | 77:869cf507173a | 199 | void AES_WriteSubData(uint32_t Data); |
emilmont | 77:869cf507173a | 200 | uint32_t AES_ReadSubData(void); |
emilmont | 77:869cf507173a | 201 | void AES_ReadKey(AES_KeyInitTypeDef* AES_KeyInitStruct); |
emilmont | 77:869cf507173a | 202 | void AES_ReadIV(AES_IVInitTypeDef* AES_IVInitStruct); |
emilmont | 77:869cf507173a | 203 | |
emilmont | 77:869cf507173a | 204 | /* DMA transfers management function ******************************************/ |
emilmont | 77:869cf507173a | 205 | void AES_DMAConfig(uint32_t AES_DMATransfer, FunctionalState NewState); |
emilmont | 77:869cf507173a | 206 | |
emilmont | 77:869cf507173a | 207 | /* Interrupts and flags management functions **********************************/ |
emilmont | 77:869cf507173a | 208 | void AES_ITConfig(uint32_t AES_IT, FunctionalState NewState); |
emilmont | 77:869cf507173a | 209 | FlagStatus AES_GetFlagStatus(uint32_t AES_FLAG); |
emilmont | 77:869cf507173a | 210 | void AES_ClearFlag(uint32_t AES_FLAG); |
emilmont | 77:869cf507173a | 211 | ITStatus AES_GetITStatus(uint32_t AES_IT); |
emilmont | 77:869cf507173a | 212 | void AES_ClearITPendingBit(uint32_t AES_IT); |
emilmont | 77:869cf507173a | 213 | |
emilmont | 77:869cf507173a | 214 | /* High Level AES functions **************************************************/ |
emilmont | 77:869cf507173a | 215 | ErrorStatus AES_ECB_Encrypt(uint8_t* Key, uint8_t* Input, uint32_t Ilength, uint8_t* Output); |
emilmont | 77:869cf507173a | 216 | ErrorStatus AES_ECB_Decrypt(uint8_t* Key, uint8_t* Input, uint32_t Ilength, uint8_t* Output); |
emilmont | 77:869cf507173a | 217 | ErrorStatus AES_CBC_Encrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output); |
emilmont | 77:869cf507173a | 218 | ErrorStatus AES_CBC_Decrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output); |
emilmont | 77:869cf507173a | 219 | ErrorStatus AES_CTR_Encrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output); |
emilmont | 77:869cf507173a | 220 | ErrorStatus AES_CTR_Decrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output); |
emilmont | 77:869cf507173a | 221 | |
emilmont | 77:869cf507173a | 222 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 223 | } |
emilmont | 77:869cf507173a | 224 | #endif |
emilmont | 77:869cf507173a | 225 | |
emilmont | 77:869cf507173a | 226 | #endif /*__STM32L1xx_AES_H */ |
emilmont | 77:869cf507173a | 227 | |
emilmont | 77:869cf507173a | 228 | /** |
emilmont | 77:869cf507173a | 229 | * @} |
emilmont | 77:869cf507173a | 230 | */ |
emilmont | 77:869cf507173a | 231 | |
emilmont | 77:869cf507173a | 232 | /** |
emilmont | 77:869cf507173a | 233 | * @} |
emilmont | 77:869cf507173a | 234 | */ |
emilmont | 77:869cf507173a | 235 | |
emilmont | 77:869cf507173a | 236 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |