178 #define FLAG_MASK ((uint8_t)0x20)
179 #define MAX_TIMEOUT ((uint16_t)0xFFFF)
238 assert_param(IS_CRYP_ALGOMODE(CRYP_InitStruct->
CRYP_AlgoMode));
239 assert_param(IS_CRYP_DATATYPE(CRYP_InitStruct->
CRYP_DataType));
240 assert_param(IS_CRYP_ALGODIR(CRYP_InitStruct->
CRYP_AlgoDir));
243 CRYP->CR &= ~CRYP_CR_ALGOMODE;
247 CRYP->CR &= ~CRYP_CR_DATATYPE;
256 assert_param(IS_CRYP_KEYSIZE(CRYP_InitStruct->
CRYP_KeySize));
257 CRYP->CR &= ~CRYP_CR_KEYSIZE;
264 CRYP->CR &= ~CRYP_CR_ALGODIR;
367 { uint32_t tempcr = 0;
370 assert_param(IS_CRYP_PHASE(CRYP_Phase));
376 tempcr &= (uint32_t)(~CRYP_CR_GCM_CCMPH);
378 tempcr |= (uint32_t)CRYP_Phase;
394 CRYP->CR |= CRYP_CR_FFLUSH;
406 assert_param(IS_FUNCTIONAL_STATE(NewState));
408 if (NewState != DISABLE)
411 CRYP->CR |= CRYP_CR_CRYPEN;
416 CRYP->CR &= ~CRYP_CR_CRYPEN;
500 __IO uint32_t timeout = 0;
501 uint32_t ckeckmask = 0, bitstatus;
502 ErrorStatus status = ERROR;
505 CRYP->DMACR &= ~(uint32_t)CRYP_DMACR_DIEN;
511 if ((CRYP->CR & (uint32_t)(CRYP_CR_ALGOMODE_TDES_ECB | CRYP_CR_ALGOMODE_TDES_CBC)) != (uint32_t)0 )
513 ckeckmask = CRYP_SR_IFEM | CRYP_SR_BUSY ;
517 ckeckmask = CRYP_SR_IFEM | CRYP_SR_BUSY | CRYP_SR_OFNE;
522 bitstatus = CRYP->SR & ckeckmask;
525 while ((timeout != MAX_TIMEOUT) && (bitstatus != CRYP_SR_IFEM));
527 if ((CRYP->SR & ckeckmask) != CRYP_SR_IFEM)
537 CRYP->DMACR &= ~(uint32_t)CRYP_DMACR_DOEN;
538 CRYP->CR &= ~(uint32_t)CRYP_CR_CRYPEN;
548 CRYP_ContextSave->CRYP_IV0LR = CRYP->IV0LR;
549 CRYP_ContextSave->CRYP_IV0RR = CRYP->IV0RR;
550 CRYP_ContextSave->CRYP_IV1LR = CRYP->IV1LR;
554 CRYP_ContextSave->CRYP_K0LR = CRYP_KeyInitStruct->
CRYP_Key0Left;
556 CRYP_ContextSave->CRYP_K1LR = CRYP_KeyInitStruct->
CRYP_Key1Left;
558 CRYP_ContextSave->CRYP_K2LR = CRYP_KeyInitStruct->
CRYP_Key2Left;
560 CRYP_ContextSave->CRYP_K3LR = CRYP_KeyInitStruct->
CRYP_Key3Left;
564 CRYP_ContextSave->CRYP_CSGCMCCMR[0] = CRYP->CSGCMCCM0R;
565 CRYP_ContextSave->CRYP_CSGCMCCMR[1] = CRYP->CSGCMCCM1R;
566 CRYP_ContextSave->CRYP_CSGCMCCMR[2] = CRYP->CSGCMCCM2R;
567 CRYP_ContextSave->CRYP_CSGCMCCMR[3] = CRYP->CSGCMCCM3R;
568 CRYP_ContextSave->CRYP_CSGCMCCMR[4] = CRYP->CSGCMCCM4R;
569 CRYP_ContextSave->CRYP_CSGCMCCMR[5] = CRYP->CSGCMCCM5R;
570 CRYP_ContextSave->CRYP_CSGCMCCMR[6] = CRYP->CSGCMCCM6R;
571 CRYP_ContextSave->CRYP_CSGCMCCMR[7] = CRYP->CSGCMCCM7R;
573 CRYP_ContextSave->CRYP_CSGCMR[0] = CRYP->CSGCM0R;
574 CRYP_ContextSave->CRYP_CSGCMR[1] = CRYP->CSGCM1R;
575 CRYP_ContextSave->CRYP_CSGCMR[2] = CRYP->CSGCM2R;
576 CRYP_ContextSave->CRYP_CSGCMR[3] = CRYP->CSGCM3R;
577 CRYP_ContextSave->CRYP_CSGCMR[4] = CRYP->CSGCM4R;
578 CRYP_ContextSave->CRYP_CSGCMR[5] = CRYP->CSGCM5R;
579 CRYP_ContextSave->CRYP_CSGCMR[6] = CRYP->CSGCM6R;
580 CRYP_ContextSave->CRYP_CSGCMR[7] = CRYP->CSGCM7R;
609 CRYP->K0LR = CRYP_ContextRestore->CRYP_K0LR;
610 CRYP->K0RR = CRYP_ContextRestore->CRYP_K0RR;
611 CRYP->K1LR = CRYP_ContextRestore->CRYP_K1LR;
612 CRYP->K1RR = CRYP_ContextRestore->CRYP_K1RR;
613 CRYP->K2LR = CRYP_ContextRestore->CRYP_K2LR;
614 CRYP->K2RR = CRYP_ContextRestore->CRYP_K2RR;
615 CRYP->K3LR = CRYP_ContextRestore->CRYP_K3LR;
616 CRYP->K3RR = CRYP_ContextRestore->CRYP_K3RR;
619 CRYP->IV0LR = CRYP_ContextRestore->CRYP_IV0LR;
620 CRYP->IV0RR = CRYP_ContextRestore->CRYP_IV0RR;
621 CRYP->IV1LR = CRYP_ContextRestore->CRYP_IV1LR;
622 CRYP->IV1RR = CRYP_ContextRestore->
CRYP_IV1RR;
625 CRYP->CSGCMCCM0R = CRYP_ContextRestore->CRYP_CSGCMCCMR[0];
626 CRYP->CSGCMCCM1R = CRYP_ContextRestore->CRYP_CSGCMCCMR[1];
627 CRYP->CSGCMCCM2R = CRYP_ContextRestore->CRYP_CSGCMCCMR[2];
628 CRYP->CSGCMCCM3R = CRYP_ContextRestore->CRYP_CSGCMCCMR[3];
629 CRYP->CSGCMCCM4R = CRYP_ContextRestore->CRYP_CSGCMCCMR[4];
630 CRYP->CSGCMCCM5R = CRYP_ContextRestore->CRYP_CSGCMCCMR[5];
631 CRYP->CSGCMCCM6R = CRYP_ContextRestore->CRYP_CSGCMCCMR[6];
632 CRYP->CSGCMCCM7R = CRYP_ContextRestore->CRYP_CSGCMCCMR[7];
634 CRYP->CSGCM0R = CRYP_ContextRestore->CRYP_CSGCMR[0];
635 CRYP->CSGCM1R = CRYP_ContextRestore->CRYP_CSGCMR[1];
636 CRYP->CSGCM2R = CRYP_ContextRestore->CRYP_CSGCMR[2];
637 CRYP->CSGCM3R = CRYP_ContextRestore->CRYP_CSGCMR[3];
638 CRYP->CSGCM4R = CRYP_ContextRestore->CRYP_CSGCMR[4];
639 CRYP->CSGCM5R = CRYP_ContextRestore->CRYP_CSGCMR[5];
640 CRYP->CSGCM6R = CRYP_ContextRestore->CRYP_CSGCMR[6];
641 CRYP->CSGCM7R = CRYP_ContextRestore->CRYP_CSGCMR[7];
644 CRYP->CR |= CRYP_CR_CRYPEN;
684 assert_param(IS_CRYP_DMAREQ(CRYP_DMAReq));
685 assert_param(IS_FUNCTIONAL_STATE(NewState));
687 if (NewState != DISABLE)
690 CRYP->DMACR |= CRYP_DMAReq;
695 CRYP->DMACR &= (uint8_t)~CRYP_DMAReq;
802 assert_param(IS_CRYP_CONFIG_IT(CRYP_IT));
803 assert_param(IS_FUNCTIONAL_STATE(NewState));
805 if (NewState != DISABLE)
808 CRYP->IMSCR |= CRYP_IT;
813 CRYP->IMSCR &= (uint8_t)~CRYP_IT;
829 ITStatus bitstatus = RESET;
831 assert_param(IS_CRYP_GET_IT(CRYP_IT));
834 if ((CRYP->MISR & CRYP_IT) != (uint8_t)RESET)
855 FunctionalState state = DISABLE;
857 if ((CRYP->CR & CRYP_CR_CRYPEN) != 0)
885 FlagStatus bitstatus = RESET;
886 uint32_t tempreg = 0;
889 assert_param(IS_CRYP_GET_FLAG(CRYP_FLAG));
892 if ((CRYP_FLAG & FLAG_MASK) != 0x00)
894 tempreg = CRYP->RISR;
903 if ((tempreg & CRYP_FLAG ) != (uint8_t)RESET)
CRYP context swapping structure definition.
This file contains all the functions prototypes for the RCC firmware library.
CRYP Key(s) structure definition.
void CRYP_IVInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
Initializes the CRYP Initialization Vectors(IV) according to the specified parameters in the CRYP_IVI...
void CRYP_StructInit(CRYP_InitTypeDef *CRYP_InitStruct)
Fills each CRYP_InitStruct member with its default value.
void CRYP_KeyStructInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Fills each CRYP_KeyInitStruct member with its default value.
void CRYP_DMACmd(uint8_t CRYP_DMAReq, FunctionalState NewState)
Enables or disables the CRYP DMA interface.
void CRYP_FIFOFlush(void)
Flushes the IN and OUT FIFOs (that is read and write pointers of the FIFOs are reset) ...
uint32_t CR_CurrentConfig
uint32_t CRYP_DataOut(void)
Returns the last data entered into the output FIFO.
#define CRYP_AlgoMode_DES_CBC
void CRYP_KeyInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Initializes the CRYP Keys according to the specified parameters in the CRYP_KeyInitStruct.
ErrorStatus CRYP_SaveContext(CRYP_Context *CRYP_ContextSave, CRYP_KeyInitTypeDef *CRYP_KeyInitStruct)
Saves the CRYP peripheral Context.
FunctionalState CRYP_GetCmdStatus(void)
Returns whether CRYP peripheral is enabled or disabled.
void CRYP_DeInit(void)
Deinitializes the CRYP peripheral registers to their default reset values.
#define CRYP_AlgoMode_TDES_ECB
void CRYP_PhaseConfig(uint32_t CRYP_Phase)
Configures the AES-CCM and AES-GCM phases.
void CRYP_ITConfig(uint8_t CRYP_IT, FunctionalState NewState)
Enables or disables the specified CRYP interrupts.
void CRYP_Cmd(FunctionalState NewState)
Enables or disables the CRYP peripheral.
void CRYP_RestoreContext(CRYP_Context *CRYP_ContextRestore)
Restores the CRYP peripheral Context.
FlagStatus CRYP_GetFlagStatus(uint8_t CRYP_FLAG)
Checks whether the specified CRYP flag is set or not.
CRYP Initialization Vectors (IV) structure definition.
ITStatus CRYP_GetITStatus(uint8_t CRYP_IT)
Checks whether the specified CRYP interrupt has occurred or not.
void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
Forces or releases AHB2 peripheral reset.
#define CRYP_AlgoMode_TDES_CBC
void CRYP_IVStructInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
Fills each CRYP_IVInitStruct member with its default value.
This file contains all the functions prototypes for the Cryptographic processor(CRYP) firmware librar...
void CRYP_DataIn(uint32_t Data)
Writes data in the Data Input register (DIN).
CRYP Init structure definition.
void CRYP_Init(CRYP_InitTypeDef *CRYP_InitStruct)
Initializes the CRYP peripheral according to the specified parameters in the CRYP_InitStruct.