From patchwork Tue Nov 5 13:27:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 11227709 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4894B15AB for ; Tue, 5 Nov 2019 13:28:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E86D21D7C for ; Tue, 5 Nov 2019 13:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572960522; bh=7mDjWmrykjWinI9flSdIxWfKbwzQRVeme/a6n119Pf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qQWShcOoDWOTMzmyS5AIlVTik4H7TcyyI1eZ+iTOy6OxaCMxW/6uIBESx5ZRpu1ML cpqJbiQmqRasbhAOCD7vFuuTWAJrtoTjkXlv3uucdJdDf6lOUFBUbq8xobPq9U7Ns4 1yMQ4OmQDptIji9KbjUoi+38gK2iPr1LD61SFqZQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389028AbfKEN2l (ORCPT ); Tue, 5 Nov 2019 08:28:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:46488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388963AbfKEN2l (ORCPT ); Tue, 5 Nov 2019 08:28:41 -0500 Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr [92.154.90.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A161621D71; Tue, 5 Nov 2019 13:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572960520; bh=7mDjWmrykjWinI9flSdIxWfKbwzQRVeme/a6n119Pf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slgOjyTwt9OCoJixjRH5cLIeQPmUmjH4govBwVcy1mKhc2rJO3SE5SHp3WjnXAiQ/ I724H/moeFtTnV79Oylq3cMtEnzODhZ7q6p7sanqANcUCrl1g3vwvIt4ZbCbPDhwIB QJjuTMqo6di0Xb8GEXxt5uMgA7WlC7Obp5a5aUEI= From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , "David S. Miller" , Eric Biggers , linux-arm-kernel@lists.infradead.org, "Michael S. Tsirkin" , Jason Wang , Gonglei , virtualization@lists.linux-foundation.org Subject: [PATCH v3 01/29] crypto: virtio - implement missing support for output IVs Date: Tue, 5 Nov 2019 14:27:58 +0100 Message-Id: <20191105132826.1838-2-ardb@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191105132826.1838-1-ardb@kernel.org> References: <20191105132826.1838-1-ardb@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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: dbaf0624ffa5 ("crypto: add virtio-crypto driver") Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Gonglei Cc: virtualization@lists.linux-foundation.org Signed-off-by: Ard Biesheuvel --- drivers/crypto/virtio/virtio_crypto_algs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c index 42d19205166b..65ec10800137 100644 --- a/drivers/crypto/virtio/virtio_crypto_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_algs.c @@ -437,6 +437,11 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, goto free; } 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); sgs[num_out++] = &iv_sg; vc_sym_req->iv = iv; @@ -563,6 +568,10 @@ static void virtio_crypto_ablkcipher_finalize_req( struct ablkcipher_request *req, 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, req, err); kzfree(vc_sym_req->iv);