@@ -475,7 +475,7 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
475475
476476 /* We'll use SW for fallback:
477477 * unsupported key lengths. (e.g. ESP32-S3)
478- * chipsets not ikmplemented .
478+ * chipsets not implemented .
479479 * hardware busy. */
480480 #define NEED_AES_TABLES
481481 #define NEED_AES_HW_FALLBACK
@@ -3586,12 +3586,18 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
35863586 return 0 ;
35873587 }
35883588#elif defined(FREESCALE_LTC )
3589- int wc_AesSetKey (Aes * aes , const byte * userKey , word32 keylen , const byte * iv ,
3590- int dir )
3589+ int wc_AesSetKeyLocal (Aes * aes , const byte * userKey , word32 keylen ,
3590+ const byte * iv , int dir , int checkKeyLen )
35913591 {
3592- if (aes == NULL || !(( keylen == 16 ) || ( keylen == 24 ) || ( keylen == 32 )) )
3592+ if (aes == NULL )
35933593 return BAD_FUNC_ARG ;
35943594
3595+ if (checkKeyLen ) {
3596+ if (!((keylen == 16 ) || (keylen == 24 ) || (keylen == 32 )))
3597+ return BAD_FUNC_ARG ;
3598+ }
3599+ (void )dir ;
3600+
35953601 aes -> rounds = keylen /4 + 6 ;
35963602 XMEMCPY (aes -> key , userKey , keylen );
35973603
@@ -3603,15 +3609,21 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
36033609 return wc_AesSetIV (aes , iv );
36043610 }
36053611
3612+ int wc_AesSetKey (Aes * aes , const byte * userKey , word32 keylen ,
3613+ const byte * iv , int dir )
3614+ {
3615+ return wc_AesSetKeyLocal (aes , userKey , keylen , iv , dir , 1 );
3616+ }
3617+
3618+
36063619 int wc_AesSetKeyDirect (Aes * aes , const byte * userKey , word32 keylen ,
36073620 const byte * iv , int dir )
36083621 {
36093622 return wc_AesSetKey (aes , userKey , keylen , iv , dir );
36103623 }
36113624#elif defined(FREESCALE_MMCAU )
3612- #define NEED_SOFTWARE_AES_SETKEY
3613- int wc_AesSetKey (Aes * aes , const byte * userKey , word32 keylen ,
3614- const byte * iv , int dir )
3625+ int wc_AesSetKeyLocal (Aes * aes , const byte * userKey , word32 keylen ,
3626+ const byte * iv , int dir , int checkKeyLen )
36153627 {
36163628 int ret ;
36173629 byte * rk ;
@@ -3621,11 +3633,14 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
36213633
36223634 (void )dir ;
36233635
3624- if (!((keylen == 16 ) || (keylen == 24 ) || (keylen == 32 )))
3625- return BAD_FUNC_ARG ;
36263636 if (aes == NULL )
36273637 return BAD_FUNC_ARG ;
36283638
3639+ if (checkKeyLen ) {
3640+ if (!((keylen == 16 ) || (keylen == 24 ) || (keylen == 32 )))
3641+ return BAD_FUNC_ARG ;
3642+ }
3643+
36293644 rk = (byte * )aes -> key ;
36303645 if (rk == NULL )
36313646 return BAD_FUNC_ARG ;
@@ -3676,6 +3691,12 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
36763691 return ret ;
36773692 }
36783693
3694+ int wc_AesSetKey (Aes * aes , const byte * userKey , word32 keylen ,
3695+ const byte * iv , int dir )
3696+ {
3697+ return wc_AesSetKeyLocal (aes , userKey , keylen , iv , dir , 1 );
3698+ }
3699+
36793700 int wc_AesSetKeyDirect (Aes * aes , const byte * userKey , word32 keylen ,
36803701 const byte * iv , int dir )
36813702 {
0 commit comments