Message ID | 1482377823-20184-1-git-send-email-arei.gonglei@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Michael, Ping... Regards, -Gonglei > -----Original Message----- > From: Gonglei (Arei) > Sent: Thursday, December 22, 2016 11:37 AM > To: qemu-devel@nongnu.org > Cc: mst@redhat.com; Gonglei (Arei) > Subject: [PATCH] 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 <arei.gonglei@huawei.com> > --- > hw/virtio/virtio-crypto.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c > index 4f11fee..978bb98 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) { > -- > 1.8.3.1 >
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 4f11fee..978bb98 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) {
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 <arei.gonglei@huawei.com> --- hw/virtio/virtio-crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)