public static ulong[] SeekW(ulong[] M) { ulong [] W = new ulong[80]; int i = 0; while (i < 16) { W[i] = M[i]; i++; } while (i < 80) { W[i] = SecFunction.CyclicShift4(W[i - 2]) + W[i - 7] + SecFunction.CyclicShift3(W[i - 15]) + W[i - 16]; i++; } return(W); }
//static ulong [,]HEgt=new ulong[81,8]; public static ulong[] Rounds(ulong[] W) { ulong T1, T2; ulong[] H = new ulong[8]; ulong a = BoxTransfer.H[0]; ulong b = BoxTransfer.H[1]; ulong c = BoxTransfer.H[2]; ulong d = BoxTransfer.H[3]; ulong e = BoxTransfer.H[4]; ulong f = BoxTransfer.H[5]; ulong g = BoxTransfer.H[6]; ulong h = BoxTransfer.H[7]; //表示轮数 int t = 0; while (t < 80) { T1 = h + SecFunction.CyclicShift2(e) + SecFunction.Ch(e, f, g) + BoxTransfer.K[t] + W[t]; T2 = SecFunction.CyclicShift1(a) + SecFunction.Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; t++; } H[0] = BoxTransfer.H2[0] + a; H[1] = BoxTransfer.H2[1] + b; H[2] = BoxTransfer.H2[2] + c; H[3] = BoxTransfer.H2[3] + d; H[4] = BoxTransfer.H2[4] + e; H[5] = BoxTransfer.H2[5] + f; H[6] = BoxTransfer.H2[6] + g; H[7] = BoxTransfer.H2[7] + h; return(H); }