Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1318955imu; Wed, 23 Jan 2019 14:53:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN5NQoYoQxBKwY+5Y9V3UMOZ2iwO7kxMQSWObGJoboVWk+8biBdnVB/qmGZwKGvPMYCSLwZK X-Received: by 2002:a63:b34f:: with SMTP id x15mr3744348pgt.243.1548283982344; Wed, 23 Jan 2019 14:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548283982; cv=none; d=google.com; s=arc-20160816; b=aOv5q53yL8ymmk7yK73Hkwh3i2w92KLoKEX/ep0PWgooPy8y2/m/vms4ty3T3/7pM7 A/CLw0yrfTczbUDDsm+KY1xMHdbMDjUatAv+1uO0z4eifBqg7cPcDzDCIa4eVYJYUrc7 lCsxOvGw6iC5cvVeIe2CTFW6li/Mg+kaDU/FS8ZP7dZjKCyEiKmCYQwexCp6zKNFULkb BvKiK0QLVR+x3vdB5dTQVR+MMoAdoFYqI9RuSp6iRLzhYSflPEaMApTE2JMII30utEBK oSsjRW3BlFX9cG3l3z/l/GPG19eh+CEiWmpo4/TbxxKZT7cDQBf2TL7cy9pzO0jQ4bDD tong== 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=Rc0CrVEWJmQKAD0Jo44zFIOA/j49fPYe9pb3yDtg78Q=; b=eM/REg/hzNcKB6szgtp5t+OCvf0SmyiPREVsSTl8PrjzBSuagQe80M7TBzUy9SxBKP nYTkn7EA0QDdZQray/xhdFIDV9a5TYq4njmC6J9d5u2qJMU6ennf5dvc7jGFaN9nI7xd 1QJEvFSQFuQMTze+77jdhhNISFLfJ4qDGjuIKwvrr2I9wxbD/C7eXqipwKV+RNy5hn/H qj9aM0BU/fBF4In+GZzNFMNlI9Aer4yveJsYU8sRBIfUn2Eso38sYfr5o9xKfMQpM73S 3dY4HE50rmfoQFG7yBoeqb6KZozavObLhuuhDYerCpvJJkKQvwdLntulHmQLOR8QlzO5 J01A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0i6PbAKg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si18799815pgj.316.2019.01.23.14.52.45; Wed, 23 Jan 2019 14:53:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=0i6PbAKg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbfAWWwj (ORCPT + 99 others); Wed, 23 Jan 2019 17:52:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:50108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbfAWWwc (ORCPT ); Wed, 23 Jan 2019 17:52:32 -0500 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (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 A728A218A2; Wed, 23 Jan 2019 22:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548283951; bh=Q9W59TbgJ1Q9YUDkqEDbFDT7Hi9s2AJUXcFF9AsLb3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0i6PbAKgb5zeFpSjHHhP5wllsgP4h3jXQMHa5IinFziCptvRz1KYIVrrK26/dVhKL yNEoXMNUJxhMBoAyp1n3wxt7x3D0nCunJRTTVu3PlrhwiS73RVyDg9al8eHMh8cVaT 3fV8agJ8gtmqWZ//WsHLOPMYUfr6vJOoV4sz2SZ8= From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, "Jason A . Donenfeld" , stable@vger.kernel.org, Ondrej Mosnacek Subject: [RFC/RFT PATCH 02/15] crypto: morus - fix handling chunked inputs Date: Wed, 23 Jan 2019 14:49:13 -0800 Message-Id: <20190123224926.250525-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog In-Reply-To: <20190123224926.250525-1-ebiggers@kernel.org> References: <20190123224926.250525-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers The generic MORUS implementations all fail the improved AEAD tests because they produce the wrong result with some data layouts. Fix them. Fixes: 396be41f16fd ("crypto: morus - Add generic MORUS AEAD implementations") Cc: # v4.18+ Cc: Ondrej Mosnacek Signed-off-by: Eric Biggers --- crypto/morus1280.c | 13 +++++++------ crypto/morus640.c | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crypto/morus1280.c b/crypto/morus1280.c index 3889c188f266..b83576b4eb55 100644 --- a/crypto/morus1280.c +++ b/crypto/morus1280.c @@ -366,18 +366,19 @@ static void crypto_morus1280_process_crypt(struct morus1280_state *state, const struct morus1280_ops *ops) { struct skcipher_walk walk; - u8 *dst; - const u8 *src; ops->skcipher_walk_init(&walk, req, false); while (walk.nbytes) { - src = walk.src.virt.addr; - dst = walk.dst.virt.addr; + unsigned int nbytes = walk.nbytes; - ops->crypt_chunk(state, dst, src, walk.nbytes); + if (nbytes < walk.total) + nbytes = round_down(nbytes, walk.stride); - skcipher_walk_done(&walk, 0); + ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr, + nbytes); + + skcipher_walk_done(&walk, walk.nbytes - nbytes); } } diff --git a/crypto/morus640.c b/crypto/morus640.c index da06ec2f6a80..b6a477444f6d 100644 --- a/crypto/morus640.c +++ b/crypto/morus640.c @@ -365,18 +365,19 @@ static void crypto_morus640_process_crypt(struct morus640_state *state, const struct morus640_ops *ops) { struct skcipher_walk walk; - u8 *dst; - const u8 *src; ops->skcipher_walk_init(&walk, req, false); while (walk.nbytes) { - src = walk.src.virt.addr; - dst = walk.dst.virt.addr; + unsigned int nbytes = walk.nbytes; - ops->crypt_chunk(state, dst, src, walk.nbytes); + if (nbytes < walk.total) + nbytes = round_down(nbytes, walk.stride); - skcipher_walk_done(&walk, 0); + ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr, + nbytes); + + skcipher_walk_done(&walk, walk.nbytes - nbytes); } } -- 2.20.1.321.g9e740568ce-goog