From: Gonglei Date: Thu, 22 Dec 2016 03:37:03 +0000 (+0800) Subject: virtio-crypto: use the correct length for cipher operation X-Git-Tag: v2.9.0-rc0~162^2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c159a4d1d0434fcf670f8684273bce0eca117a27;p=thirdparty%2Fqemu.git virtio-crypto: use the correct length for cipher operation In some modes of cipher algorithms, the length of destination data maybe larger then source data, such as ciphertext stealing (CTS). For symmetric algorithms, the length of ciphertext is definitly equal to the plaintext for each crypto operation. So we should use the src_len instead of dst_len avoid to pass the incorrect cryptographical results to the frontend driver. Signed-off-by: Gonglei Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index c23e1ad4588..f872c87cb98 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -355,7 +355,7 @@ virtio_crypto_sym_input_data_helper(VirtIODevice *vdev, return; } - len = sym_op_info->dst_len; + len = sym_op_info->src_len; /* Save the cipher result */ s = iov_from_buf(req->in_iov, req->in_num, 0, sym_op_info->dst, len); if (s != len) {