mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH v2 3/3] PBL: add oneshot helper for sha384 and sha512
Date: Wed, 30 Sep 2026 10:28:57 +0200	[thread overview]
Message-ID: <20260930-crypto-pbl-sha384-v2-3-1cedca8ce7c6@pengutronix.de> (raw)
In-Reply-To: <20260930-crypto-pbl-sha384-v2-0-1cedca8ce7c6@pengutronix.de>

Similar to the oneshot helper for sha256, add helpers for sha384 and
sha512.

The helper functions don't use the ARMv8 Crypto Extensions, yet.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Changes in v2:
- Move implementation from header to pbl/sha.c
---
 include/crypto/pbl-sha.h |  6 ++++++
 pbl/sha.c                | 30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/include/crypto/pbl-sha.h b/include/crypto/pbl-sha.h
index dbfb79647462..dc5d5ccdadd6 100644
--- a/include/crypto/pbl-sha.h
+++ b/include/crypto/pbl-sha.h
@@ -28,7 +28,13 @@ int sha512_init(struct digest *desc);
 int sha512_update(struct digest *desc, const void *data, unsigned long len);
 int sha512_final(struct digest *desc, u8 *out);
 
+/* One-shot SHA-512 that picks the best transform available in the PBL. */
+void pbl_sha512(const void *buf, size_t len, u8 out[SHA512_DIGEST_SIZE]);
+
 int sha384_init(struct digest *desc);
 int sha384_final(struct digest *desc, u8 *out);
 
+/* One-shot SHA-384 that picks the best transform available in the PBL. */
+void pbl_sha384(const void *buf, size_t len, u8 out[SHA384_DIGEST_SIZE]);
+
 #endif /* __PBL-SHA_H_ */
diff --git a/pbl/sha.c b/pbl/sha.c
index f08e554ea4c8..81ffab9123dc 100644
--- a/pbl/sha.c
+++ b/pbl/sha.c
@@ -26,3 +26,33 @@ void pbl_sha256(const void *buf, size_t len, u8 out[static SHA256_DIGEST_SIZE])
 
 	pbl_sha256_generic(buf, len, out);
 }
+
+static void pbl_sha512_generic(const void *buf, size_t len, u8 *out)
+{
+	struct sha512_state state = { };
+	struct digest d = { .ctx = &state, .length = SHA512_DIGEST_SIZE };
+
+	sha512_init(&d);
+	sha512_update(&d, buf, len);
+	sha512_final(&d, out);
+}
+
+void pbl_sha512(const void *buf, size_t len, u8 out[static SHA512_DIGEST_SIZE])
+{
+	pbl_sha512_generic(buf, len, out);
+}
+
+static void pbl_sha384_generic(const void *buf, size_t len, u8 *out)
+{
+	struct sha512_state state = { };
+	struct digest d = { .ctx = &state, .length = SHA384_DIGEST_SIZE };
+
+	sha384_init(&d);
+	sha512_update(&d, buf, len);
+	sha384_final(&d, out);
+}
+
+void pbl_sha384(const void *buf, size_t len, u8 out[static SHA384_DIGEST_SIZE])
+{
+	pbl_sha384_generic(buf, len, out);
+}

-- 
2.47.3




  parent reply	other threads:[~2026-09-30  8:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  8:28 [PATCH v2 0/3] PBL: enable hash functions for Vendor Authorized Boot Michael Tretter
2026-09-30  8:28 ` [PATCH v2 1/3] crypto: make sha384 and sha512 available in PBL Michael Tretter
2026-09-30  8:28 ` [PATCH v2 2/3] PBL: rename sha256.c to generic sha.c Michael Tretter
2026-09-30  8:28 ` Michael Tretter [this message]
2026-10-01 20:19 ` [PATCH v2 0/3] PBL: enable hash functions for Vendor Authorized Boot Sascha Hauer

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=20260930-crypto-pbl-sha384-v2-3-1cedca8ce7c6@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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