mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Feb 26 09:45:12 2014 +0000
Revision:
106:ced8cbb51063
Parent:
80:66393a7b209d
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd

Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/

[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license

Who changed what in which revision?

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