68 #define AESBUSY_TIMEOUT ((uint32_t) 0x00010000)
107 uint8_t* Input, uint32_t Ilength, uint8_t* Output)
111 __IO uint32_t counter = 0;
112 uint32_t busystatus = 0;
113 ErrorStatus status = SUCCESS;
114 uint32_t keyaddr = (uint32_t)Key;
115 uint32_t inputaddr = (uint32_t)Input;
116 uint32_t outputaddr = (uint32_t)Output;
125 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_128b;
126 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
128 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
130 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
132 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
135 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_192b;
136 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
138 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
140 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
142 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
144 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
146 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
149 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_256b;
150 AES_CRYP_KeyInitStructure.
CRYP_Key0Left = __REV(*(uint32_t*)(keyaddr));
152 AES_CRYP_KeyInitStructure.
CRYP_Key0Right= __REV(*(uint32_t*)(keyaddr));
154 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
156 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
158 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
160 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
162 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
164 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
171 if(Mode == MODE_DECRYPT)
177 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
178 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_Key;
193 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
195 if (busystatus != RESET)
202 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
212 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
215 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_ECB;
232 for(i=0; ((i<Ilength) && (status != ERROR)); i+=16)
251 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
253 if (busystatus != RESET)
294 ErrorStatus
CRYP_AES_CBC(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key,
295 uint16_t Keysize, uint8_t *Input, uint32_t Ilength,
301 __IO uint32_t counter = 0;
302 uint32_t busystatus = 0;
303 ErrorStatus status = SUCCESS;
304 uint32_t keyaddr = (uint32_t)Key;
305 uint32_t inputaddr = (uint32_t)Input;
306 uint32_t outputaddr = (uint32_t)Output;
307 uint32_t ivaddr = (uint32_t)InitVectors;
316 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_128b;
317 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
319 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
321 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
323 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
326 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_192b;
327 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
329 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
331 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
333 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
335 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
337 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
340 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_256b;
341 AES_CRYP_KeyInitStructure.
CRYP_Key0Left = __REV(*(uint32_t*)(keyaddr));
343 AES_CRYP_KeyInitStructure.
CRYP_Key0Right= __REV(*(uint32_t*)(keyaddr));
345 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
347 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
349 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
351 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
353 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
355 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
362 AES_CRYP_IVInitStructure.
CRYP_IV0Left = __REV(*(uint32_t*)(ivaddr));
364 AES_CRYP_IVInitStructure.
CRYP_IV0Right= __REV(*(uint32_t*)(ivaddr));
366 AES_CRYP_IVInitStructure.
CRYP_IV1Left = __REV(*(uint32_t*)(ivaddr));
368 AES_CRYP_IVInitStructure.
CRYP_IV1Right= __REV(*(uint32_t*)(ivaddr));
372 if(Mode == MODE_DECRYPT)
378 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
379 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_Key;
395 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
397 if (busystatus != RESET)
404 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
413 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
415 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_CBC;
435 for(i=0; ((i<Ilength) && (status != ERROR)); i+=16)
453 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
455 if (busystatus != RESET)
496 ErrorStatus
CRYP_AES_CTR(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key,
497 uint16_t Keysize, uint8_t *Input, uint32_t Ilength,
503 __IO uint32_t counter = 0;
504 uint32_t busystatus = 0;
505 ErrorStatus status = SUCCESS;
506 uint32_t keyaddr = (uint32_t)Key;
507 uint32_t inputaddr = (uint32_t)Input;
508 uint32_t outputaddr = (uint32_t)Output;
509 uint32_t ivaddr = (uint32_t)InitVectors;
518 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_128b;
519 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
521 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
523 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
525 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
528 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_192b;
529 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
531 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
533 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
535 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
537 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
539 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
542 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_256b;
543 AES_CRYP_KeyInitStructure.
CRYP_Key0Left = __REV(*(uint32_t*)(keyaddr));
545 AES_CRYP_KeyInitStructure.
CRYP_Key0Right= __REV(*(uint32_t*)(keyaddr));
547 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
549 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
551 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
553 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
555 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
557 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
563 AES_CRYP_IVInitStructure.
CRYP_IV0Left = __REV(*(uint32_t*)(ivaddr));
565 AES_CRYP_IVInitStructure.
CRYP_IV0Right= __REV(*(uint32_t*)(ivaddr));
567 AES_CRYP_IVInitStructure.
CRYP_IV1Left = __REV(*(uint32_t*)(ivaddr));
569 AES_CRYP_IVInitStructure.
CRYP_IV1Right= __REV(*(uint32_t*)(ivaddr));
575 if(Mode == MODE_DECRYPT)
578 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
584 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
586 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_CTR;
606 for(i=0; ((i<Ilength) && (status != ERROR)); i+=16)
624 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
626 if (busystatus != RESET)
671 uint8_t *Key, uint16_t Keysize,
672 uint8_t *Input, uint32_t ILength,
673 uint8_t *Header, uint32_t HLength,
674 uint8_t *Output, uint8_t *AuthTAG)
679 __IO uint32_t counter = 0;
680 uint32_t busystatus = 0;
681 ErrorStatus status = SUCCESS;
682 uint32_t keyaddr = (uint32_t)Key;
683 uint32_t inputaddr = (uint32_t)Input;
684 uint32_t outputaddr = (uint32_t)Output;
685 uint32_t ivaddr = (uint32_t)InitVectors;
686 uint32_t headeraddr = (uint32_t)Header;
687 uint32_t tagaddr = (uint32_t)AuthTAG;
688 uint64_t headerlength = HLength * 8;
689 uint64_t inputlength = ILength * 8;
690 uint32_t loopcounter = 0;
698 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_128b;
699 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
701 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
703 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
705 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
708 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_192b;
709 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
711 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
713 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
715 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
717 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
719 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
722 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_256b;
723 AES_CRYP_KeyInitStructure.
CRYP_Key0Left = __REV(*(uint32_t*)(keyaddr));
725 AES_CRYP_KeyInitStructure.
CRYP_Key0Right= __REV(*(uint32_t*)(keyaddr));
727 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
729 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
731 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
733 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
735 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
737 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
744 AES_CRYP_IVInitStructure.
CRYP_IV0Left = __REV(*(uint32_t*)(ivaddr));
746 AES_CRYP_IVInitStructure.
CRYP_IV0Right= __REV(*(uint32_t*)(ivaddr));
748 AES_CRYP_IVInitStructure.
CRYP_IV1Left = __REV(*(uint32_t*)(ivaddr));
750 AES_CRYP_IVInitStructure.
CRYP_IV1Right= __REV(*(uint32_t*)(ivaddr));
753 if(Mode == MODE_ENCRYPT)
765 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
766 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_GCM;
798 for(loopcounter = 0; (loopcounter < HLength); loopcounter+=16)
822 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
824 if (busystatus != RESET)
846 for(loopcounter = 0; ((loopcounter < ILength) && (status != ERROR)); loopcounter+=16)
868 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
870 if (busystatus != RESET)
918 tagaddr = (uint32_t)AuthTAG;
942 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
943 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_GCM;
975 for(loopcounter = 0; (loopcounter < HLength); loopcounter+=16)
999 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
1001 if (busystatus != RESET)
1023 for(loopcounter = 0; ((loopcounter < ILength) && (status != ERROR)); loopcounter+=16)
1045 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
1047 if (busystatus != RESET)
1095 tagaddr = (uint32_t)AuthTAG;
1136 uint8_t* Nonce, uint32_t NonceSize,
1137 uint8_t *Key, uint16_t Keysize,
1138 uint8_t *Input, uint32_t ILength,
1139 uint8_t *Header, uint32_t HLength, uint8_t *HBuffer,
1141 uint8_t *AuthTAG, uint32_t TAGSize)
1146 __IO uint32_t counter = 0;
1147 uint32_t busystatus = 0;
1148 ErrorStatus status = SUCCESS;
1149 uint32_t keyaddr = (uint32_t)Key;
1150 uint32_t inputaddr = (uint32_t)Input;
1151 uint32_t outputaddr = (uint32_t)Output;
1152 uint32_t headeraddr = (uint32_t)Header;
1153 uint32_t tagaddr = (uint32_t)AuthTAG;
1154 uint32_t headersize = HLength;
1155 uint32_t loopcounter = 0;
1156 uint32_t bufferidx = 0;
1157 uint8_t blockb0[16] = {0};
1158 uint8_t ctr[16] = {0};
1159 uint32_t temptag[4] = {0};
1160 uint32_t ctraddr = (uint32_t)ctr;
1161 uint32_t b0addr = (uint32_t)blockb0;
1167 if(headersize < 65280)
1169 HBuffer[bufferidx++] = (uint8_t) ((headersize >> 8) & 0xFF);
1170 HBuffer[bufferidx++] = (uint8_t) ((headersize) & 0xFF);
1176 HBuffer[bufferidx++] = 0xFF;
1177 HBuffer[bufferidx++] = 0xFE;
1178 HBuffer[bufferidx++] = headersize & 0xff000000;
1179 HBuffer[bufferidx++] = headersize & 0x00ff0000;
1180 HBuffer[bufferidx++] = headersize & 0x0000ff00;
1181 HBuffer[bufferidx++] = headersize & 0x000000ff;
1185 for(loopcounter = 0; loopcounter < headersize; loopcounter++)
1187 HBuffer[bufferidx++] = Header[loopcounter];
1190 if ((headersize % 16) != 0)
1193 for(loopcounter = headersize; loopcounter <= ((headersize/16) + 1) * 16; loopcounter++)
1195 HBuffer[loopcounter] = 0;
1198 headersize = ((headersize/16) + 1) * 16;
1201 headeraddr = (uint32_t)HBuffer;
1209 blockb0[0] |= 0u | (((( (uint8_t) TAGSize - 2) / 2) & 0x07 ) << 3 ) | ( ( (uint8_t) (15 - NonceSize) - 1) & 0x07);
1211 for (loopcounter = 0; loopcounter < NonceSize; loopcounter++)
1213 blockb0[loopcounter+1] = Nonce[loopcounter];
1215 for ( ; loopcounter < 13; loopcounter++)
1217 blockb0[loopcounter+1] = 0;
1220 blockb0[14] = ((ILength >> 8) & 0xFF);
1221 blockb0[15] = (ILength & 0xFF);
1230 ctr[0] = blockb0[0] & 0x07;
1232 for(loopcounter = 1; loopcounter < NonceSize + 1; loopcounter++)
1234 ctr[loopcounter] = blockb0[loopcounter];
1245 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_128b;
1246 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
1248 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
1250 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
1252 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
1255 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_192b;
1256 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
1258 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
1260 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
1262 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
1264 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
1266 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
1269 AES_CRYP_InitStructure.
CRYP_KeySize = CRYP_KeySize_256b;
1270 AES_CRYP_KeyInitStructure.
CRYP_Key0Left = __REV(*(uint32_t*)(keyaddr));
1272 AES_CRYP_KeyInitStructure.
CRYP_Key0Right= __REV(*(uint32_t*)(keyaddr));
1274 AES_CRYP_KeyInitStructure.
CRYP_Key1Left = __REV(*(uint32_t*)(keyaddr));
1276 AES_CRYP_KeyInitStructure.
CRYP_Key1Right= __REV(*(uint32_t*)(keyaddr));
1278 AES_CRYP_KeyInitStructure.
CRYP_Key2Left = __REV(*(uint32_t*)(keyaddr));
1280 AES_CRYP_KeyInitStructure.
CRYP_Key2Right= __REV(*(uint32_t*)(keyaddr));
1282 AES_CRYP_KeyInitStructure.
CRYP_Key3Left = __REV(*(uint32_t*)(keyaddr));
1284 AES_CRYP_KeyInitStructure.
CRYP_Key3Right= __REV(*(uint32_t*)(keyaddr));
1291 AES_CRYP_IVInitStructure.
CRYP_IV0Left = (__REV(*(uint32_t*)(ctraddr)));
1293 AES_CRYP_IVInitStructure.
CRYP_IV0Right= (__REV(*(uint32_t*)(ctraddr)));
1295 AES_CRYP_IVInitStructure.
CRYP_IV1Left = (__REV(*(uint32_t*)(ctraddr)));
1297 AES_CRYP_IVInitStructure.
CRYP_IV1Right= (__REV(*(uint32_t*)(ctraddr)));
1300 if(Mode == MODE_ENCRYPT)
1312 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;
1313 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_CCM;
1321 b0addr = (uint32_t)blockb0;
1354 for(loopcounter = 0; (loopcounter < headersize); loopcounter+=16)
1378 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
1380 if (busystatus != RESET)
1402 for(loopcounter = 0; ((loopcounter < ILength) && (status != ERROR)); loopcounter+=16)
1425 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
1427 if (busystatus != RESET)
1465 ctraddr = (uint32_t)ctr;
1500 AES_CRYP_InitStructure.
CRYP_AlgoDir = CRYP_AlgoDir_Decrypt;
1501 AES_CRYP_InitStructure.
CRYP_AlgoMode = CRYP_AlgoMode_AES_CCM;
1509 b0addr = (uint32_t)blockb0;
1543 for(loopcounter = 0; (loopcounter < headersize); loopcounter+=16)
1567 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
1569 if (busystatus != RESET)
1591 for(loopcounter = 0; ((loopcounter < ILength) && (status != ERROR)); loopcounter+=16)
1614 }
while ((counter != AESBUSY_TIMEOUT) && (busystatus != RESET));
1616 if (busystatus != RESET)
1654 ctraddr = (uint32_t)ctr;
1678 for(loopcounter = 0; (loopcounter < TAGSize); loopcounter++)
1681 *((uint8_t*)tagaddr+loopcounter) = *((uint8_t*)temptag+loopcounter);
ErrorStatus CRYP_AES_CBC(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using AES in CBC Mode.
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.
void CRYP_PhaseConfig(uint32_t CRYP_Phase)
Configures the AES-CCM and AES-GCM phases.
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).
ErrorStatus CRYP_AES_GCM(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t ILength, uint8_t *Header, uint32_t HLength, uint8_t *Output, uint8_t *AuthTAG)
Encrypt and decrypt using AES in GCM Mode. The GCM and CCM modes are available only on STM32F437x Dev...
ErrorStatus CRYP_AES_CTR(uint8_t Mode, uint8_t InitVectors[16], uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using AES in CTR Mode.
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_AES_CCM(uint8_t Mode, uint8_t *Nonce, uint32_t NonceSize, uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t ILength, uint8_t *Header, uint32_t HLength, uint8_t *HBuffer, uint8_t *Output, uint8_t *AuthTAG, uint32_t TAGSize)
Encrypt and decrypt using AES in CCM Mode. The GCM and CCM modes are available only on STM32F437x Dev...
ErrorStatus CRYP_AES_ECB(uint8_t Mode, uint8_t *Key, uint16_t Keysize, uint8_t *Input, uint32_t Ilength, uint8_t *Output)
Encrypt and decrypt using AES in ECB Mode.
CRYP Init structure definition.
FunctionalState CRYP_GetCmdStatus(void)
Returns whether CRYP peripheral is enabled or disabled.