aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-Wei Wang <chiawei_wang@aspeedtech.com>2021-07-30 09:08:02 +0800
committerTom Rini <trini@konsulko.com>2021-09-01 19:02:00 -0400
commit5369c84d200b1ceae5f9a4f6c2237c482a932057 (patch)
tree257860a4ac45eef1a5f7c2982ab89a9c8a9c46f3
parenta039025e035354696cb26af3b4cabdc9ddefe7d3 (diff)
downloadu-boot-5369c84d200b1ceae5f9a4f6c2237c482a932057.zip
u-boot-5369c84d200b1ceae5f9a4f6c2237c482a932057.tar.gz
u-boot-5369c84d200b1ceae5f9a4f6c2237c482a932057.tar.bz2
lib/md5: Export progressive APIs
Export the MD5 hash init/update/finish progressive APIs for better flexibility. Signed-off-by: Chia-Wei Wang <chiawei_wang@aspeedtech.com>
-rw-r--r--include/u-boot/md5.h4
-rw-r--r--lib/md5.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/include/u-boot/md5.h b/include/u-boot/md5.h
index e09c16a..e5cb923 100644
--- a/include/u-boot/md5.h
+++ b/include/u-boot/md5.h
@@ -17,6 +17,10 @@ struct MD5Context {
};
};
+void MD5Init(struct MD5Context *ctx);
+void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len);
+void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
+
/*
* Calculate and store in 'output' the MD5 digest of 'len' bytes at
* 'input'. 'output' must have enough space to hold 16 bytes.
diff --git a/lib/md5.c b/lib/md5.c
index 2ae4a06..688b725 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -55,7 +55,7 @@ byteReverse(unsigned char *buf, unsigned longs)
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
-static void
+void
MD5Init(struct MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
@@ -71,7 +71,7 @@ MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
-static void
+void
MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
{
register __u32 t;
@@ -120,7 +120,7 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
-static void
+void
MD5Final(unsigned char digest[16], struct MD5Context *ctx)
{
unsigned int count;