summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/hisilicon
diff options
context:
space:
mode:
authorKai Ye <yekai13@huawei.com>2022-01-22 16:13:10 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2022-01-31 11:21:45 +1100
commit5e340558c5c7f64504ef1f4d31af152f26705261 (patch)
treed23651856918190fbc1aeb13efce207c3a2c560c /drivers/crypto/hisilicon
parente764d81d58070e66e61fb1b972c81eb9d2ea971e (diff)
downloadlinux-5e340558c5c7f64504ef1f4d31af152f26705261.tar.gz
linux-5e340558c5c7f64504ef1f4d31af152f26705261.tar.bz2
linux-5e340558c5c7f64504ef1f4d31af152f26705261.zip
crypto: hisilicon/sec - fix the max length of AAD for the CCM mode
Fix the maximum length of AAD for the CCM mode due to the hardware limited. Signed-off-by: Kai Ye <yekai13@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/hisilicon')
-rw-r--r--drivers/crypto/hisilicon/sec2/sec_crypto.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index 48abd3871c0e..8305eee9a3d3 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -63,6 +63,7 @@
#define SEC_AUTH_CIPHER 0x1
#define SEC_MAX_MAC_LEN 64
#define SEC_MAX_AAD_LEN 65535
+#define SEC_MAX_CCM_AAD_LEN 65279
#define SEC_TOTAL_MAC_SZ (SEC_MAX_MAC_LEN * QM_Q_DEPTH)
#define SEC_PBUF_SZ 512
@@ -2220,6 +2221,10 @@ static int sec_aead_spec_check(struct sec_ctx *ctx, struct sec_req *sreq)
}
if (c_mode == SEC_CMODE_CCM) {
+ if (unlikely(req->assoclen > SEC_MAX_CCM_AAD_LEN)) {
+ dev_err_ratelimited(dev, "CCM input aad parameter is too long!\n");
+ return -EINVAL;
+ }
ret = aead_iv_demension_check(req);
if (ret) {
dev_err(dev, "aead input iv param error!\n");