From: Frediano Ziglio <frediano.ziglio@cloud.com>
To: xen-devel@lists.xenproject.org
Cc: "Ross Lagerwall" <ross.lagerwall@citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH 1/4] xen/lib: Export additional sha256 functions
Date: Tue, 6 May 2025 14:56:50 +0100 [thread overview]
Message-ID: <20250506135655.187014-2-frediano.ziglio@cloud.com> (raw)
In-Reply-To: <20250506135655.187014-1-frediano.ziglio@cloud.com>
From: Ross Lagerwall <ross.lagerwall@citrix.com>
In future, some code needs to generate a digest over several separate buffers
so export the necessary functions to do so.
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
xen/include/xen/sha2.h | 10 ++++++++++
xen/lib/sha2-256.c | 14 ++++----------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/xen/include/xen/sha2.h b/xen/include/xen/sha2.h
index 47d97fbf01..ea8bad67e4 100644
--- a/xen/include/xen/sha2.h
+++ b/xen/include/xen/sha2.h
@@ -9,6 +9,16 @@
#define SHA2_256_DIGEST_SIZE 32
+struct sha2_256_state {
+ uint32_t state[SHA2_256_DIGEST_SIZE / sizeof(uint32_t)];
+ uint8_t buf[64];
+ size_t count; /* Byte count. */
+};
+
+void sha2_256_init(struct sha2_256_state *s);
+void sha2_256_update(struct sha2_256_state *s, const void *msg,
+ size_t len);
+void sha2_256_final(struct sha2_256_state *s, void *_dst);
void sha2_256_digest(uint8_t digest[SHA2_256_DIGEST_SIZE],
const void *msg, size_t len);
diff --git a/xen/lib/sha2-256.c b/xen/lib/sha2-256.c
index 19e8252188..896a257ed9 100644
--- a/xen/lib/sha2-256.c
+++ b/xen/lib/sha2-256.c
@@ -10,12 +10,6 @@
#include <xen/string.h>
#include <xen/unaligned.h>
-struct sha2_256_state {
- uint32_t state[SHA2_256_DIGEST_SIZE / sizeof(uint32_t)];
- uint8_t buf[64];
- size_t count; /* Byte count. */
-};
-
static uint32_t choose(uint32_t x, uint32_t y, uint32_t z)
{
return z ^ (x & (y ^ z));
@@ -131,7 +125,7 @@ static void sha2_256_transform(uint32_t *state, const void *_input)
state[4] += e; state[5] += f; state[6] += g; state[7] += h;
}
-static void sha2_256_init(struct sha2_256_state *s)
+void sha2_256_init(struct sha2_256_state *s)
{
*s = (struct sha2_256_state){
.state = {
@@ -147,8 +141,8 @@ static void sha2_256_init(struct sha2_256_state *s)
};
}
-static void sha2_256_update(struct sha2_256_state *s, const void *msg,
- size_t len)
+void sha2_256_update(struct sha2_256_state *s, const void *msg,
+ size_t len)
{
unsigned int partial = s->count & 63;
@@ -177,7 +171,7 @@ static void sha2_256_update(struct sha2_256_state *s, const void *msg,
memcpy(s->buf + partial, msg, len);
}
-static void sha2_256_final(struct sha2_256_state *s, void *_dst)
+void sha2_256_final(struct sha2_256_state *s, void *_dst)
{
uint32_t *dst = _dst;
unsigned int i, partial = s->count & 63;
--
2.43.0
next prev parent reply other threads:[~2025-05-06 13:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 13:56 [PATCH 0/4] Allows Secure Boot for Kexec Frediano Ziglio
2025-05-06 13:56 ` Frediano Ziglio [this message]
2025-05-06 14:05 ` [PATCH 1/4] xen/lib: Export additional sha256 functions Andrew Cooper
2025-05-06 22:17 ` Andrew Cooper
2025-05-07 5:26 ` Frediano Ziglio
2025-05-07 6:17 ` Andrew Cooper
2025-05-12 10:30 ` Jan Beulich
2025-05-06 13:56 ` [PATCH 4/4] kexec: Support non-page-aligned kexec segments Frediano Ziglio
2025-05-06 14:11 ` [PATCH 0/4] Allows Secure Boot for Kexec Andrii Sultanov
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=20250506135655.187014-2-frediano.ziglio@cloud.com \
--to=frediano.ziglio@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=ross.lagerwall@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.