From patchwork Mon Oct 14 12:18:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 176215 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp4413496ocf; Mon, 14 Oct 2019 05:19:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjMLMwb8gaK2UCjbCfm9dhTb8MBEIH9irUPFMclQhlI7WnXbJxI5yt/QEUvEuWpieOTV62 X-Received: by 2002:a17:906:250d:: with SMTP id i13mr28895010ejb.275.1571055582372; Mon, 14 Oct 2019 05:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571055582; cv=none; d=google.com; s=arc-20160816; b=ZdpLntLRLWoK5bIJRenOlWCBVPHE2WFKwmCiIS4gScT5lwl4V2eY0qxV+66RjZHWi+ 03x7DOZnNx9OC1AMgXdA1uU7tcSQvTHgXVp9ndJvX4ZGKx1bB14Lf+LrZcqCy7clLVmM ColhY0pVRe8iYrj9dpRi+4s6hgZR8BRk1emN9yY0MpHV/eLh3MvNN8ZCEm/cE5AlHnVF pjNjSxy/V5vtdEb3hbet7PDXI0w5FaZVsT89Ps1EMkSEEpJ0aBp8Nhd9syMQ3pf2/1A8 6AeYN60VWCbpthsGDJVSNbwzDyki+3xVjthhtO46X6/8PaB6jkdqkfZrRNAPS8ZI9AyX NNjQ== 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=Yer2bm71PYYMFfGvN+PnUXIKZKu3MGyqIWBWCwNluEA3EuH91+krHWAeaMY1zI5bKm HO5P5vovvLDpK1yR85kWa14B5T2x26VtIcRyuJVZAZiVJQ203EV1vVhoOH6ERy/J2w0c hlsnYhq6QVSt+rop1qPLTLptoj1BQZheczUvQPlAWmsR8RFDTypVMKWDNmXGBxQukh57 sK2INmrDTjbV4+1IzQtVqCNPfWk15xiB03lS1srUU/pz0EVJ4XBmQSDh7ElGXJxnqpYQ 9FePBHOy+o1u7RCPI/O28QcVjEqIshvTUDRJaAGEI1B9UdFzeFLxpVX5aoflPdDroYsb RKVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RGejKaLh; 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 hk1si10860733ejb.408.2019.10.14.05.19.41; Mon, 14 Oct 2019 05:19:42 -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=RGejKaLh; 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 S1726304AbfJNMTl (ORCPT + 3 others); Mon, 14 Oct 2019 08:19:41 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41588 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729776AbfJNMTk (ORCPT ); Mon, 14 Oct 2019 08:19:40 -0400 Received: by mail-wr1-f65.google.com with SMTP id p4so3594764wrm.8 for ; Mon, 14 Oct 2019 05:19:39 -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=RGejKaLhilxSPep1T8GKNwd/Q7C8PjNrda8JoEtErLf7kvnBTwZv6MAI6dLz7PtSfH Xc0ZbIH4yCgnqQF/QZ8kRKM1M9TlpkV7h9fuLbnZtRfjgp1zFtS7HhezB+ejfsfcd/ih Qc8kssabtPem2XldE14kn5hRxH1jWbl5rCbr//QNr6RXDHGwxoFk4uTvKhI/i4zKT21e n2tN07fsRM4ujN5KvVN44S8MhsHdWSXcqVRQ3qW8zlxl0l1E3Mh9ai+PDNQQQB8jnKob b4w1isX5e8XtW8yn9hwPDMsxD6N5vMOQDu84Ikr17EIgPRBXdz5Uz2hqvpUCq8YB2xBv NDfw== 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=H8muBDtzkpxlCxCR47v5FddHShJdmgF3YNSeJB1PtOFj4wTVIp9wzw/vvSw9Nk/Yu5 vPQfp/ooVHRd9uJV2WV+YAdOm70KctBNu9YefagXLl9vx/OACkrVvZwOCKvfuek5ZtDt n1yhkqmZTT8K1OBp7fEvHAY1jq4UbDtewZrvUQBr1zP3ZK9xFSHL4Kwi7h1sCvE9iMIz LTEzDE3hnyJ9EpCyad71jt3rI0ThAVi/J7eanmRDmpV/a2CF98H2WqlmK2B5Jy/hvEBg +GpkEUACnt/J1P0LUtJ4OKS0XqFXCHF1E33yhEC5gLSa/pstUOsFAqH9nR5j0GRthL3f aB6A== X-Gm-Message-State: APjAAAXwICN+A4NSZ4ygdcJwQ/DpmGPnLuFbfVBz0NOi97hnbHd0M9zw I1FPtXm+zPBZ9dGipgnXcb1C+iBPg0I0QQ== X-Received: by 2002:adf:bd93:: with SMTP id l19mr25110646wrh.1.1571055578363; Mon, 14 Oct 2019 05:19:38 -0700 (PDT) Received: from localhost.localdomain (91-167-84-221.subs.proxad.net. [91.167.84.221]) by smtp.gmail.com with ESMTPSA id i1sm20222470wmb.19.2019.10.14.05.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 05:19:37 -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 01/25] crypto: virtio - implement missing support for output IVs Date: Mon, 14 Oct 2019 14:18:46 +0200 Message-Id: <20191014121910.7264-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014121910.7264-1-ard.biesheuvel@linaro.org> References: <20191014121910.7264-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);