Adding an iv update to de-crypto method as cbc mode. the dst address should not be changed. So fix it.
Signed-off-by: Kai Ye yekai13@huawei.com --- src/uadk_cipher.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index 8a2c39d..5dd2178 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -764,8 +764,9 @@ static void uadk_cipher_update_priv_ctx(struct cipher_priv_ctx *priv) switch (priv->setup.mode) { case WD_CIPHER_CBC: if (priv->req.op_type == WD_CIPHER_ENCRYPTION) { - priv->req.dst += priv->req.in_bytes; - memcpy(priv->iv, priv->req.dst - iv_bytes, iv_bytes); + memcpy(priv->iv, priv->req.dst + priv->req.in_bytes - iv_bytes, iv_bytes); + } else { + memcpy(priv->iv, priv->req.src + priv->req.in_bytes - iv_bytes, iv_bytes); } break; case WD_CIPHER_OFB: @@ -777,11 +778,9 @@ static void uadk_cipher_update_priv_ctx(struct cipher_priv_ctx *priv) break; case WD_CIPHER_CFB: if (priv->req.op_type == WD_CIPHER_ENCRYPTION) { - priv->req.dst += priv->req.in_bytes; - memcpy(priv->iv, priv->req.dst - iv_bytes, iv_bytes); + memcpy(priv->iv, priv->req.dst + priv->req.in_bytes - iv_bytes, iv_bytes); } else { - priv->req.src += priv->req.in_bytes; - memcpy(priv->iv, priv->req.src - iv_bytes, iv_bytes); + memcpy(priv->iv, priv->req.src + priv->req.in_bytes - iv_bytes, iv_bytes); } break; case WD_CIPHER_CTR: