/// <summary> /// M is client's proof of K. /// </summary> /// <returns></returns> public static Byte[] CalcM(NetBigInteger N, NetBigInteger g, String userName, Byte[] salt, NetBigInteger A, NetBigInteger B, Byte[] K) { // User -> Host: M = H(H(N) xor H(g), H(I), s, A, B, K) Byte[] gBytes = g.ToByteArray(); Byte[] NBytes = N.ToByteArray(); Byte[] hg = hashAlgo.ComputeHash(gBytes); Byte[] hN = hashAlgo.ComputeHash(NBytes); Byte[] gNXorBytes = XorArrays(hN, hg); Byte[] userNameBytes = Encoding.UTF8.GetBytes(userName); Byte[] hUserNameBytes = hashAlgo.ComputeHash(userNameBytes); Byte[] ABytes = A.ToByteArray(); Byte[] BBytes = B.ToByteArray(); ArrayList al = new ArrayList(); al.Add(gNXorBytes); al.Add(hUserNameBytes); al.Add(salt); al.Add(ABytes); al.Add(BBytes); al.Add(K); Byte[] all = NetUtility.JoinArrays(al); return(hashAlgo.ComputeHash(all)); }