@@ -490,8 +490,8 @@ static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
490490 err = wc_AesSetKey (ctx -> aes_encrypt , in_key , key_len , NULL , AES_ENCRYPTION );
491491
492492 if (unlikely (err )) {
493- if (! disable_setkey_warnings )
494- pr_err ("%s: wc_AesSetKey for encryption key failed: %d\n" , name , err );
493+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
494+ pr_err ("%s: wc_AesSetKey for encryption key (len %u) failed: %d\n" , name , key_len , err );
495495 return - EINVAL ;
496496 }
497497
@@ -500,9 +500,9 @@ static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
500500 AES_DECRYPTION );
501501
502502 if (unlikely (err )) {
503- if (! disable_setkey_warnings )
504- pr_err ("%s: wc_AesSetKey for decryption key failed: %d\n" ,
505- name , err );
503+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
504+ pr_err ("%s: wc_AesSetKey for decryption key (len %u) failed: %d\n" ,
505+ name , key_len , err );
506506 return - EINVAL ;
507507 }
508508 }
@@ -515,7 +515,7 @@ static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
515515 err = wc_AesSetKey (ctx -> aes_encrypt_C , in_key , key_len , NULL , AES_ENCRYPTION );
516516
517517 if (unlikely (err )) {
518- if (! disable_setkey_warnings )
518+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
519519 pr_err ("%s: wc_AesSetKey for encryption key failed: %d\n" , name , err );
520520 return - EINVAL ;
521521 }
@@ -532,7 +532,7 @@ static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
532532 AES_DECRYPTION );
533533
534534 if (unlikely (err )) {
535- if (! disable_setkey_warnings )
535+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
536536 pr_err ("%s: wc_AesSetKey for decryption key failed: %d\n" ,
537537 name , err );
538538 return - EINVAL ;
@@ -666,7 +666,7 @@ static int km_AesCbcDecrypt(struct skcipher_request *req)
666666
667667 if (unlikely (err )) {
668668 if (! disable_setkey_warnings )
669- pr_err ("%s: wc_AesSetKey failed: %d\n" ,
669+ pr_err ("%s: wc_AesSetIV failed: %d\n" ,
670670 crypto_tfm_alg_driver_name (crypto_skcipher_tfm (tfm )), err );
671671 err = - EINVAL ;
672672 goto out ;
@@ -929,7 +929,7 @@ static int km_AesGcmSetKey(struct crypto_aead *tfm, const u8 *in_key,
929929 err = wc_AesGcmSetKey (ctx -> aes_encrypt , in_key , key_len );
930930
931931 if (unlikely (err )) {
932- if (! disable_setkey_warnings )
932+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
933933 pr_err ("%s: wc_AesGcmSetKey failed: %d\n" ,
934934 crypto_tfm_alg_driver_name (crypto_aead_tfm (tfm )), err );
935935 return - EINVAL ;
@@ -942,7 +942,7 @@ static int km_AesGcmSetKey(struct crypto_aead *tfm, const u8 *in_key,
942942 err = wc_AesGcmSetKey (ctx -> aes_encrypt_C , in_key , key_len );
943943
944944 if (unlikely (err )) {
945- if (! disable_setkey_warnings )
945+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
946946 pr_err ("%s: wc_AesGcmSetKey failed: %d\n" ,
947947 crypto_tfm_alg_driver_name (crypto_aead_tfm (tfm )), err );
948948 return - EINVAL ;
@@ -977,7 +977,7 @@ static int km_AesGcmSetKey_Rfc4106(struct crypto_aead *tfm, const u8 *in_key,
977977 err = wc_AesGcmSetKey (ctx -> aes_encrypt , in_key , key_len );
978978
979979 if (unlikely (err )) {
980- if (! disable_setkey_warnings )
980+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
981981 pr_err ("%s: wc_AesGcmSetKey failed: %d\n" ,
982982 crypto_tfm_alg_driver_name (crypto_aead_tfm (tfm )), err );
983983 return - EINVAL ;
@@ -990,7 +990,7 @@ static int km_AesGcmSetKey_Rfc4106(struct crypto_aead *tfm, const u8 *in_key,
990990 err = wc_AesGcmSetKey (ctx -> aes_encrypt_C , in_key , key_len );
991991
992992 if (unlikely (err )) {
993- if (! disable_setkey_warnings )
993+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
994994 pr_err ("%s: wc_AesGcmSetKey failed: %d\n" ,
995995 crypto_tfm_alg_driver_name (crypto_aead_tfm (tfm )), err );
996996 return - EINVAL ;
@@ -1612,7 +1612,7 @@ static int km_AesXtsSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
16121612 AES_ENCRYPTION_AND_DECRYPTION );
16131613
16141614 if (unlikely (err )) {
1615- if (! disable_setkey_warnings )
1615+ if (( ! disable_setkey_warnings ) && (( key_len == 16 ) || ( key_len == 24 ) || ( key_len == 32 )) )
16161616 pr_err ("%s: wc_AesXtsSetKeyNoInit failed: %d\n" ,
16171617 crypto_tfm_alg_driver_name (crypto_skcipher_tfm (tfm )), err );
16181618 return - EINVAL ;
0 commit comments