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