mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	Borislav Petkov <bp@alien8.de>
Subject: [PATCH] x86/microcode/AMD: Use sha256() instead of init/update/final
Date: Mon, 28 Apr 2025 11:30:06 -0700	[thread overview]
Message-ID: <20250428183006.782501-1-ebiggers@kernel.org> (raw)

From: Eric Biggers <ebiggers@google.com>

Just call sha256() instead of doing the init/update/final sequence.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---

This patch is targeting the x86 tree.

 arch/x86/kernel/cpu/microcode/amd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 1798a6c027f89..f1fae6e282215 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -215,11 +215,10 @@ static bool need_sha_check(u32 cur_rev)
 
 static bool verify_sha256_digest(u32 patch_id, u32 cur_rev, const u8 *data, unsigned int len)
 {
 	struct patch_digest *pd = NULL;
 	u8 digest[SHA256_DIGEST_SIZE];
-	struct sha256_state s;
 	int i;
 
 	if (x86_family(bsp_cpuid_1_eax) < 0x17)
 		return true;
 
@@ -233,13 +232,11 @@ static bool verify_sha256_digest(u32 patch_id, u32 cur_rev, const u8 *data, unsi
 	if (!pd) {
 		pr_err("No sha256 digest for patch ID: 0x%x found\n", patch_id);
 		return false;
 	}
 
-	sha256_init(&s);
-	sha256_update(&s, data, len);
-	sha256_final(&s, digest);
+	sha256(data, len, digest);
 
 	if (memcmp(digest, pd->sha256, sizeof(digest))) {
 		pr_err("Patch 0x%x SHA256 digest mismatch!\n", patch_id);
 
 		for (i = 0; i < SHA256_DIGEST_SIZE; i++)

base-commit: 33035b665157558254b3c21c3f049fd728e72368
-- 
2.49.0


             reply	other threads:[~2025-04-28 18:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 18:30 Eric Biggers [this message]
2025-04-28 19:21 ` [tip: x86/microcode] " tip-bot2 for Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250428183006.782501-1-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=bp@alien8.de \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®