crypto: hisilicon - fix the authsize and icv problems of aead in sec
Subsystems (2)
v5 cover crypto: hisilicon - fix the authsize and icv problems of aead in sec
1. Fix for aead invalid authsize.
2. Fix for aead icv error.
---
Changes in v5:
- Delete the 'fallback' that is not used.
- Link to v4: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Add a switching flag (fallback) for soft-calculation in req.
- Link to v3: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- Call crypto_aead_authsize to obtain authsize instead ofactx->authsize.
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Restored authsize to the tfm.
- Link to v1: https://lore.kernel.org/all/[email protected]/
---
Wenkai Lin (2):
crypto: hisilicon/sec2 - fix for aead icv error
crypto: hisilicon/sec2 - fix for aead invalid authsize
drivers/crypto/hisilicon/sec2/sec.h | 3 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 161 ++++++++++----------- drivers/crypto/hisilicon/sec2/sec_crypto.h | 11 -- 3 files changed, 76 insertions(+), 99 deletions(-)
Signature · 1 line
2.33.0
PATCH v5 1/2 crypto: hisilicon/sec2 - fix for aead icv error
From: Wenkai Lin <[email protected]>
When the AEAD algorithm is used for encryption or decryption, the input authentication length varies, the hardware needs to obtain the input length to pass the integrity check verification. Currently, the driver uses a fixed authentication length,which causes decryption failure, so the length configuration is modified. In addition, the step of setting the auth length is unnecessary, so it was deleted from the setkey function.
--- drivers/crypto/hisilicon/sec2/sec.h | 1 - drivers/crypto/hisilicon/sec2/sec_crypto.c | 101 +++++++++------------ drivers/crypto/hisilicon/sec2/sec_crypto.h | 11 --- 3 files changed, 44 insertions(+), 69 deletions(-)
drivers/crypto/hisilicon/sec2/sec.h +0 -1
@@ -90,7 +90,6 @@ struct sec_auth_ctx {dma_addr_t a_key_dma;u8 *a_key;u8 a_key_len; -u8 mac_len;u8 a_alg;bool fallback;struct crypto_shash *hash_tfm;
drivers/crypto/hisilicon/sec2/sec_crypto.c +44 -57
233 lines not on this page · raw message
drivers/crypto/hisilicon/sec2/sec_crypto.h +0 -11
@@ -23,17 +23,6 @@ enum sec_hash_alg { SEC_A_HMAC_SHA512 = 0x15, }; -enum sec_mac_len { -SEC_HMAC_CCM_MAC =16 , -SEC_HMAC_GCM_MAC =16 , -SEC_SM3_MAC =32 , -SEC_HMAC_SM3_MAC =32 , -SEC_HMAC_MD5_MAC =16 , -SEC_HMAC_SHA1_MAC =20 , -SEC_HMAC_SHA256_MAC =32 , -SEC_HMAC_SHA512_MAC =64 , -}; -enum sec_cmode {SEC_CMODE_ECB =0x0 ,SEC_CMODE_CBC =0x1 ,
Signature · 1 line
2.33.0
PATCH v5 2/2 crypto: hisilicon/sec2 - fix for aead invalid authsize
In reply to Chenghai HuangFrom: Wenkai Lin <[email protected]>
When the digest alg is HMAC-SHAx or another, the authsize may be less than 4 bytes and mac_len of the BD is set to zero, the hardware considers it a BD configuration error and reports a ras error, so the sec driver needs to switch to software calculation in this case, this patch add a check for it and remove unnecessary check that has been done by crypto.
--- drivers/crypto/hisilicon/sec2/sec.h | 2 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 64 +++++++++++----------- 2 files changed, 34 insertions(+), 32 deletions(-)
drivers/crypto/hisilicon/sec2/sec.h +1 -1
@@ -37,6 +37,7 @@ struct sec_aead_req {u8 *a_ivin;dma_addr_t a_ivin_dma;struct aead_request *aead_req; +bool fallback; };/* SEC request of Crypto */
@@ -91,7 +92,6 @@ struct sec_auth_ctx {u8 *a_key;u8 a_key_len;u8 a_alg; -bool fallback;struct crypto_shash *hash_tfm;struct crypto_aead *fallback_aead_tfm; };
drivers/crypto/hisilicon/sec2/sec_crypto.c +33 -31
142 lines not on this page · raw message
Signature · 1 line
2.33.0
Herbert Xu
maintainerQuoted 22 lines · Chenghai Huang
1. Fix for aead invalid authsize.
2. Fix for aead icv error.---
Changes in v5:
- Delete the 'fallback' that is not used.
- Link to v4: https://lore.kernel.org/all/[email protected]/Changes in v4:
- Add a switching flag (fallback) for soft-calculation in req.
- Link to v3: https://lore.kernel.org/all/[email protected]/Changes in v3:
- Callcrypto_aead_authsizeto obtain authsize instead ofactx->authsize.
- Link to v2: https://lore.kernel.org/all/[email protected]/Changes in v2:
- Restored authsize to the tfm.
- Link to v1: https://lore.kernel.org/all/[email protected]/
---
Quoted 11 lines
Wenkai Lin (2):
crypto: hisilicon/sec2 - fix for aead icv error
crypto: hisilicon/sec2 - fix for aead invalid authsizedrivers/crypto/hisilicon/sec2/sec.h | 3 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 161 ++++++++++----------- drivers/crypto/hisilicon/sec2/sec_crypto.h | 11 -- 3 files changed, 76 insertions(+), 99 deletions(-)Signature · 1 line
2.33.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt