Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4513759ybp; Mon, 14 Oct 2019 06:00:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtP2vTzoabl6aizUoADt7uMtOH2E9QqSKXkgZZWJE7XTBa4YXrLb65hrhghCMysn22XZPq X-Received: by 2002:aa7:db0a:: with SMTP id t10mr7380019eds.113.1571058008101; Mon, 14 Oct 2019 06:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571058008; cv=none; d=google.com; s=arc-20160816; b=zDamGP5d2tFeoOZJZezJUZSM77AFH017/LNAhhf1HtE3BWIjrc4czAWNwxKBYTlj35 bkldSfN3LjV8/HsSIds0/yHpL1a/IUFo7NMvHSMdiLB+vPllRpWBXE+h4gDFWNC7CVMd JmQbxBdMP9hKPofKG0mj7MQvW+fvnqIvuQIm9DeWpgUPq9Sxjn2PbCUNHgudydry+xV2 pIJPO4N1mX7vXkeUW5gwtxjNVoDAsShFU0NI1Oq5xiDIDCZmvKCG/mEpAEHKnu1Tr0vj mpU2A2veKOzhOZ9Nv6QeIxEC4IyepFMstmKtH4+68HRNTtIsubtZNoFatpPAhvwCgk8M OyGQ== 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 d25si10414313edq.65.2019.10.14.05.59.43; Mon, 14 Oct 2019 06:00:08 -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 + 99 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 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