void sha256d_midstate(struct work *work) { unsigned char data[64]; uint32_t *data32 = (uint32_t *)data; sph_sha256_context ctx; flip64(data32, work->data); sph_sha256_init(&ctx); sph_sha256(&ctx, data, 64); memcpy(work->midstate, ctx.val, 32); endian_flip32(work->midstate, work->midstate); }
static void calc_midstate(struct mm_work *mw, struct work *work) { unsigned char data[64]; uint32_t *data32 = (uint32_t *)data; flip64(data32, mw->header); sha256_init(); sha256_update(data, 64); sha256_final(work->data); /* FIXME: LM32 will crash if I direct use * flip64(work->data, work->data); * Should be flip32 ?? */ memcpy(data, work->data, 32); flip64(data32, data); memcpy(work->data, data, 32); memcpy(work->data + 32, mw->header + 64, 12); }
static void calc_midstate(struct mm_work *mw, struct work *work) { unsigned char data[64]; uint32_t *data32 = (uint32_t *)data; flip64(data32, mw->header); sha256_init(); sha256_update(data, 64); sha256_final(work->data); memcpy(data, work->data, 32); flip32(work->data, data); memcpy(work->data + 32, mw->header + 64, 12); }