version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
erezi
Date:
Wed Jun 25 06:08:49 2014 +0000
Revision:
86:4f9a848d74c7
Parent:
81:7d30d6019079
version_2.0

Who changed what in which revision?

UserRevisionLine numberNew 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 *
bogdanm 81:7d30d6019079 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
emilmont 77:869cf507173a 13 *
bogdanm 81:7d30d6019079 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 81:7d30d6019079 15 * are permitted provided that the following conditions are met:
bogdanm 81:7d30d6019079 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 81:7d30d6019079 17 * this list of conditions and the following disclaimer.
bogdanm 81:7d30d6019079 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 81:7d30d6019079 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 81:7d30d6019079 20 * and/or other materials provided with the distribution.
bogdanm 81:7d30d6019079 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 81:7d30d6019079 22 * may be used to endorse or promote products derived from this software
bogdanm 81:7d30d6019079 23 * without specific prior written permission.
emilmont 77:869cf507173a 24 *
bogdanm 81:7d30d6019079 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 81:7d30d6019079 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 81:7d30d6019079 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 81:7d30d6019079 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 81:7d30d6019079 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 81:7d30d6019079 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 81:7d30d6019079 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 81:7d30d6019079 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 81:7d30d6019079 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 81:7d30d6019079 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
emilmont 77:869cf507173a 35 *
emilmont 77:869cf507173a 36 ******************************************************************************
emilmont 77:869cf507173a 37 */
emilmont 77:869cf507173a 38
emilmont 77:869cf507173a 39 /* Define to prevent recursive inclusion -------------------------------------*/
emilmont 77:869cf507173a 40 #ifndef __STM32L1xx_AES_H
emilmont 77:869cf507173a 41 #define __STM32L1xx_AES_H
emilmont 77:869cf507173a 42
emilmont 77:869cf507173a 43 #ifdef __cplusplus
emilmont 77:869cf507173a 44 extern "C" {
emilmont 77:869cf507173a 45 #endif
emilmont 77:869cf507173a 46
emilmont 77:869cf507173a 47 /* Includes ------------------------------------------------------------------*/
emilmont 77:869cf507173a 48 #include "stm32l1xx.h"
emilmont 77:869cf507173a 49
emilmont 77:869cf507173a 50 /** @addtogroup STM32L1xx_StdPeriph_Driver
emilmont 77:869cf507173a 51 * @{
emilmont 77:869cf507173a 52 */
emilmont 77:869cf507173a 53
emilmont 77:869cf507173a 54 /** @addtogroup AES
emilmont 77:869cf507173a 55 * @{
emilmont 77:869cf507173a 56 */
emilmont 77:869cf507173a 57
emilmont 77:869cf507173a 58 /* Exported types ------------------------------------------------------------*/
emilmont 77:869cf507173a 59
emilmont 77:869cf507173a 60 /**
emilmont 77:869cf507173a 61 * @brief AES Init structure definition
emilmont 77:869cf507173a 62 */
emilmont 77:869cf507173a 63 typedef struct
emilmont 77:869cf507173a 64 {
emilmont 77:869cf507173a 65 uint32_t AES_Operation; /*!< Specifies the AES mode of operation.
emilmont 77:869cf507173a 66 This parameter can be a value of @ref AES_possible_Operation_modes */
emilmont 77:869cf507173a 67 uint32_t AES_Chaining; /*!< Specifies the AES Chaining modes: ECB, CBC or CTR.
emilmont 77:869cf507173a 68 This parameter can be a value of @ref AES_possible_chaining_modes */
emilmont 77:869cf507173a 69 uint32_t AES_DataType; /*!< Specifies the AES data swapping: 32-bit, 16-bit, 8-bit or 1-bit.
emilmont 77:869cf507173a 70 This parameter can be a value of @ref AES_Data_Types */
emilmont 77:869cf507173a 71 }AES_InitTypeDef;
emilmont 77:869cf507173a 72
emilmont 77:869cf507173a 73 /**
emilmont 77:869cf507173a 74 * @brief AES Key(s) structure definition
emilmont 77:869cf507173a 75 */
emilmont 77:869cf507173a 76 typedef struct
emilmont 77:869cf507173a 77 {
emilmont 77:869cf507173a 78 uint32_t AES_Key0; /*!< Key[31:0] */
emilmont 77:869cf507173a 79 uint32_t AES_Key1; /*!< Key[63:32] */
emilmont 77:869cf507173a 80 uint32_t AES_Key2; /*!< Key[95:64] */
emilmont 77:869cf507173a 81 uint32_t AES_Key3; /*!< Key[127:96] */
emilmont 77:869cf507173a 82 }AES_KeyInitTypeDef;
emilmont 77:869cf507173a 83
emilmont 77:869cf507173a 84 /**
emilmont 77:869cf507173a 85 * @brief AES Initialization Vectors (IV) structure definition
emilmont 77:869cf507173a 86 */
emilmont 77:869cf507173a 87 typedef struct
emilmont 77:869cf507173a 88 {
emilmont 77:869cf507173a 89 uint32_t AES_IV0; /*!< Init Vector IV[31:0] */
emilmont 77:869cf507173a 90 uint32_t AES_IV1; /*!< Init Vector IV[63:32] */
emilmont 77:869cf507173a 91 uint32_t AES_IV2; /*!< Init Vector IV[95:64] */
emilmont 77:869cf507173a 92 uint32_t AES_IV3; /*!< Init Vector IV[127:96] */
emilmont 77:869cf507173a 93 }AES_IVInitTypeDef;
emilmont 77:869cf507173a 94
emilmont 77:869cf507173a 95 /* Exported constants --------------------------------------------------------*/
emilmont 77:869cf507173a 96
emilmont 77:869cf507173a 97 /** @defgroup AES_Exported_Constants
emilmont 77:869cf507173a 98 * @{
emilmont 77:869cf507173a 99 */
emilmont 77:869cf507173a 100
emilmont 77:869cf507173a 101 /** @defgroup AES_possible_Operation_modes
emilmont 77:869cf507173a 102 * @{
emilmont 77:869cf507173a 103 */
emilmont 77:869cf507173a 104 #define AES_Operation_Encryp ((uint32_t)0x00000000) /*!< AES in Encryption mode */
emilmont 77:869cf507173a 105 #define AES_Operation_KeyDeriv AES_CR_MODE_0 /*!< AES in Key Derivation mode */
emilmont 77:869cf507173a 106 #define AES_Operation_Decryp AES_CR_MODE_1 /*!< AES in Decryption mode */
emilmont 77:869cf507173a 107 #define AES_Operation_KeyDerivAndDecryp AES_CR_MODE /*!< AES in Key Derivation and Decryption mode */
emilmont 77:869cf507173a 108
emilmont 77:869cf507173a 109 #define IS_AES_MODE(OPERATION) (((OPERATION) == AES_Operation_Encryp) || \
emilmont 77:869cf507173a 110 ((OPERATION) == AES_Operation_KeyDeriv) || \
emilmont 77:869cf507173a 111 ((OPERATION) == AES_Operation_Decryp) || \
emilmont 77:869cf507173a 112 ((OPERATION) == AES_Operation_KeyDerivAndDecryp))
emilmont 77:869cf507173a 113
emilmont 77:869cf507173a 114 /**
emilmont 77:869cf507173a 115 * @}
emilmont 77:869cf507173a 116 */
emilmont 77:869cf507173a 117
emilmont 77:869cf507173a 118 /** @defgroup AES_possible_chaining_modes
emilmont 77:869cf507173a 119 * @{
emilmont 77:869cf507173a 120 */
emilmont 77:869cf507173a 121 #define AES_Chaining_ECB ((uint32_t)0x00000000) /*!< AES in ECB chaining mode */
emilmont 77:869cf507173a 122 #define AES_Chaining_CBC AES_CR_CHMOD_0 /*!< AES in CBC chaining mode */
emilmont 77:869cf507173a 123 #define AES_Chaining_CTR AES_CR_CHMOD_1 /*!< AES in CTR chaining mode */
emilmont 77:869cf507173a 124
emilmont 77:869cf507173a 125 #define IS_AES_CHAINING(CHAINING) (((CHAINING) == AES_Chaining_ECB) || \
emilmont 77:869cf507173a 126 ((CHAINING) == AES_Chaining_CBC) || \
emilmont 77:869cf507173a 127 ((CHAINING) == AES_Chaining_CTR))
emilmont 77:869cf507173a 128 /**
emilmont 77:869cf507173a 129 * @}
emilmont 77:869cf507173a 130 */
emilmont 77:869cf507173a 131
emilmont 77:869cf507173a 132 /** @defgroup AES_Data_Types
emilmont 77:869cf507173a 133 * @{
emilmont 77:869cf507173a 134 */
emilmont 77:869cf507173a 135 #define AES_DataType_32b ((uint32_t)0x00000000) /*!< 32-bit data. No swapping */
emilmont 77:869cf507173a 136 #define AES_DataType_16b AES_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */
emilmont 77:869cf507173a 137 #define AES_DataType_8b AES_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */
emilmont 77:869cf507173a 138 #define AES_DataType_1b AES_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */
emilmont 77:869cf507173a 139
emilmont 77:869cf507173a 140 #define IS_AES_DATATYPE(DATATYPE) (((DATATYPE) == AES_DataType_32b) || \
emilmont 77:869cf507173a 141 ((DATATYPE) == AES_DataType_16b)|| \
emilmont 77:869cf507173a 142 ((DATATYPE) == AES_DataType_8b) || \
emilmont 77:869cf507173a 143 ((DATATYPE) == AES_DataType_1b))
emilmont 77:869cf507173a 144 /**
emilmont 77:869cf507173a 145 * @}
emilmont 77:869cf507173a 146 */
emilmont 77:869cf507173a 147
emilmont 77:869cf507173a 148 /** @defgroup AES_Flags
emilmont 77:869cf507173a 149 * @{
emilmont 77:869cf507173a 150 */
emilmont 77:869cf507173a 151 #define AES_FLAG_CCF AES_SR_CCF /*!< Computation Complete Flag */
emilmont 77:869cf507173a 152 #define AES_FLAG_RDERR AES_SR_RDERR /*!< Read Error Flag */
emilmont 77:869cf507173a 153 #define AES_FLAG_WRERR AES_SR_WRERR /*!< Write Error Flag */
emilmont 77:869cf507173a 154
emilmont 77:869cf507173a 155 #define IS_AES_FLAG(FLAG) (((FLAG) == AES_FLAG_CCF) || \
emilmont 77:869cf507173a 156 ((FLAG) == AES_FLAG_RDERR) || \
emilmont 77:869cf507173a 157 ((FLAG) == AES_FLAG_WRERR))
emilmont 77:869cf507173a 158 /**
emilmont 77:869cf507173a 159 * @}
emilmont 77:869cf507173a 160 */
emilmont 77:869cf507173a 161
emilmont 77:869cf507173a 162 /** @defgroup AES_Interrupts
emilmont 77:869cf507173a 163 * @{
emilmont 77:869cf507173a 164 */
emilmont 77:869cf507173a 165 #define AES_IT_CC AES_CR_CCIE /*!< Computation Complete interrupt */
emilmont 77:869cf507173a 166 #define AES_IT_ERR AES_CR_ERRIE /*!< Error interrupt */
emilmont 77:869cf507173a 167
emilmont 77:869cf507173a 168 #define IS_AES_IT(IT) ((((IT) & (uint32_t)0xFFFFF9FF) == 0x00) && ((IT) != 0x00))
emilmont 77:869cf507173a 169 #define IS_AES_GET_IT(IT) (((IT) == AES_IT_CC) || ((IT) == AES_IT_ERR))
emilmont 77:869cf507173a 170
emilmont 77:869cf507173a 171 /**
emilmont 77:869cf507173a 172 * @}
emilmont 77:869cf507173a 173 */
emilmont 77:869cf507173a 174
emilmont 77:869cf507173a 175 /** @defgroup AES_DMA_Transfer_modes
emilmont 77:869cf507173a 176 * @{
emilmont 77:869cf507173a 177 */
emilmont 77:869cf507173a 178 #define AES_DMATransfer_In AES_CR_DMAINEN /*!< DMA requests enabled for input transfer phase */
emilmont 77:869cf507173a 179 #define AES_DMATransfer_Out AES_CR_DMAOUTEN /*!< DMA requests enabled for input transfer phase */
emilmont 77:869cf507173a 180 #define AES_DMATransfer_InOut (AES_CR_DMAINEN | AES_CR_DMAOUTEN) /*!< DMA requests enabled for both input and output phases */
emilmont 77:869cf507173a 181
emilmont 77:869cf507173a 182 #define IS_AES_DMA_TRANSFER(TRANSFER) (((TRANSFER) == AES_DMATransfer_In) || \
emilmont 77:869cf507173a 183 ((TRANSFER) == AES_DMATransfer_Out) || \
emilmont 77:869cf507173a 184 ((TRANSFER) == AES_DMATransfer_InOut))
emilmont 77:869cf507173a 185 /**
emilmont 77:869cf507173a 186 * @}
emilmont 77:869cf507173a 187 */
emilmont 77:869cf507173a 188
emilmont 77:869cf507173a 189 /**
emilmont 77:869cf507173a 190 * @}
emilmont 77:869cf507173a 191 */
emilmont 77:869cf507173a 192
emilmont 77:869cf507173a 193 /* Exported macro ------------------------------------------------------------*/
emilmont 77:869cf507173a 194 /* Exported functions ------------------------------------------------------- */
emilmont 77:869cf507173a 195
emilmont 77:869cf507173a 196 /* Initialization and configuration functions *********************************/
emilmont 77:869cf507173a 197 void AES_DeInit(void);
emilmont 77:869cf507173a 198 void AES_Init(AES_InitTypeDef* AES_InitStruct);
emilmont 77:869cf507173a 199 void AES_KeyInit(AES_KeyInitTypeDef* AES_KeyInitStruct);
emilmont 77:869cf507173a 200 void AES_IVInit(AES_IVInitTypeDef* AES_IVInitStruct);
emilmont 77:869cf507173a 201 void AES_Cmd(FunctionalState NewState);
emilmont 77:869cf507173a 202
emilmont 77:869cf507173a 203 /* Structures initialization functions ****************************************/
emilmont 77:869cf507173a 204 void AES_StructInit(AES_InitTypeDef* AES_InitStruct);
emilmont 77:869cf507173a 205 void AES_KeyStructInit(AES_KeyInitTypeDef* AES_KeyInitStruct);
emilmont 77:869cf507173a 206 void AES_IVStructInit(AES_IVInitTypeDef* AES_IVInitStruct);
emilmont 77:869cf507173a 207
emilmont 77:869cf507173a 208 /* AES Read and Write functions **********************************************/
emilmont 77:869cf507173a 209 void AES_WriteSubData(uint32_t Data);
emilmont 77:869cf507173a 210 uint32_t AES_ReadSubData(void);
emilmont 77:869cf507173a 211 void AES_ReadKey(AES_KeyInitTypeDef* AES_KeyInitStruct);
emilmont 77:869cf507173a 212 void AES_ReadIV(AES_IVInitTypeDef* AES_IVInitStruct);
emilmont 77:869cf507173a 213
emilmont 77:869cf507173a 214 /* DMA transfers management function ******************************************/
emilmont 77:869cf507173a 215 void AES_DMAConfig(uint32_t AES_DMATransfer, FunctionalState NewState);
emilmont 77:869cf507173a 216
emilmont 77:869cf507173a 217 /* Interrupts and flags management functions **********************************/
emilmont 77:869cf507173a 218 void AES_ITConfig(uint32_t AES_IT, FunctionalState NewState);
emilmont 77:869cf507173a 219 FlagStatus AES_GetFlagStatus(uint32_t AES_FLAG);
emilmont 77:869cf507173a 220 void AES_ClearFlag(uint32_t AES_FLAG);
emilmont 77:869cf507173a 221 ITStatus AES_GetITStatus(uint32_t AES_IT);
emilmont 77:869cf507173a 222 void AES_ClearITPendingBit(uint32_t AES_IT);
emilmont 77:869cf507173a 223
emilmont 77:869cf507173a 224 /* High Level AES functions **************************************************/
emilmont 77:869cf507173a 225 ErrorStatus AES_ECB_Encrypt(uint8_t* Key, uint8_t* Input, uint32_t Ilength, uint8_t* Output);
emilmont 77:869cf507173a 226 ErrorStatus AES_ECB_Decrypt(uint8_t* Key, uint8_t* Input, uint32_t Ilength, uint8_t* Output);
emilmont 77:869cf507173a 227 ErrorStatus AES_CBC_Encrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output);
emilmont 77:869cf507173a 228 ErrorStatus AES_CBC_Decrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output);
emilmont 77:869cf507173a 229 ErrorStatus AES_CTR_Encrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output);
emilmont 77:869cf507173a 230 ErrorStatus AES_CTR_Decrypt(uint8_t* Key, uint8_t InitVectors[16], uint8_t* Input, uint32_t Ilength, uint8_t* Output);
emilmont 77:869cf507173a 231
emilmont 77:869cf507173a 232 #ifdef __cplusplus
emilmont 77:869cf507173a 233 }
emilmont 77:869cf507173a 234 #endif
emilmont 77:869cf507173a 235
emilmont 77:869cf507173a 236 #endif /*__STM32L1xx_AES_H */
emilmont 77:869cf507173a 237
emilmont 77:869cf507173a 238 /**
emilmont 77:869cf507173a 239 * @}
emilmont 77:869cf507173a 240 */
emilmont 77:869cf507173a 241
emilmont 77:869cf507173a 242 /**
emilmont 77:869cf507173a 243 * @}
emilmont 77:869cf507173a 244 */
emilmont 77:869cf507173a 245
emilmont 77:869cf507173a 246 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/