git: 316cf82382e0 - stable/12 - sha512_224: Fix SHA512_224_Final() on little-endian machines.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 10 Feb 2023 00:23:36 UTC
The branch stable/12 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=316cf82382e06b7abf8724e9b7804bf6dc2aa576
commit 316cf82382e06b7abf8724e9b7804bf6dc2aa576
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
AuthorDate: 2023-02-06 16:57:28 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-02-10 00:20:11 +0000
sha512_224: Fix SHA512_224_Final() on little-endian machines.
PR: 266863
MFC after: 1 week
Reviewed by: allanjude, cperciva, des
Differential Revision: https://reviews.freebsd.org/D38372
(cherry picked from commit 6680cfe8e0eec4427716ab50d73ab8231dd9ab28)
---
sys/crypto/sha2/sha512c.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/sys/crypto/sha2/sha512c.c b/sys/crypto/sha2/sha512c.c
index e0dd36120a90..d1c8ec488fe5 100644
--- a/sys/crypto/sha2/sha512c.c
+++ b/sys/crypto/sha2/sha512c.c
@@ -54,23 +54,26 @@ __FBSDID("$FreeBSD$");
#else /* BYTE_ORDER != BIG_ENDIAN */
/*
- * Encode a length len/4 vector of (uint64_t) into a length len vector of
- * (unsigned char) in big-endian form. Assumes len is a multiple of 8.
+ * Encode a length (len + 7) / 8 vector of (uint64_t) into a length len
+ * vector of (unsigned char) in big-endian form. Assumes len is a
+ * multiple of 4.
*/
-static void
+static inline void
be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len)
{
size_t i;
for (i = 0; i < len / 8; i++)
be64enc(dst + i * 8, src[i]);
+ if (len % 8 == 4)
+ be32enc(dst + i * 8, src[i] >> 32);
}
/*
* Decode a big-endian length len vector of (unsigned char) into a length
- * len/4 vector of (uint64_t). Assumes len is a multiple of 8.
+ * len/8 vector of (uint64_t). Assumes len is a multiple of 8.
*/
-static void
+static inline void
be64dec_vect(uint64_t *dst, const unsigned char *src, size_t len)
{
size_t i;