summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-02-06 17:57:28 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-02-06 19:37:24 +0100
commita67b944329b7a2589d698c69becf2be54d3879d7 (patch)
treea1301d5b22634891ab321138fdb1ea89f0eccccc
parentvalidation: Improve IRQ handler dispatch test (diff)
downloadrtems-a67b944329b7a2589d698c69becf2be54d3879d7.tar.bz2
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
-rw-r--r--cpukit/libmd/sha512c.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/cpukit/libmd/sha512c.c b/cpukit/libmd/sha512c.c
index 0b03d09fa9..56217586cd 100644
--- a/cpukit/libmd/sha512c.c
+++ b/cpukit/libmd/sha512c.c
@@ -50,23 +50,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;