aboutsummaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-02-06 16:57:28 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2023-02-06 17:02:49 +0000
commit6680cfe8e0eec4427716ab50d73ab8231dd9ab28 (patch)
tree83454678e12efaad2521570e7f20b2339e2cadd2 /sys/crypto
parent9c067b844f85a224f0416e6eb46ba3ef82aec5c4 (diff)
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/sha2/sha512c.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/crypto/sha2/sha512c.c b/sys/crypto/sha2/sha512c.c
index f18a7e6fa994..4533632500f2 100644
--- a/sys/crypto/sha2/sha512c.c
+++ b/sys/crypto/sha2/sha512c.c
@@ -60,23 +60,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;