62 #define DESBUSY_TIMEOUT ((uint32_t) 0x00010000)
99 ErrorStatus
CRYP_DES_ECB(uint8_t Mode, uint8_t Key[8], uint8_t *Input,
100 uint32_t Ilength, uint8_t *Output)
104 __IO uint32_t counter = 0;
105 uint32_t busystatus = 0;
106 ErrorStatus status = SUCCESS;
107 uint32_t keyaddr = (uint32_t)Key;
108 uint32_t inputaddr = (uint32_t)Input;
109 uint32_t outputaddr = (uint32_t)Output;
116 if( Mode == MODE_ENCRYPT )
118 DES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
122 DES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
125 DES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_DES_ECB;
130 DES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
132 DES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
147 for(i=0; ((i<Ilength) && (status != ERROR)); i+=8)
162 }
while ((counter != DESBUSY_TIMEOUT) && (busystatus != RESET));
164 if (busystatus != RESET)
200 ErrorStatus
CRYP_DES_CBC(uint8_t Mode, uint8_t Key[8], uint8_t InitVectors[8],
201 uint8_t *Input, uint32_t Ilength, uint8_t *Output)
206 __IO uint32_t counter = 0;
207 uint32_t busystatus = 0;
208 ErrorStatus status = SUCCESS;
209 uint32_t keyaddr = (uint32_t)Key;
210 uint32_t inputaddr = (uint32_t)Input;
211 uint32_t outputaddr = (uint32_t)Output;
212 uint32_t ivaddr = (uint32_t)InitVectors;
219 if(Mode == MODE_ENCRYPT)
221 DES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
225 DES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
233 DES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
235 DES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
239 DES_CRYP_IVInitStructure.
CRYP_IV0Left = __REV(*(uint32_t*)(ivaddr));
241 DES_CRYP_IVInitStructure.
CRYP_IV0Right= __REV(*(uint32_t*)(ivaddr));
256 for(i=0; ((i<Ilength) && (status != ERROR)); i+=8)
270 }
while ((counter != DESBUSY_TIMEOUT) && (busystatus != RESET));
272 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_DES_CBC(uint8_t Mode, uint8_t Key[8], uint8_t InitVectors[8], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using DES in CBC Mode.
#define CRYP_AlgoMode_DES_CBC
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...
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.
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_DES_ECB(uint8_t Mode, uint8_t Key[8], uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using DES in ECB Mode.
CRYP Init structure definition.
FunctionalState CRYP_GetCmdStatus(void)
Returns whether CRYP peripheral is enabled or disabled.