FreeBSD Bugzilla – Attachment 237936 Details for
Bug 266863
SHA512_224_Final() is broken on little-endian machines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix the bug.
0001-Fix-SHA512_224_Final-on-little-endian-machines.patch (text/plain), 1.24 KB, created by
sebastian.huber
on 2022-11-08 09:55:56 UTC
(
hide
)
Description:
Patch to fix the bug.
Filename:
MIME Type:
Creator:
sebastian.huber
Created:
2022-11-08 09:55:56 UTC
Size:
1.24 KB
patch
obsolete
>From 41aac1ff9ae4bd44aa08d87dfdb4ddcdcc8f583a Mon Sep 17 00:00:00 2001 >From: Sebastian Huber <sebastian.huber@embedded-brains.de> >Date: Tue, 8 Nov 2022 10:50:57 +0100 >Subject: [PATCH] Fix SHA512_224_Final() on little-endian machines > >We have > > #define SHA512_224_DIGEST_LENGTH 28 > >which is not a multiple of 8. > >So, for little-endian machines the following code does not work, since the last >32-bits of the digest are not encoded: > >static 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]); >} > >To fix this, round the length up to the next multiple of eight for >SHA512_224_Final(). >--- > sys/crypto/sha2/sha512c.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > >diff --git a/sys/crypto/sha2/sha512c.c b/sys/crypto/sha2/sha512c.c >index f18a7e6fa994..709971b03b47 100644 >--- a/sys/crypto/sha2/sha512c.c >+++ b/sys/crypto/sha2/sha512c.c >@@ -68,7 +68,10 @@ be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len) > { > size_t i; > >- for (i = 0; i < len / 8; i++) >+ /* >+ * Round the length up to the next multiple of eight for SHA512_224_Final(). >+ */ >+ for (i = 0; i < (len + 7) / 8; i++) > be64enc(dst + i * 8, src[i]); > } > >-- >2.35.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 266863
: 237936