From patchwork Thu Oct 24 13:23:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 177472 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2155570ocf; Thu, 24 Oct 2019 06:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNMhYmv9GSdi+5AnBe0mE3DeQ1MEyt2PhCrqXHTI+5/rrLIs4UaEr+IMS3S4j+Bp6NLM6p X-Received: by 2002:a50:f058:: with SMTP id u24mr9118058edl.288.1571923440364; Thu, 24 Oct 2019 06:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571923440; cv=none; d=google.com; s=arc-20160816; b=HtB+FlNKmIOf0gTIRQjBqiQrCPaeiXb8D47BEyJdhJgWcQMB7vczH2Al4RIk0P9G+9 9sMgx6/sSW4i6LVMAjS88hpLirZPBWlC7daurXHLyyLHYAlwmsxcJf3p0w582dAWNrXD Y0h4MPjpCyN4N4zbEl7/GFpFDfeaf0Gr4od3M/PD6unPsfnR7dJ1196Ld0MNETBZr1g6 2zEPMHSNOmwVDheZhNiZ6vo32UnzKAl5XQMhiLSJSwYlks+RbJEtO+HRgNqCoOs8Lgok F1i3hKsSe7632yejdRXt44ZBJZdCZDAU9bqGhQKlm/CRO+oHwSVlkBOTuLKkFgPjF1FG UOYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TNWJxh1AFEyP6kvtb+pRqQQilO6T6qX/8rJmhhrHLY0=; b=X+0SDKfHC32jU6TOArTBzuBsTIdVXC7oGTu4y3zZd1LnJpvtIcIN5ezzvOshv/wQPR Nax4Q2Q4ep/NOxOt9lOfiYuom+C65HrA695lQBm/hK41DqIlzsLMav8SiQm3s+0xhCzQ CgcCt+hE/ISKXuOXkUdmZ2TzEtisqTzWU3iTm54cWewxpHi/2IXc1eFjQ+VC/ruq/g/X AK1Du532OA7TWgjd7tiJ4fQFR8YNGn+JISk5/63cXczn+vvwtrm1vSJAashKJtJvDOBg 6K0OTOfsLDb25Tcz3u5ZqQ+cAP5Sa6TJmbY5Hx6sAQpd/GgschSsRk7erlDEqiy/Qs4H uPNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2eThVk8; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si8474084eji.439.2019.10.24.06.24.00; Thu, 24 Oct 2019 06:24:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2eThVk8; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502549AbfJXNX7 (ORCPT + 3 others); Thu, 24 Oct 2019 09:23:59 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36612 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502548AbfJXNX6 (ORCPT ); Thu, 24 Oct 2019 09:23:58 -0400 Received: by mail-wr1-f68.google.com with SMTP id w18so25541016wrt.3 for ; Thu, 24 Oct 2019 06:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TNWJxh1AFEyP6kvtb+pRqQQilO6T6qX/8rJmhhrHLY0=; b=S2eThVk83dKO5Bwg3yDm/gzVGNto7qsth4WMLLOmiYJINz7Qibs5lDhZH4pMHelfff UI55mx/5I/os0vKVwqaNYzvodYmhm3q7elBYzBwxmPBD/GiwrKVqX7DFhWZBhSZqTfDb KjuRWogf+5wecIavxAAFgv75+yn7OshRyOO5VWsaZJg6YRdu/S6wV2oaeWIGvn7xkyT2 GYlxYl4QmaiC54ujOPw1nrH935qPBMI4BffDjb+GHywDtacfw4evwSNKQ7ue/25jsr1U TWuU7+hKvJpl0M+XfxDx5PBJ128PVg0jtARNCF0ugFpEeUzQLDYVTl90UMFXe0QRcLoa i6Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TNWJxh1AFEyP6kvtb+pRqQQilO6T6qX/8rJmhhrHLY0=; b=iOIzO0Yy8nS4SqKMHoCUpFTSvsH0+LcueTJ+9Oip7bmrcJPMcAYEM3tronKhJD9Q8y /23PdLs71prA5U04ij7CBiyHObVr+TsE1BguBnos19Sdvji31NkAFUIB4YhV6mS3klUp l1+4sQXmH9DUNKXAd7kmG8xytSz/Kb6ltajRvhQuvVsN8JUiFOBUH9CxqDH7CpIIsqg2 M9rgRi+TroltzUXDvwCka9prsenAEfJpFJRKNoFXjvtuDuznQUnPSDZSeZdAbvACtrgg nDAaGsVdPLkM0LDsw4Xg6drmCiNat3Xv9T8X5IfA8EQdM7zWqLECJ2BiU2VkDstvcfN3 sJzQ== X-Gm-Message-State: APjAAAVaENivq1ZGs+FXpg0mfulqOW8EuPmNJWLQRztPOAvFMuLyQIqG +n6Z8/kYGi6mEuZpL2MVTJsnFnPOA/7ypGQQ X-Received: by 2002:adf:e886:: with SMTP id d6mr4021372wrm.188.1571923435313; Thu, 24 Oct 2019 06:23:55 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id e3sm2346310wme.36.2019.10.24.06.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 06:23:54 -0700 (PDT) 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 v2 01/27] crypto: virtio - implement missing support for output IVs Date: Thu, 24 Oct 2019 15:23:19 +0200 Message-Id: <20191024132345.5236-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024132345.5236-1-ard.biesheuvel@linaro.org> References: <20191024132345.5236-1-ard.biesheuvel@linaro.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(+) -- 2.20.1 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);