[System.Security.SecurityCritical] // auto-generated private static unsafe void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint a = state[0]; uint b = state[1]; uint c = state[2]; uint d = state[3]; uint e = state[4]; int i; Utils.DWORDFromBigEndian(expandedBuffer, 16, block); SHAExpand(expandedBuffer); /* Round 1 */ for (i = 0; i < 20; i += 5) { { (e) += (((((a)) << (5)) | (((a)) >> (32 - (5)))) + ((d) ^ ((b) & ((c) ^ (d)))) + (expandedBuffer[i]) + 0x5a827999); (b) = ((((b)) << (30)) | (((b)) >> (32 - (30)))); } { (d) += (((((e)) << (5)) | (((e)) >> (32 - (5)))) + ((c) ^ ((a) & ((b) ^ (c)))) + (expandedBuffer[i + 1]) + 0x5a827999); (a) = ((((a)) << (30)) | (((a)) >> (32 - (30)))); } { (c) += (((((d)) << (5)) | (((d)) >> (32 - (5)))) + ((b) ^ ((e) & ((a) ^ (b)))) + (expandedBuffer[i + 2]) + 0x5a827999); (e) = ((((e)) << (30)) | (((e)) >> (32 - (30)))); };; { (b) += (((((c)) << (5)) | (((c)) >> (32 - (5)))) + ((a) ^ ((d) & ((e) ^ (a)))) + (expandedBuffer[i + 3]) + 0x5a827999); (d) = ((((d)) << (30)) | (((d)) >> (32 - (30)))); };; { (a) += (((((b)) << (5)) | (((b)) >> (32 - (5)))) + ((e) ^ ((c) & ((d) ^ (e)))) + (expandedBuffer[i + 4]) + 0x5a827999); (c) = ((((c)) << (30)) | (((c)) >> (32 - (30)))); };; } /* Round 2 */ for (; i < 40; i += 5) { { (e) += (((((a)) << (5)) | (((a)) >> (32 - (5)))) + ((b) ^ (c) ^ (d)) + (expandedBuffer[i]) + 0x6ed9eba1); (b) = ((((b)) << (30)) | (((b)) >> (32 - (30)))); };; { (d) += (((((e)) << (5)) | (((e)) >> (32 - (5)))) + ((a) ^ (b) ^ (c)) + (expandedBuffer[i + 1]) + 0x6ed9eba1); (a) = ((((a)) << (30)) | (((a)) >> (32 - (30)))); };; { (c) += (((((d)) << (5)) | (((d)) >> (32 - (5)))) + ((e) ^ (a) ^ (b)) + (expandedBuffer[i + 2]) + 0x6ed9eba1); (e) = ((((e)) << (30)) | (((e)) >> (32 - (30)))); };; { (b) += (((((c)) << (5)) | (((c)) >> (32 - (5)))) + ((d) ^ (e) ^ (a)) + (expandedBuffer[i + 3]) + 0x6ed9eba1); (d) = ((((d)) << (30)) | (((d)) >> (32 - (30)))); };; { (a) += (((((b)) << (5)) | (((b)) >> (32 - (5)))) + ((c) ^ (d) ^ (e)) + (expandedBuffer[i + 4]) + 0x6ed9eba1); (c) = ((((c)) << (30)) | (((c)) >> (32 - (30)))); };; } /* Round 3 */ for (; i < 60; i += 5) { { (e) += (((((a)) << (5)) | (((a)) >> (32 - (5)))) + (((b) & (c)) | ((d) & ((b) | (c)))) + (expandedBuffer[i]) + 0x8f1bbcdc); (b) = ((((b)) << (30)) | (((b)) >> (32 - (30)))); };; { (d) += (((((e)) << (5)) | (((e)) >> (32 - (5)))) + (((a) & (b)) | ((c) & ((a) | (b)))) + (expandedBuffer[i + 1]) + 0x8f1bbcdc); (a) = ((((a)) << (30)) | (((a)) >> (32 - (30)))); };; { (c) += (((((d)) << (5)) | (((d)) >> (32 - (5)))) + (((e) & (a)) | ((b) & ((e) | (a)))) + (expandedBuffer[i + 2]) + 0x8f1bbcdc); (e) = ((((e)) << (30)) | (((e)) >> (32 - (30)))); };; { (b) += (((((c)) << (5)) | (((c)) >> (32 - (5)))) + (((d) & (e)) | ((a) & ((d) | (e)))) + (expandedBuffer[i + 3]) + 0x8f1bbcdc); (d) = ((((d)) << (30)) | (((d)) >> (32 - (30)))); };; { (a) += (((((b)) << (5)) | (((b)) >> (32 - (5)))) + (((c) & (d)) | ((e) & ((c) | (d)))) + (expandedBuffer[i + 4]) + 0x8f1bbcdc); (c) = ((((c)) << (30)) | (((c)) >> (32 - (30)))); };; } /* Round 4 */ for (; i < 80; i += 5) { { (e) += (((((a)) << (5)) | (((a)) >> (32 - (5)))) + ((b) ^ (c) ^ (d)) + (expandedBuffer[i]) + 0xca62c1d6); (b) = ((((b)) << (30)) | (((b)) >> (32 - (30)))); };; { (d) += (((((e)) << (5)) | (((e)) >> (32 - (5)))) + ((a) ^ (b) ^ (c)) + (expandedBuffer[i + 1]) + 0xca62c1d6); (a) = ((((a)) << (30)) | (((a)) >> (32 - (30)))); };; { (c) += (((((d)) << (5)) | (((d)) >> (32 - (5)))) + ((e) ^ (a) ^ (b)) + (expandedBuffer[i + 2]) + 0xca62c1d6); (e) = ((((e)) << (30)) | (((e)) >> (32 - (30)))); };; { (b) += (((((c)) << (5)) | (((c)) >> (32 - (5)))) + ((d) ^ (e) ^ (a)) + (expandedBuffer[i + 3]) + 0xca62c1d6); (d) = ((((d)) << (30)) | (((d)) >> (32 - (30)))); };; { (a) += (((((b)) << (5)) | (((b)) >> (32 - (5)))) + ((c) ^ (d) ^ (e)) + (expandedBuffer[i + 4]) + 0xca62c1d6); (c) = ((((c)) << (30)) | (((c)) >> (32 - (30)))); };; } state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; }
private unsafe static void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint num = *state; uint num2 = state[1]; uint num3 = state[2]; uint num4 = state[3]; uint num5 = state[4]; uint num6 = state[5]; uint num7 = state[6]; uint num8 = state[7]; Utils.DWORDFromBigEndian(expandedBuffer, 16, block); SHA256Managed.SHA256Expand(expandedBuffer); for (int i = 0; i < 64; i++) { uint num9 = num8 + SHA256Managed.Sigma_1(num5) + SHA256Managed.Ch(num5, num6, num7) + SHA256Managed._K[i] + expandedBuffer[i]; uint num10 = num4 + num9; uint num11 = num9 + SHA256Managed.Sigma_0(num) + SHA256Managed.Maj(num, num2, num3); i++; num9 = num7 + SHA256Managed.Sigma_1(num10) + SHA256Managed.Ch(num10, num5, num6) + SHA256Managed._K[i] + expandedBuffer[i]; uint num12 = num3 + num9; uint num13 = num9 + SHA256Managed.Sigma_0(num11) + SHA256Managed.Maj(num11, num, num2); i++; num9 = num6 + SHA256Managed.Sigma_1(num12) + SHA256Managed.Ch(num12, num10, num5) + SHA256Managed._K[i] + expandedBuffer[i]; uint num14 = num2 + num9; uint num15 = num9 + SHA256Managed.Sigma_0(num13) + SHA256Managed.Maj(num13, num11, num); i++; num9 = num5 + SHA256Managed.Sigma_1(num14) + SHA256Managed.Ch(num14, num12, num10) + SHA256Managed._K[i] + expandedBuffer[i]; uint num16 = num + num9; uint num17 = num9 + SHA256Managed.Sigma_0(num15) + SHA256Managed.Maj(num15, num13, num11); i++; num9 = num10 + SHA256Managed.Sigma_1(num16) + SHA256Managed.Ch(num16, num14, num12) + SHA256Managed._K[i] + expandedBuffer[i]; num8 = num11 + num9; num4 = num9 + SHA256Managed.Sigma_0(num17) + SHA256Managed.Maj(num17, num15, num13); i++; num9 = num12 + SHA256Managed.Sigma_1(num8) + SHA256Managed.Ch(num8, num16, num14) + SHA256Managed._K[i] + expandedBuffer[i]; num7 = num13 + num9; num3 = num9 + SHA256Managed.Sigma_0(num4) + SHA256Managed.Maj(num4, num17, num15); i++; num9 = num14 + SHA256Managed.Sigma_1(num7) + SHA256Managed.Ch(num7, num8, num16) + SHA256Managed._K[i] + expandedBuffer[i]; num6 = num15 + num9; num2 = num9 + SHA256Managed.Sigma_0(num3) + SHA256Managed.Maj(num3, num4, num17); i++; num9 = num16 + SHA256Managed.Sigma_1(num6) + SHA256Managed.Ch(num6, num7, num8) + SHA256Managed._K[i] + expandedBuffer[i]; num5 = num17 + num9; num = num9 + SHA256Managed.Sigma_0(num2) + SHA256Managed.Maj(num2, num3, num4); } *state += num; state[1] += num2; state[2] += num3; state[3] += num4; state[4] += num5; state[5] += num6; state[6] += num7; state[7] += num8; }
private static unsafe void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint num1 = *state; uint num2 = *(uint *)((IntPtr)state + 4); uint num3 = state[2]; uint num4 = state[3]; uint num5 = state[4]; Utils.DWORDFromBigEndian(expandedBuffer, 16, block); SHA1Managed.SHAExpand(expandedBuffer); int index = 0; while (index < 20) { uint num6 = num5 + (uint)(((int)num1 << 5 | (int)(num1 >> 27)) + ((int)num4 ^ (int)num2 & ((int)num3 ^ (int)num4)) + (int)expandedBuffer[index] + 1518500249); uint num7 = num2 << 30 | num2 >> 2; uint num8 = num4 + (uint)(((int)num6 << 5 | (int)(num6 >> 27)) + ((int)num3 ^ (int)num1 & ((int)num7 ^ (int)num3)) + (int)expandedBuffer[index + 1] + 1518500249); uint num9 = num1 << 30 | num1 >> 2; uint num10 = num3 + (uint)(((int)num8 << 5 | (int)(num8 >> 27)) + ((int)num7 ^ (int)num6 & ((int)num9 ^ (int)num7)) + (int)expandedBuffer[index + 2] + 1518500249); num5 = num6 << 30 | num6 >> 2; num2 = num7 + (uint)(((int)num10 << 5 | (int)(num10 >> 27)) + ((int)num9 ^ (int)num8 & ((int)num5 ^ (int)num9)) + (int)expandedBuffer[index + 3] + 1518500249); num4 = num8 << 30 | num8 >> 2; num1 = num9 + (uint)(((int)num2 << 5 | (int)(num2 >> 27)) + ((int)num5 ^ (int)num10 & ((int)num4 ^ (int)num5)) + (int)expandedBuffer[index + 4] + 1518500249); num3 = num10 << 30 | num10 >> 2; index += 5; } while (index < 40) { uint num6 = num5 + (uint)(((int)num1 << 5 | (int)(num1 >> 27)) + ((int)num2 ^ (int)num3 ^ (int)num4) + (int)expandedBuffer[index] + 1859775393); uint num7 = num2 << 30 | num2 >> 2; uint num8 = num4 + (uint)(((int)num6 << 5 | (int)(num6 >> 27)) + ((int)num1 ^ (int)num7 ^ (int)num3) + (int)expandedBuffer[index + 1] + 1859775393); uint num9 = num1 << 30 | num1 >> 2; uint num10 = num3 + (uint)(((int)num8 << 5 | (int)(num8 >> 27)) + ((int)num6 ^ (int)num9 ^ (int)num7) + (int)expandedBuffer[index + 2] + 1859775393); num5 = num6 << 30 | num6 >> 2; num2 = num7 + (uint)(((int)num10 << 5 | (int)(num10 >> 27)) + ((int)num8 ^ (int)num5 ^ (int)num9) + (int)expandedBuffer[index + 3] + 1859775393); num4 = num8 << 30 | num8 >> 2; num1 = num9 + (uint)(((int)num2 << 5 | (int)(num2 >> 27)) + ((int)num10 ^ (int)num4 ^ (int)num5) + (int)expandedBuffer[index + 4] + 1859775393); num3 = num10 << 30 | num10 >> 2; index += 5; } while (index < 60) { uint num6 = num5 + (uint)(((int)num1 << 5 | (int)(num1 >> 27)) + ((int)num2 & (int)num3 | (int)num4 & ((int)num2 | (int)num3)) + (int)expandedBuffer[index] - 1894007588); uint num7 = num2 << 30 | num2 >> 2; uint num8 = num4 + (uint)(((int)num6 << 5 | (int)(num6 >> 27)) + ((int)num1 & (int)num7 | (int)num3 & ((int)num1 | (int)num7)) + (int)expandedBuffer[index + 1] - 1894007588); uint num9 = num1 << 30 | num1 >> 2; uint num10 = num3 + (uint)(((int)num8 << 5 | (int)(num8 >> 27)) + ((int)num6 & (int)num9 | (int)num7 & ((int)num6 | (int)num9)) + (int)expandedBuffer[index + 2] - 1894007588); num5 = num6 << 30 | num6 >> 2; num2 = num7 + (uint)(((int)num10 << 5 | (int)(num10 >> 27)) + ((int)num8 & (int)num5 | (int)num9 & ((int)num8 | (int)num5)) + (int)expandedBuffer[index + 3] - 1894007588); num4 = num8 << 30 | num8 >> 2; num1 = num9 + (uint)(((int)num2 << 5 | (int)(num2 >> 27)) + ((int)num10 & (int)num4 | (int)num5 & ((int)num10 | (int)num4)) + (int)expandedBuffer[index + 4] - 1894007588); num3 = num10 << 30 | num10 >> 2; index += 5; } while (index < 80) { uint num6 = num5 + (uint)(((int)num1 << 5 | (int)(num1 >> 27)) + ((int)num2 ^ (int)num3 ^ (int)num4) + (int)expandedBuffer[index] - 899497514); uint num7 = num2 << 30 | num2 >> 2; uint num8 = num4 + (uint)(((int)num6 << 5 | (int)(num6 >> 27)) + ((int)num1 ^ (int)num7 ^ (int)num3) + (int)expandedBuffer[index + 1] - 899497514); uint num9 = num1 << 30 | num1 >> 2; uint num10 = num3 + (uint)(((int)num8 << 5 | (int)(num8 >> 27)) + ((int)num6 ^ (int)num9 ^ (int)num7) + (int)expandedBuffer[index + 2] - 899497514); num5 = num6 << 30 | num6 >> 2; num2 = num7 + (uint)(((int)num10 << 5 | (int)(num10 >> 27)) + ((int)num8 ^ (int)num5 ^ (int)num9) + (int)expandedBuffer[index + 3] - 899497514); num4 = num8 << 30 | num8 >> 2; num1 = num9 + (uint)(((int)num2 << 5 | (int)(num2 >> 27)) + ((int)num10 ^ (int)num4 ^ (int)num5) + (int)expandedBuffer[index + 4] - 899497514); num3 = num10 << 30 | num10 >> 2; index += 5; } uint *numPtr = state; int num11 = (int)*numPtr + (int)num1; * numPtr = (uint)num11; IntPtr num12 = (IntPtr)state + 4; int num13 = (int)*(uint *)num12 + (int)num2; *(int *)num12 = num13; IntPtr num14 = (IntPtr)(state + 2); int num15 = (int)*(uint *)num14 + (int)num3; *(int *)num14 = num15; IntPtr num16 = (IntPtr)(state + 3); int num17 = (int)*(uint *)num16 + (int)num4; *(int *)num16 = num17; IntPtr num18 = (IntPtr)(state + 4); int num19 = (int)*(uint *)num18 + (int)num5; *(int *)num18 = num19; }
private static unsafe void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint num1 = *state; uint num2 = *(uint *)((IntPtr)state + 4); uint num3 = state[2]; uint num4 = state[3]; uint num5 = state[4]; uint num6 = state[5]; uint num7 = state[6]; uint num8 = state[7]; Utils.DWORDFromBigEndian(expandedBuffer, 16, block); SHA256Managed.SHA256Expand(expandedBuffer); int index1; for (int index2 = 0; index2 < 64; index2 = index1 + 1) { uint num9 = num8 + SHA256Managed.Sigma_1(num5) + SHA256Managed.Ch(num5, num6, num7) + SHA256Managed._K[index2] + expandedBuffer[index2]; uint num10 = num4 + num9; uint num11 = num9 + SHA256Managed.Sigma_0(num1) + SHA256Managed.Maj(num1, num2, num3); int index3 = index2 + 1; uint num12 = num7 + SHA256Managed.Sigma_1(num10) + SHA256Managed.Ch(num10, num5, num6) + SHA256Managed._K[index3] + expandedBuffer[index3]; uint num13 = num3 + num12; uint num14 = num12 + SHA256Managed.Sigma_0(num11) + SHA256Managed.Maj(num11, num1, num2); int index4 = index3 + 1; uint num15 = num6 + SHA256Managed.Sigma_1(num13) + SHA256Managed.Ch(num13, num10, num5) + SHA256Managed._K[index4] + expandedBuffer[index4]; uint num16 = num2 + num15; uint num17 = num15 + SHA256Managed.Sigma_0(num14) + SHA256Managed.Maj(num14, num11, num1); int index5 = index4 + 1; uint num18 = num5 + SHA256Managed.Sigma_1(num16) + SHA256Managed.Ch(num16, num13, num10) + SHA256Managed._K[index5] + expandedBuffer[index5]; uint num19 = num1 + num18; uint num20 = num18 + SHA256Managed.Sigma_0(num17) + SHA256Managed.Maj(num17, num14, num11); int index6 = index5 + 1; uint num21 = num10 + SHA256Managed.Sigma_1(num19) + SHA256Managed.Ch(num19, num16, num13) + SHA256Managed._K[index6] + expandedBuffer[index6]; num8 = num11 + num21; num4 = num21 + SHA256Managed.Sigma_0(num20) + SHA256Managed.Maj(num20, num17, num14); int index7 = index6 + 1; uint num22 = num13 + SHA256Managed.Sigma_1(num8) + SHA256Managed.Ch(num8, num19, num16) + SHA256Managed._K[index7] + expandedBuffer[index7]; num7 = num14 + num22; num3 = num22 + SHA256Managed.Sigma_0(num4) + SHA256Managed.Maj(num4, num20, num17); int index8 = index7 + 1; uint num23 = num16 + SHA256Managed.Sigma_1(num7) + SHA256Managed.Ch(num7, num8, num19) + SHA256Managed._K[index8] + expandedBuffer[index8]; num6 = num17 + num23; num2 = num23 + SHA256Managed.Sigma_0(num3) + SHA256Managed.Maj(num3, num4, num20); index1 = index8 + 1; uint num24 = num19 + SHA256Managed.Sigma_1(num6) + SHA256Managed.Ch(num6, num7, num8) + SHA256Managed._K[index1] + expandedBuffer[index1]; num5 = num20 + num24; num1 = num24 + SHA256Managed.Sigma_0(num2) + SHA256Managed.Maj(num2, num3, num4); } uint *numPtr = state; int num25 = (int)*numPtr + (int)num1; * numPtr = (uint)num25; IntPtr num26 = (IntPtr)state + 4; int num27 = (int)*(uint *)num26 + (int)num2; *(int *)num26 = num27; IntPtr num28 = (IntPtr)(state + 2); int num29 = (int)*(uint *)num28 + (int)num3; *(int *)num28 = num29; IntPtr num30 = (IntPtr)(state + 3); int num31 = (int)*(uint *)num30 + (int)num4; *(int *)num30 = num31; IntPtr num32 = (IntPtr)(state + 4); int num33 = (int)*(uint *)num32 + (int)num5; *(int *)num32 = num33; IntPtr num34 = (IntPtr)(state + 5); int num35 = (int)*(uint *)num34 + (int)num6; *(int *)num34 = num35; IntPtr num36 = (IntPtr)(state + 6); int num37 = (int)*(uint *)num36 + (int)num7; *(int *)num36 = num37; IntPtr num38 = (IntPtr)(state + 7); int num39 = (int)*(uint *)num38 + (int)num8; *(int *)num38 = num39; }
private static unsafe void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint x = state[0]; uint y = state[1]; uint z = state[2]; uint num4 = state[3]; uint num5 = state[4]; uint num6 = state[5]; uint num8 = state[6]; uint num7 = state[7]; Utils.DWORDFromBigEndian(expandedBuffer, 0x10, block); SHA256Expand(expandedBuffer); for (int i = 0; i < 0x40; i++) { uint num17 = (((num7 + Sigma_1(num5)) + Ch(num5, num6, num8)) + _K[i]) + expandedBuffer[i]; uint num13 = num4 + num17; uint num9 = (num17 + Sigma_0(x)) + Maj(x, y, z); i++; num17 = (((num8 + Sigma_1(num13)) + Ch(num13, num5, num6)) + _K[i]) + expandedBuffer[i]; uint num14 = z + num17; uint num10 = (num17 + Sigma_0(num9)) + Maj(num9, x, y); i++; num17 = (((num6 + Sigma_1(num14)) + Ch(num14, num13, num5)) + _K[i]) + expandedBuffer[i]; uint num16 = y + num17; uint num11 = (num17 + Sigma_0(num10)) + Maj(num10, num9, x); i++; num17 = (((num5 + Sigma_1(num16)) + Ch(num16, num14, num13)) + _K[i]) + expandedBuffer[i]; uint num15 = x + num17; uint num12 = (num17 + Sigma_0(num11)) + Maj(num11, num10, num9); i++; num17 = (((num13 + Sigma_1(num15)) + Ch(num15, num16, num14)) + _K[i]) + expandedBuffer[i]; num7 = num9 + num17; num4 = (num17 + Sigma_0(num12)) + Maj(num12, num11, num10); i++; num17 = (((num14 + Sigma_1(num7)) + Ch(num7, num15, num16)) + _K[i]) + expandedBuffer[i]; num8 = num10 + num17; z = (num17 + Sigma_0(num4)) + Maj(num4, num12, num11); i++; num17 = (((num16 + Sigma_1(num8)) + Ch(num8, num7, num15)) + _K[i]) + expandedBuffer[i]; num6 = num11 + num17; y = (num17 + Sigma_0(z)) + Maj(z, num4, num12); i++; num17 = (((num15 + Sigma_1(num6)) + Ch(num6, num8, num7)) + _K[i]) + expandedBuffer[i]; num5 = num12 + num17; x = (num17 + Sigma_0(y)) + Maj(y, z, num4); } state[0] += x; uint *numPtr1 = state + 1; numPtr1[0] += y; uint *numPtr2 = state + 2; numPtr2[0] += z; uint *numPtr3 = state + 3; numPtr3[0] += num4; uint *numPtr4 = state + 4; numPtr4[0] += num5; uint *numPtr5 = state + 5; numPtr5[0] += num6; uint *numPtr6 = state + 6; numPtr6[0] += num8; uint *numPtr7 = state + 7; numPtr7[0] += num7; }
[System.Security.SecurityCritical] // auto-generated private static unsafe void SHATransform(uint *expandedBuffer, uint *state, byte *block) { UInt32 a, b, c, d, e, f, h, g; UInt32 aa, bb, cc, dd, ee, ff, hh, gg; UInt32 T1; a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; f = state[5]; g = state[6]; h = state[7]; // fill in the first 16 bytes of W. Utils.DWORDFromBigEndian(expandedBuffer, 16, block); SHA256Expand(expandedBuffer); /* Apply the SHA256 compression function */ // We are trying to be smart here and avoid as many copies as we can // The perf gain with this method over the straightforward modify and shift // forward is >= 20%, so it's worth the pain for (int j = 0; j < 64;) { T1 = h + Sigma_1(e) + Ch(e, f, g) + _K[j] + expandedBuffer[j]; ee = d + T1; aa = T1 + Sigma_0(a) + Maj(a, b, c); j++; T1 = g + Sigma_1(ee) + Ch(ee, e, f) + _K[j] + expandedBuffer[j]; ff = c + T1; bb = T1 + Sigma_0(aa) + Maj(aa, a, b); j++; T1 = f + Sigma_1(ff) + Ch(ff, ee, e) + _K[j] + expandedBuffer[j]; gg = b + T1; cc = T1 + Sigma_0(bb) + Maj(bb, aa, a); j++; T1 = e + Sigma_1(gg) + Ch(gg, ff, ee) + _K[j] + expandedBuffer[j]; hh = a + T1; dd = T1 + Sigma_0(cc) + Maj(cc, bb, aa); j++; T1 = ee + Sigma_1(hh) + Ch(hh, gg, ff) + _K[j] + expandedBuffer[j]; h = aa + T1; d = T1 + Sigma_0(dd) + Maj(dd, cc, bb); j++; T1 = ff + Sigma_1(h) + Ch(h, hh, gg) + _K[j] + expandedBuffer[j]; g = bb + T1; c = T1 + Sigma_0(d) + Maj(d, dd, cc); j++; T1 = gg + Sigma_1(g) + Ch(g, h, hh) + _K[j] + expandedBuffer[j]; f = cc + T1; b = T1 + Sigma_0(c) + Maj(c, d, dd); j++; T1 = hh + Sigma_1(f) + Ch(f, g, h) + _K[j] + expandedBuffer[j]; e = dd + T1; a = T1 + Sigma_0(b) + Maj(b, c, d); j++; } state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; state[5] += f; state[6] += g; state[7] += h; }
private static unsafe void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint num = state[0]; uint num2 = state[1]; uint num3 = state[2]; uint num4 = state[3]; uint num5 = state[4]; Utils.DWORDFromBigEndian(expandedBuffer, 0x10, block); SHAExpand(expandedBuffer); int index = 0; while (index < 20) { num5 += ((((num << 5) | (num >> 0x1b)) + (num4 ^ (num2 & (num3 ^ num4)))) + expandedBuffer[index]) + 0x5a827999; num2 = (num2 << 30) | (num2 >> 2); num4 += ((((num5 << 5) | (num5 >> 0x1b)) + (num3 ^ (num & (num2 ^ num3)))) + expandedBuffer[index + 1]) + 0x5a827999; num = (num << 30) | (num >> 2); num3 += ((((num4 << 5) | (num4 >> 0x1b)) + (num2 ^ (num5 & (num ^ num2)))) + expandedBuffer[index + 2]) + 0x5a827999; num5 = (num5 << 30) | (num5 >> 2); num2 += ((((num3 << 5) | (num3 >> 0x1b)) + (num ^ (num4 & (num5 ^ num)))) + expandedBuffer[index + 3]) + 0x5a827999; num4 = (num4 << 30) | (num4 >> 2); num += ((((num2 << 5) | (num2 >> 0x1b)) + (num5 ^ (num3 & (num4 ^ num5)))) + expandedBuffer[index + 4]) + 0x5a827999; num3 = (num3 << 30) | (num3 >> 2); index += 5; } while (index < 40) { num5 += ((((num << 5) | (num >> 0x1b)) + ((num2 ^ num3) ^ num4)) + expandedBuffer[index]) + 0x6ed9eba1; num2 = (num2 << 30) | (num2 >> 2); num4 += ((((num5 << 5) | (num5 >> 0x1b)) + ((num ^ num2) ^ num3)) + expandedBuffer[index + 1]) + 0x6ed9eba1; num = (num << 30) | (num >> 2); num3 += ((((num4 << 5) | (num4 >> 0x1b)) + ((num5 ^ num) ^ num2)) + expandedBuffer[index + 2]) + 0x6ed9eba1; num5 = (num5 << 30) | (num5 >> 2); num2 += ((((num3 << 5) | (num3 >> 0x1b)) + ((num4 ^ num5) ^ num)) + expandedBuffer[index + 3]) + 0x6ed9eba1; num4 = (num4 << 30) | (num4 >> 2); num += ((((num2 << 5) | (num2 >> 0x1b)) + ((num3 ^ num4) ^ num5)) + expandedBuffer[index + 4]) + 0x6ed9eba1; num3 = (num3 << 30) | (num3 >> 2); index += 5; } while (index < 60) { num5 += ((((num << 5) | (num >> 0x1b)) + ((num2 & num3) | (num4 & (num2 | num3)))) + expandedBuffer[index]) + 0x8f1bbcdc; num2 = (num2 << 30) | (num2 >> 2); num4 += ((((num5 << 5) | (num5 >> 0x1b)) + ((num & num2) | (num3 & (num | num2)))) + expandedBuffer[index + 1]) + 0x8f1bbcdc; num = (num << 30) | (num >> 2); num3 += ((((num4 << 5) | (num4 >> 0x1b)) + ((num5 & num) | (num2 & (num5 | num)))) + expandedBuffer[index + 2]) + 0x8f1bbcdc; num5 = (num5 << 30) | (num5 >> 2); num2 += ((((num3 << 5) | (num3 >> 0x1b)) + ((num4 & num5) | (num & (num4 | num5)))) + expandedBuffer[index + 3]) + 0x8f1bbcdc; num4 = (num4 << 30) | (num4 >> 2); num += ((((num2 << 5) | (num2 >> 0x1b)) + ((num3 & num4) | (num5 & (num3 | num4)))) + expandedBuffer[index + 4]) + 0x8f1bbcdc; num3 = (num3 << 30) | (num3 >> 2); index += 5; } while (index < 80) { num5 += ((((num << 5) | (num >> 0x1b)) + ((num2 ^ num3) ^ num4)) + expandedBuffer[index]) + 0xca62c1d6; num2 = (num2 << 30) | (num2 >> 2); num4 += ((((num5 << 5) | (num5 >> 0x1b)) + ((num ^ num2) ^ num3)) + expandedBuffer[index + 1]) + 0xca62c1d6; num = (num << 30) | (num >> 2); num3 += ((((num4 << 5) | (num4 >> 0x1b)) + ((num5 ^ num) ^ num2)) + expandedBuffer[index + 2]) + 0xca62c1d6; num5 = (num5 << 30) | (num5 >> 2); num2 += ((((num3 << 5) | (num3 >> 0x1b)) + ((num4 ^ num5) ^ num)) + expandedBuffer[index + 3]) + 0xca62c1d6; num4 = (num4 << 30) | (num4 >> 2); num += ((((num2 << 5) | (num2 >> 0x1b)) + ((num3 ^ num4) ^ num5)) + expandedBuffer[index + 4]) + 0xca62c1d6; num3 = (num3 << 30) | (num3 >> 2); index += 5; } state[0] += num; uint *numPtr1 = state + 1; numPtr1[0] += num2; uint *numPtr2 = state + 2; numPtr2[0] += num3; uint *numPtr3 = state + 3; numPtr3[0] += num4; uint *numPtr4 = state + 4; numPtr4[0] += num5; }
private unsafe static void SHATransform(uint *expandedBuffer, uint *state, byte *block) { uint num = *state; uint num2 = state[1]; uint num3 = state[2]; uint num4 = state[3]; uint num5 = state[4]; Utils.DWORDFromBigEndian(expandedBuffer, 16, block); SHA1Managed.SHAExpand(expandedBuffer); int i; for (i = 0; i < 20; i += 5) { num5 += (num << 5 | num >> 27) + (num4 ^ (num2 & (num3 ^ num4))) + expandedBuffer[i] + 1518500249U; num2 = (num2 << 30 | num2 >> 2); num4 += (num5 << 5 | num5 >> 27) + (num3 ^ (num & (num2 ^ num3))) + expandedBuffer[i + 1] + 1518500249U; num = (num << 30 | num >> 2); num3 += (num4 << 5 | num4 >> 27) + (num2 ^ (num5 & (num ^ num2))) + expandedBuffer[i + 2] + 1518500249U; num5 = (num5 << 30 | num5 >> 2); num2 += (num3 << 5 | num3 >> 27) + (num ^ (num4 & (num5 ^ num))) + expandedBuffer[i + 3] + 1518500249U; num4 = (num4 << 30 | num4 >> 2); num += (num2 << 5 | num2 >> 27) + (num5 ^ (num3 & (num4 ^ num5))) + expandedBuffer[i + 4] + 1518500249U; num3 = (num3 << 30 | num3 >> 2); } while (i < 40) { num5 += (num << 5 | num >> 27) + (num2 ^ num3 ^ num4) + expandedBuffer[i] + 1859775393U; num2 = (num2 << 30 | num2 >> 2); num4 += (num5 << 5 | num5 >> 27) + (num ^ num2 ^ num3) + expandedBuffer[i + 1] + 1859775393U; num = (num << 30 | num >> 2); num3 += (num4 << 5 | num4 >> 27) + (num5 ^ num ^ num2) + expandedBuffer[i + 2] + 1859775393U; num5 = (num5 << 30 | num5 >> 2); num2 += (num3 << 5 | num3 >> 27) + (num4 ^ num5 ^ num) + expandedBuffer[i + 3] + 1859775393U; num4 = (num4 << 30 | num4 >> 2); num += (num2 << 5 | num2 >> 27) + (num3 ^ num4 ^ num5) + expandedBuffer[i + 4] + 1859775393U; num3 = (num3 << 30 | num3 >> 2); i += 5; } while (i < 60) { num5 += (num << 5 | num >> 27) + ((num2 & num3) | (num4 & (num2 | num3))) + expandedBuffer[i] + 2400959708U; num2 = (num2 << 30 | num2 >> 2); num4 += (num5 << 5 | num5 >> 27) + ((num & num2) | (num3 & (num | num2))) + expandedBuffer[i + 1] + 2400959708U; num = (num << 30 | num >> 2); num3 += (num4 << 5 | num4 >> 27) + ((num5 & num) | (num2 & (num5 | num))) + expandedBuffer[i + 2] + 2400959708U; num5 = (num5 << 30 | num5 >> 2); num2 += (num3 << 5 | num3 >> 27) + ((num4 & num5) | (num & (num4 | num5))) + expandedBuffer[i + 3] + 2400959708U; num4 = (num4 << 30 | num4 >> 2); num += (num2 << 5 | num2 >> 27) + ((num3 & num4) | (num5 & (num3 | num4))) + expandedBuffer[i + 4] + 2400959708U; num3 = (num3 << 30 | num3 >> 2); i += 5; } while (i < 80) { num5 += (num << 5 | num >> 27) + (num2 ^ num3 ^ num4) + expandedBuffer[i] + 3395469782U; num2 = (num2 << 30 | num2 >> 2); num4 += (num5 << 5 | num5 >> 27) + (num ^ num2 ^ num3) + expandedBuffer[i + 1] + 3395469782U; num = (num << 30 | num >> 2); num3 += (num4 << 5 | num4 >> 27) + (num5 ^ num ^ num2) + expandedBuffer[i + 2] + 3395469782U; num5 = (num5 << 30 | num5 >> 2); num2 += (num3 << 5 | num3 >> 27) + (num4 ^ num5 ^ num) + expandedBuffer[i + 3] + 3395469782U; num4 = (num4 << 30 | num4 >> 2); num += (num2 << 5 | num2 >> 27) + (num3 ^ num4 ^ num5) + expandedBuffer[i + 4] + 3395469782U; num3 = (num3 << 30 | num3 >> 2); i += 5; } *state += num; state[1] += num2; state[2] += num3; state[3] += num4; state[4] += num5; }