62 #define TDESBUSY_TIMEOUT ((uint32_t) 0x00010000)
101 uint32_t Ilength, uint8_t *Output)
105 __IO uint32_t counter = 0;
106 uint32_t busystatus = 0;
107 ErrorStatus status = SUCCESS;
108 uint32_t keyaddr = (uint32_t)Key;
109 uint32_t inputaddr = (uint32_t)Input;
110 uint32_t outputaddr = (uint32_t)Output;
117 if(Mode == MODE_ENCRYPT)
119 TDES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
123 TDES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
131 TDES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
133 TDES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
135 TDES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
137 TDES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
139 TDES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
141 TDES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
156 for(i=0; ((i<Ilength) && (status != ERROR)); i+=8)
170 }
while ((counter != TDESBUSY_TIMEOUT) && (busystatus != RESET));
172 if (busystatus != RESET)
208 ErrorStatus
CRYP_TDES_CBC(uint8_t Mode, uint8_t Key[24], uint8_t InitVectors[8],
209 uint8_t *Input, uint32_t Ilength, uint8_t *Output)
214 __IO uint32_t counter = 0;
215 uint32_t busystatus = 0;
216 ErrorStatus status = SUCCESS;
217 uint32_t keyaddr = (uint32_t)Key;
218 uint32_t inputaddr = (uint32_t)Input;
219 uint32_t outputaddr = (uint32_t)Output;
220 uint32_t ivaddr = (uint32_t)InitVectors;
227 if(Mode == MODE_ENCRYPT)
229 TDES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
233 TDES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
241 TDES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
243 TDES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
245 TDES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
247 TDES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
249 TDES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
251 TDES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
255 TDES_CRYP_IVInitStructure.
CRYP_IV0Left = __REV(*(uint32_t*)(ivaddr));
257 TDES_CRYP_IVInitStructure.
CRYP_IV0Right= __REV(*(uint32_t*)(ivaddr));
273 for(i=0; ((i<Ilength) && (status != ERROR)); i+=8)
287 }
while ((counter != TDESBUSY_TIMEOUT) && (busystatus != RESET));
289 if (busystatus != RESET)
CRYP Key(s) structure definition.
void CRYP_KeyInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Initializes the CRYP Keys according to the specified parameters in the CRYP_KeyInitStruct.
ErrorStatus CRYP_TDES_ECB(uint8_t Mode, uint8_t Key[24], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using TDES in ECB Mode.
void CRYP_Cmd(FunctionalState NewState)
Enables or disables the CRYP peripheral.
uint32_t CRYP_DataOut(void)
Returns the last data entered into the output FIFO.
void CRYP_IVInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
Initializes the CRYP Initialization Vectors(IV) according to the specified parameters in the CRYP_IVI...
#define CRYP_AlgoMode_TDES_ECB
void CRYP_KeyStructInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Fills each CRYP_KeyInitStruct member with its default value.
void CRYP_DataIn(uint32_t Data)
Writes data in the Data Input register (DIN).
FlagStatus CRYP_GetFlagStatus(uint8_t CRYP_FLAG)
Checks whether the specified CRYP flag is set or not.
void CRYP_Init(CRYP_InitTypeDef *CRYP_InitStruct)
Initializes the CRYP peripheral according to the specified parameters in the CRYP_InitStruct.
CRYP Initialization Vectors (IV) structure definition.
#define CRYP_AlgoMode_TDES_CBC
This file contains all the functions prototypes for the Cryptographic processor(CRYP) firmware librar...
void CRYP_FIFOFlush(void)
Flushes the IN and OUT FIFOs (that is read and write pointers of the FIFOs are reset) ...
ErrorStatus CRYP_TDES_CBC(uint8_t Mode, uint8_t Key[24], uint8_t InitVectors[8], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using TDES in CBC Mode.
CRYP Init structure definition.
FunctionalState CRYP_GetCmdStatus(void)
Returns whether CRYP peripheral is enabled or disabled.