From e01d6941c14b78f5b413b4226d03313128a9e1bf Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sun, 23 Oct 2011 23:55:17 -0400 Subject: [PATCH] Byteswap computed hash in hashtest so it can be correctly checked --- main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 08028966..8e0df82a 100644 --- a/main.c +++ b/main.c @@ -4222,13 +4222,21 @@ bool hashtest(const struct work *work) unsigned char swap[128]; uint32_t *swap32 = (uint32_t *)swap; unsigned char hash1[32]; + unsigned char hash2[32]; + uint32_t *hash2_32 = (uint32_t *)hash2; int i; for (i = 0; i < 80 / 4; i++) swap32[i] = swab32(data32[i]); sha2(swap, 80, hash1, false); - sha2(hash1, 32, (unsigned char *)(work->hash), false); + sha2(hash1, 32, hash2, false); + + for (i = 0; i < 32 / 4; i++) + hash2_32[i] = swab32(hash2_32[i]); + + memcpy((void*)work->hash, hash2, 32); + return fulltest(work->hash, work->target); }