mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix SHA224 to produce 28 bytes of hash (instead of 32).
@ 2012-06-07 13:05 Krzysztof Halasa
  0 siblings, 0 replies; only message in thread
From: Krzysztof Halasa @ 2012-06-07 13:05 UTC (permalink / raw)
  To: barebox

This fixes a panic in sha224sum.

Signed-off-by: Krzysztof Hałasa <khc@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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-07 13:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07 13:05 [PATCH] Fix SHA224 to produce 28 bytes of hash (instead of 32) Krzysztof Halasa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox