Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3477229ybg; Fri, 25 Oct 2019 04:51:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdDZg8B0Xq5DXZgNLNct0tw7APPHaI6QKzILJ3dfsuVOfa71vi90kqjRAx8V2n8Uf63BPR X-Received: by 2002:a05:6402:304c:: with SMTP id bu12mr3363441edb.230.1572004263632; Fri, 25 Oct 2019 04:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572004263; cv=none; d=google.com; s=arc-20160816; b=TY5NP5DAlWJzQ2EJ+hTTyPnU5mDBhPHB92l/fyXpXv/zkrcAeZdo96ytIjtW28bGQR AhcWsFLMebKEs8nxqJryHRjZSIrK7M7xtfprJzLrXAFcyr0uFbV1Vsfa+WiQKydtddr5 lSPK7auyQasWeYLsCXPDQh+f0+7y4Q5Ux9DWp53JPFGMYjttfQacElIQpkyNVlP9bpD/ +L0r/VsshK9Gpwgpx7makOymrcKuuL0fbAiyoSCcwDzaVkC/ondl3ZnHEzAkNgQhS9fW 36kbDxAojxz82ha9Z6D/InU2vn5R4adavda1D82BjQAKNCQKzJh7abyq36OCGPUYSwps 6s+g== 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 rv7si479522ejb.366.2019.10.25.04.50.39; Fri, 25 Oct 2019 04:51:03 -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 + 99 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 Content-Transfer-Encoding: 8bit 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); -- 2.20.1