Skip to content

Commit

Permalink
Import Aaron D. Gifford's fast sha256 implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckolivas committed Aug 19, 2013
1 parent 2a78cd3 commit 78d78b1
Show file tree
Hide file tree
Showing 4 changed files with 991 additions and 332 deletions.
16 changes: 8 additions & 8 deletions cgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,12 +1522,12 @@ static void calc_midstate(struct work *work)
{
unsigned char data[64];
uint32_t *data32 = (uint32_t *)data;
sha2_context ctx;
sha256_ctx ctx;

flip64(data32, work->data);
sha2_starts(&ctx);
sha2_update(&ctx, data, 64);
memcpy(work->midstate, ctx.state, 32);
sha256_init(&ctx);
sha256_update(&ctx, data, 64);
memcpy(work->midstate, ctx.h, 32);
endian_flip32(work->midstate, work->midstate);
}

Expand Down Expand Up @@ -3366,8 +3366,8 @@ static void regen_hash(struct work *work)
unsigned char hash1[32];

flip80(swap32, data32);
sha2(swap, 80, hash1);
sha2(hash1, 32, (unsigned char *)(work->hash));
sha256(swap, 80, hash1);
sha256(hash1, 32, (unsigned char *)(work->hash));
}

static void rebuild_hash(struct work *work)
Expand Down Expand Up @@ -5543,8 +5543,8 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len)
{
unsigned char hash1[32];

sha2(data, len, hash1);
sha2(hash1, 32, hash);
sha256(data, len, hash1);
sha256(hash1, 32, hash);
}

/* Diff 1 is a 256 bit unsigned integer of
Expand Down
4 changes: 2 additions & 2 deletions driver-ztex.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ static uint32_t ztex_checkNonce(struct work *work, uint32_t nonce)
for (i = 0; i < 76 / 4; i++)
swap32[i] = swab32(data32[i]);

sha2(swap, 80, hash1);
sha2(hash1, 32, hash2);
sha256(swap, 80, hash1);
sha256(hash1, 32, hash2);

return htonl(hash2_32[7]);
}
Expand Down
Loading

0 comments on commit 78d78b1

Please sign in to comment.