Commit 500e6807 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: virtio - implement missing support for output IVs

In order to allow for CBC to be chained, which is something that the
CTS template relies upon, implementations of CBC need to pass the
IV to be used for subsequent invocations via the IV buffer. This was
not implemented yet for virtio-crypto so implement it now.

Fixes: dbaf0624 ("crypto: add virtio-crypto driver")
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Gonglei <arei.gonglei@huawei.com>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 07d8f185
...@@ -437,6 +437,11 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, ...@@ -437,6 +437,11 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
goto free; goto free;
} }
memcpy(iv, req->info, ivsize); memcpy(iv, req->info, ivsize);
if (!vc_sym_req->encrypt)
scatterwalk_map_and_copy(req->info, req->src,
req->nbytes - AES_BLOCK_SIZE,
AES_BLOCK_SIZE, 0);
sg_init_one(&iv_sg, iv, ivsize); sg_init_one(&iv_sg, iv, ivsize);
sgs[num_out++] = &iv_sg; sgs[num_out++] = &iv_sg;
vc_sym_req->iv = iv; vc_sym_req->iv = iv;
...@@ -563,6 +568,10 @@ static void virtio_crypto_ablkcipher_finalize_req( ...@@ -563,6 +568,10 @@ static void virtio_crypto_ablkcipher_finalize_req(
struct ablkcipher_request *req, struct ablkcipher_request *req,
int err) int err)
{ {
if (vc_sym_req->encrypt)
scatterwalk_map_and_copy(req->info, req->dst,
req->nbytes - AES_BLOCK_SIZE,
AES_BLOCK_SIZE, 0);
crypto_finalize_ablkcipher_request(vc_sym_req->base.dataq->engine, crypto_finalize_ablkcipher_request(vc_sym_req->base.dataq->engine,
req, err); req, err);
kzfree(vc_sym_req->iv); kzfree(vc_sym_req->iv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment