[PATCH] Fix SHA224 to produce 28 bytes of hash (instead of 32).
Krzysztof Halasa
khc at pm.waw.pl
Thu Jun 7 09:05:11 EDT 2012
This fixes a panic in sha224sum.
Signed-off-by: Krzysztof Hałasa <khc at pm.waw.pl>
diff --git a/crypto/sha2.c b/crypto/sha2.c
index 3096efe..afbe0c3 100644
--- a/crypto/sha2.c
+++ b/crypto/sha2.c
@@ -274,7 +274,8 @@ static void sha2_finish(sha2_context * ctx, uint8_t digest[32])
PUT_UINT32_BE(ctx->state[4], digest, 16);
PUT_UINT32_BE(ctx->state[5], digest, 20);
PUT_UINT32_BE(ctx->state[6], digest, 24);
- PUT_UINT32_BE(ctx->state[7], digest, 28);
+ if (!ctx->is224)
+ PUT_UINT32_BE(ctx->state[7], digest, 28);
}
struct sha2 {
--
Krzysztof Halasa
More information about the barebox
mailing list