void sha256_block_data_order(uint[] output, uint[] state, uint[] input)
{
uint[] X = new uint[16];
int i;
uint a = state[0];
uint b = state[1];
uint c = state[2];
uint d = state[3];
uint e = state[4];
uint f = state[5];
uint g = state[6];
uint h = state[7];
for (i=0;i<16;i++)
{
uint T1 = X[i] = input[i];
T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];
uint T2 = Sigma0(a) + Maj(a, b, c);
h = g; g = f; f = e; e = d + T1;
d = c; c = b; b = a; a = T1 + T2;
}
for (;i<64;i++)
{
uint s0 = X[(i+1)&0x0f];
s0 = sigma0(s0);
uint s1 = X[(i+14)&0x0f];
s1 = sigma1(s1);
X[i & 0xf] += s0 + s1 + X[(i + 9) & 0xf];
uint T1 = X[i & 0xf];
T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];
uint T2 = Sigma0(a) + Maj(a, b, c);
h = g; g = f; f = e; e = d + T1;
d = c; c = b; b = a; a = T1 + T2;
}
output[0] = (state[0] + a);
output[1] = (state[1] + b);
output[2] = (state[2] + c);
output[3] = (state[3] + d);
output[4] = (state[4] + e);
output[5] = (state[5] + f);
output[6] = (state[6] + g);
output[7] = (state[7] + h);
}