Hello Kristian, I cannot reproduce the bug if I use sha1-base.c directly with a C program that feeds small chunks instead of doing it in one go. florz pointed out a dodgy piece of code in the SHA1Update function, I've updated it to the latest version found on GitHub [1] and the bug went away.
You'll also want to update the sha1 egg while you're at it. Peter Bex pointed out it's using the same sha1-base.c file, the fix should apply for it as well. Vasilij [1]: https://raw.githubusercontent.com/clibs/sha1/master/sha1.c
From 035522f8c742a0cfe3413570173da4818d6088dc Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann <[email protected]> Date: Sun, 2 Jun 2019 18:08:16 +0200 Subject: [PATCH] Increment counter correctly for large len values --- sha1-base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sha1-base.c b/sha1-base.c index 545ac04..ca64e8c 100644 --- a/sha1-base.c +++ b/sha1-base.c @@ -134,7 +134,8 @@ SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len) j = context->count[0]; if ((context->count[0] += len << 3) < j) - context->count[1] += (len>>29)+1; + context->count[1]++; + context->count[1] += len >> 29; j = (j >> 3) & 63; if ((j + len) > 63) { i = 64 - j; -- 2.21.0
signature.asc
Description: PGP signature
_______________________________________________ Chicken-hackers mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-hackers
