The code check "req->in_bytes != req->out_bytes" is incompatible with the software of other versions. Therefore, the check is deleted and the size check of out_bytes and iv_bytes is added to the driver.
Signed-off-by: Qi Tao taoqi10@huawei.com --- drv/hisi_sec.c | 4 ++-- wd_cipher.c | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 917b60d1..09c135e2 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -752,7 +752,7 @@ static void update_iv(struct wd_cipher_msg *msg) msg->iv_bytes, msg->iv_bytes); break; case WD_CIPHER_OFB: - if (msg->in_bytes < msg->iv_bytes) + if (msg->in_bytes < msg->iv_bytes || msg->out_bytes < msg->iv_bytes) break; /* The iv_bytes has been checked and it is not greater than AES_BLOCK_SIZE. */ for (i = 0; i < msg->iv_bytes; i++) @@ -794,7 +794,7 @@ static void update_iv_sgl(struct wd_cipher_msg *msg) break; case WD_CIPHER_OFB: /* The iv_bytes has been checked and it is not greater than AES_BLOCK_SIZE. */ - if (msg->in_bytes >= msg->iv_bytes) { + if (msg->in_bytes >= msg->iv_bytes && msg->out_bytes >= msg->iv_bytes) { hisi_qm_sgl_copy(in, msg->in, msg->in_bytes - msg->iv_bytes, msg->iv_bytes, COPY_SGL_TO_PBUFF); diff --git a/wd_cipher.c b/wd_cipher.c index be80d224..a8330741 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -648,12 +648,6 @@ static int wd_cipher_check_params(handle_t h_sess, return -WD_EINVAL; }
- if (unlikely(req->in_bytes != req->out_bytes)) { - WD_ERR("cipher set out_bytes is error, size = %u\n", - req->out_bytes); - return -WD_EINVAL; - } - ret = cipher_in_len_check(h_sess, req); if (unlikely(ret)) return ret;