Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp176491lqh; Thu, 30 May 2024 19:17:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBjHdODunikIQYBRjPejzcjZVSvHDPy+EH1KfQE/Lb7pBhlaj8YI8SzG72lMixgmw8anWrFpKQNqrFBza2v6FUDM4cRWDPuo4qG07EKA== X-Google-Smtp-Source: AGHT+IELLXvJEr9T15f4wd0rvrusqsk26uhbQvQK7W8cF7EorOqisl3tFGe724sOI4vQP2a1Bz2s X-Received: by 2002:ac8:5781:0:b0:43e:3b8e:671f with SMTP id d75a77b69052e-43ff54f74a5mr6141211cf.47.1717121831249; Thu, 30 May 2024 19:17:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717121831; cv=pass; d=google.com; s=arc-20160816; b=fbByn/3O6O1EDSp8OZfw0HuWxwheA2w/5G10/9rM423kRvFSPIs+emVTtPO6gRhg4H odVbQqVO+AVgMZ72ZIPi+f3wwSSSXaD3+qe7m2GbbkAqhL9WjRZtpRyI6EhMW/a8c6Ef S1MDsu09kw8m3ocqwPoQviSqdyQSJ322/L+AxT7axFIHJzg/754kqDY3y+bvkittpgfb Xs6xoes/d9rgphDUHSDBZztBDI22PEJhqb+KfyF7oNYX7VhA70QCnXPS/pUn3pGpCWFq 20auQueP4iRlWmhrZmcYAR/HwcWYZcY2owtIcsZ2bk0tZVJ+ZqQ0zAEUUNzyoMbhds54 Dd/Q== 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=iaZgUwYCdhttLC3R79FxGPqFxgVkuzIUMKsEP8zrUjs=; fh=OSI2wOzteinPastLCRIhniej1iMvwRXqoYaF032peqU=; b=qOc99wJyKBstfj7xpxOUb9tlG3mIiWiOT99ZnCZvoGNoIXHc9wdS92vKPPm0o7I/11 Du1L3tmcRGLkaN3kKF1h8+me6eaZgn0V/4bU68dxAys0URoAUP5FJpXRDNnMtwvdynI/ 9oT+VQrH5a10jFopK651E/jOO7tn+2Fqrb4d4jSFB0iT1SfYFmLpYpYNM1MLkdT2iaZq sh8F+jskZVwxqkbTYgQ4StrB7S28/oodRp4gmDI+LVaem5dYvxKkSjD56cyj5IBRDNvu 7YP+yfnvrtZZFIHyr29beV/VEmfulQUdnjqJCrGgb9CplCDK1kNct813ZjcMjdlc1GPW F6lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hkaByAMr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43ff258243fsi10029901cf.522.2024.05.30.19.17.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 19:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hkaByAMr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196182-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E4FC81C2356F for ; Fri, 31 May 2024 02:17:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B134B77F2D; Fri, 31 May 2024 02:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hkaByAMr" 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 C74E84C6D; Fri, 31 May 2024 02:16:59 +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=1717121819; cv=none; b=htacjHei9MURWTIIl7GEQgGhabsO7UwBiRSP03Ob9UfHiy4guG+5cv0UB81LpWmvchkM8puk0bPWZheogiXb0Xgu+kkrONa3kYG2zabNnQLtXBpRxpSQLBZYk6j2Kwmi7uNX54PwjMPcSoz/HfT3/rgh6YVE9u2Fc+tuld+aWgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717121819; c=relaxed/simple; bh=P5d/0b92iEEWWrKJQ67tqG3rp+vdYxJZiUvaostorGY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nS65dhGE3Ncm1XPRHuXXGaRIeFSt4C+dVJhEsg2txL+S8/pu0kiz8Brmw4B4liC6jxwpnyz49+88sG0hZS9G+yHYBxSfn/fVhWsz9OY5XuBs8C6TAkx34n4Z/AmGJcRSHVW6n0UwUhibXhknCK7Z4q9MgbEYdo2np0Ij7mpBQlQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hkaByAMr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E9C8C2BBFC; Fri, 31 May 2024 02:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717121819; bh=P5d/0b92iEEWWrKJQ67tqG3rp+vdYxJZiUvaostorGY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hkaByAMrS7s3R8mRhw3b+e4esv4ruad8pwZal97P7yPssH0JV1AZh/jIKAQTk6Tu+ JS1Bcf42qlwozPi845OchFKmaFQBRLqLd5IbpLo33CwKwmKGGFe4caWgrY+BF6I3Oo lQvzd7s68N16zgT+eX1feCQkUFxpflo7srOsfgGO5Nuu3GlQXMIjaZH3HK4tB4440c GoqHWACn0iwEfylTG+VXzj9wuwAN+hfKFtYP4YBMVwebVRc6/hx6mLpjLqG0qGlEEW X+Fvudlzs2OvFvkw16SPZ8f9OE+vPr6XP+zhRE/XXACoJ4CmeoxbHv5oyuab8yZeqJ 3rAnt80rtWJDg== Date: Thu, 30 May 2024 19:16:56 -0700 From: Eric Biggers To: Ross Philipson Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, kexec@lists.infradead.org, linux-efi@vger.kernel.org, iommu@lists.linux-foundation.org, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, dave.hansen@linux.intel.com, ardb@kernel.org, mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com, peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca, luto@amacapital.net, nivedita@alum.mit.edu, herbert@gondor.apana.org.au, davem@davemloft.net, corbet@lwn.net, ebiederm@xmission.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, kanth.ghatraju@oracle.com, andrew.cooper3@citrix.com, trenchboot-devel@googlegroups.com Subject: Re: [PATCH v9 06/19] x86: Add early SHA-1 support for Secure Launch early measurements Message-ID: <20240531021656.GA1502@sol.localdomain> References: <20240531010331.134441-1-ross.philipson@oracle.com> <20240531010331.134441-7-ross.philipson@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20240531010331.134441-7-ross.philipson@oracle.com> On Thu, May 30, 2024 at 06:03:18PM -0700, Ross Philipson wrote: > From: "Daniel P. Smith" > > For better or worse, Secure Launch needs SHA-1 and SHA-256. The > choice of hashes used lie with the platform firmware, not with > software, and is often outside of the users control. > > Even if we'd prefer to use SHA-256-only, if firmware elected to start us > with the SHA-1 and SHA-256 backs active, we still need SHA-1 to parse > the TPM event log thus far, and deliberately cap the SHA-1 PCRs in order > to safely use SHA-256 for everything else. > > The SHA-1 code here has its origins in the code from the main kernel: > > commit c4d5b9ffa31f ("crypto: sha1 - implement base layer for SHA-1") > > A modified version of this code was introduced to the lib/crypto/sha1.c > to bring it in line with the SHA-256 code and allow it to be pulled into the > setup kernel in the same manner as SHA-256 is. > > Signed-off-by: Daniel P. Smith > Signed-off-by: Ross Philipson Thanks. This explanation doesn't seem to have made it into the actual code or documentation. Can you please get it into a more permanent location? Also, can you point to where the "deliberately cap the SHA-1 PCRs" thing happens in the code? That paragraph is also phrased as a hypothetical, "Even if we'd prefer to use SHA-256-only". That implies that you do not, in fact, prefer SHA-256 only. Is that the case? Sure, maybe there are situations where you *have* to use SHA-1, but why would you not at least *prefer* SHA-256? > /* > * An implementation of SHA-1's compression function. Don't use in new code! > * You shouldn't be using SHA-1, and even if you *have* to use SHA-1, this isn't > * the correct way to hash something with SHA-1 (use crypto_shash instead). > */ > #define SHA1_DIGEST_WORDS (SHA1_DIGEST_SIZE / 4) > #define SHA1_WORKSPACE_WORDS 16 > void sha1_init(__u32 *buf); > void sha1_transform(__u32 *digest, const char *data, __u32 *W); >+void sha1(const u8 *data, unsigned int len, u8 *out); Also, the comment above needs to be updated. - Eric