Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp324464lqb; Tue, 4 Jun 2024 12:30:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVu+q9sJFbCkczWDz7j5NWjZ/AaBB8PBpwRqxiAhoutsRen6Uh70mcma8YMtPoWCK3dB0EZv4dugWvMxfkaSDeqM0ugVoKZDjHpHWubkg== X-Google-Smtp-Source: AGHT+IGBItlkfdpgcrBgOdzToRfieo3tqpYDfiCfFI1GuDUkKm1PllUPDN8RlHC1614nr1tFXKIq X-Received: by 2002:a05:6358:2928:b0:19c:27a0:a116 with SMTP id e5c5f4694b2df-19c6c68ae8emr47125055d.14.1717529399642; Tue, 04 Jun 2024 12:29:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717529399; cv=pass; d=google.com; s=arc-20160816; b=qkXEp3oWdUQTtoLc5ZdW+AFuy6GCNE4Ex88DEOeh4KcvQJFkQeeElpIVzR2jGDx8FO C0bpx9Nsckgt01w3x11lbToyteatRA/80bMBXxaP3cxMa2Ne1RE05MLrwDT3HIWMWExu 1537yneGUnxt7wo8n5AuxmIeEuSG2IkJhOi5Wc2KvzJnwb7dW1mDlzpvvyKInOZonwtl rpQFnmc2AOhwwlFQ3m5NRQ3pu0wzrUXlO/gb47rloWRTfsLRpK1Ku5cEsOa7giJcnQqj o+eycfMx8iH5SLt1PpWElQAUpNgDKufhVkEBcpsFSTjBK1A6IVKWn+Sarhbp/W67iobp FNzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EYcvzfXD+SOAoL7NM1vlMK+poqgcnFSiRFRZ8HBCLM4=; fh=i5TlPtG2m1/sCkJMiSEjUuG0/XIUSync377Gg4WcAPA=; b=R4viaOnc0bN9RWuUAj14W+FTWtXIHLu7MET2XNfLXLwhDhI5PrJpionfs532LFiG5Y rvDMvXg6hVjR+TWIyNfpvmDH8CrlacJ2NHHE5D/C8py1WatGv2bl3VOfyN4rQpZ4TjqJ TdBlspGHIiuwNFkZzx8UyKRRqn/nsZF0wIDNV1oZS4w/mI06MvSwAywKnF48dlbDNCHV c7jx3mh1R9Pru8T+DOOiUj1ppzCuNClWrJ6LtkSOcHzUjs+16v23ekBcsVU/3AvLUR3C MbxJPG/Rs93bIcGEXhg0rw/ve8WTmjExgzW/c5IMCXrEnbMaCLnxWDntKSXM6m1q6wDU QIQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A4f+pTcO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4712-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35c17d1d6si1180906a12.641.2024.06.04.12.29.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4712-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A4f+pTcO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4712-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9E825B2365C for ; Tue, 4 Jun 2024 19:25:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EBDC14884D; Tue, 4 Jun 2024 19:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A4f+pTcO" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05100801; Tue, 4 Jun 2024 19:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717529145; cv=none; b=rzv5ndgc1rJrH7mkY/+mnjk1X78FLFrBwbrKzEMjsukjMVEG5VtbFo6caKgqtf854HEDZZ8RGL18Cj+l/LEV/tHEtdHmDvvM2pHs2MxH+yJ8cJECHvB/XA7LrEmWp/C7UH3PuxkHY6JRLwpk/TtUZIW8SP0dukLpmWiPw6szO8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717529145; c=relaxed/simple; bh=CfdX3QgpBeGkiViJGYp7o44OH979z8N7+Zs7t2WW+f4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dJaHosSxXLOImWLbK4Sc9T7+b5NBIWV3fRjqPNyCYxjbb3w48gLRHfUP3f41nX28c3swQmkwa+ee2Uuw5lZ4+JBBKg9Jr3Zv2JUsy5lkUhZmXQ9LGtJU1mqM5zP7WSEnRZtZ8QXzAbIbHAI4huMXVU1lgMcwtm1/AQdRjexx92w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A4f+pTcO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36641C2BBFC; Tue, 4 Jun 2024 19:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717529144; bh=CfdX3QgpBeGkiViJGYp7o44OH979z8N7+Zs7t2WW+f4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A4f+pTcO0TotuaZzcRhFq6IxIsRM4Qm8d2eF2w0RCHVEGfvBUyiY26sLeUEe2H+yZ gt+rOwUYrpWu7NmOPqtcgwQjhrRVFuM+pmeaMmkqPFln5SwJ5z/HtlucTFd/eiwTWk VPaDNYps3o6VgZXIrGE8d4/XgTxJnCm5q/AzQgP7D+LjJScqnfEdjk+cv2s+MNDLgk rA0n2GJkJeX6VJ9e1wBFVE5tF7LFKDdfyBMgYTZov8WakYIeJuoQ2h1fwXSPV0jlAC 041k0uANAgAnRtlSfIENmxulVOMGM7ee+vei2prIem8AOmci/IVlsIqa+Bo2EKGS6M iVExfLAsdSi1Q== Date: Tue, 4 Jun 2024 12:25:42 -0700 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, fsverity@lists.linux.dev, dm-devel@lists.linux.dev, Herbert Xu , x86@kernel.org, linux-arm-kernel@lists.infradead.org, Sami Tolvanen , Bart Van Assche Subject: Re: [PATCH v4 1/8] crypto: shash - add support for finup_mb Message-ID: <20240604192542.GD1566@sol.localdomain> References: <20240603183731.108986-1-ebiggers@kernel.org> <20240603183731.108986-2-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jun 04, 2024 at 08:55:48PM +0200, Ard Biesheuvel wrote: > > > > This patch takes a new approach of just adding an API > > crypto_shash_finup_mb() that synchronously computes the hash of multiple > > equal-length messages, starting from a common state that represents the > > (possibly empty) common prefix shared by the messages. > > > > This is an independent optimization, right? This could be useful even > more sequential hashing, and is not a fundamental aspect of parallel > hashing? If you're referring to the part about using a common starting state, that's not an independent optimization. Only multibuffer hashing processes multiple messages in one call and therefore has an opportunity to share a starting shash_desc for finup. This isn't just an optimization but it also makes the multibuffer hashing API and its implementation much simpler. With single-buffer there has to be one shash_desc per message as usual. If you're asking if crypto_shash_finup_mb() can be used even without multibuffer hashing support, the answer is yes. This patchset makes crypto_shash_finup_mb() fall back to crypto_shash_finup() as needed, and this is used by fsverity and dm-verity to have one code path that uses crypto_shash_finup_mb() instead of separate code paths that use crypto_shash_finup_mb() and crypto_shash_finup(). This just makes things a bit simpler and isn't an optimization; note that the fallback has to copy the shash_desc for each message beyond the first. - Eric