public static byte[] ProveRealmJoinChallenge(byte[] clientSecret, byte[] joinSecret, byte[] clientChallenge, byte[] serverChallenge) { WowAuthCrypto.ValidateParameter(clientSecret, 32, "clientSecret"); WowAuthCrypto.ValidateParameter(joinSecret, 32, "joinSecret"); WowAuthCrypto.ValidateParameter(clientChallenge, 16, "clientChallenge"); WowAuthCrypto.ValidateParameter(serverChallenge, 16, "serverChallenge"); SHA256 sHA = new SHA256CryptoServiceProvider(); byte[] array = sHA.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { clientSecret, joinSecret })); HMACSHA256 hMACSHA = new HMACSHA256(array); byte[] array2 = hMACSHA.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { clientChallenge, serverChallenge, WowAuthCrypto.REALM_JOIN_TAG })); byte[] array3 = new byte[24]; Array.Copy(array2, array3, array3.Length); return(array3); }
private void Process() { this.data = this.sha256.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { this.key0, this.data, this.key1 })); this.used = 0; }
public static byte[] MakeSessionKey(byte[] clientSecret, byte[] joinSecret, byte[] clientChallenge, byte[] userRouterChallenge) { SHA256 sHA256CryptoServiceProvider = new SHA256CryptoServiceProvider(); byte[] numArray = sHA256CryptoServiceProvider.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { clientSecret, joinSecret })); HMACSHA256 hMACSHA256 = new HMACSHA256(numArray); byte[] numArray1 = hMACSHA256.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { userRouterChallenge, clientChallenge, WowAuthCrypto.MAKE_SESSION_KEY_TAG })); return((new WowAuthCrypto.CryptoRandom(numArray1)).Read(40)); }
public static byte[] ProveContinueSessionChallenge(byte[] sessionKey, byte[] clientChallenge, byte[] serverChallenge, ulong connectionKey) { WowAuthCrypto.ValidateParameter(sessionKey, 40, "sessionKey"); WowAuthCrypto.ValidateParameter(clientChallenge, 16, "clientChallenge"); WowAuthCrypto.ValidateParameter(serverChallenge, 16, "serverChallenge"); byte[] bytes = BitConverter.GetBytes(connectionKey); if (!BitConverter.IsLittleEndian) { Array.Reverse(bytes); } HMACSHA256 hMACSHA256 = new HMACSHA256(sessionKey); byte[] numArray = hMACSHA256.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { bytes, clientChallenge, serverChallenge, WowAuthCrypto.CONTINUE_SESSION_TAG })); byte[] numArray1 = new byte[24]; Array.Copy(numArray, numArray1, (int)numArray1.Length); return(numArray1); }
public static byte[] MakeSessionKey(byte[] clientSecret, byte[] joinSecret, byte[] clientChallenge, byte[] userRouterChallenge) { SHA256 sha = new SHA256CryptoServiceProvider(); byte[] key = sha.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { clientSecret, joinSecret })); HMACSHA256 hmacsha = new HMACSHA256(key); byte[] seed = hmacsha.ComputeHash(WowAuthCrypto.Concatenate(new byte[][] { userRouterChallenge, clientChallenge, WowAuthCrypto.MAKE_SESSION_KEY_TAG })); WowAuthCrypto.CryptoRandom cryptoRandom = new WowAuthCrypto.CryptoRandom(seed); return(cryptoRandom.Read(40)); }
private static void Main(string[] args) { byte[] numArray = new byte[] { 176, 78, 211, 218, 114, 8, 0, 13, 123, 221, 218, 157, 108, 99, 149, 198, 119, 9, 57, 63, 0, 71, 192, 27, 250, 64, 179, 242, 236, 206, 83, 13 }; byte[] numArray1 = new byte[] { 125, 73, 96, 253, 110, 64, 35, 206, 201, 11, 222, 183, 70, 22, 93, 32, 137, 184, 228, 228, 142, 16, 50, 68, 42, 99, 74, 105, 38, 131, 42, 69 }; byte[] numArray2 = new byte[] { 215, 45, 27, 195, 145, 121, 49, 207, 52, 62, 232, 194, 241, 226, 8, 189 }; byte[] numArray3 = new byte[] { 216, 246, 86, 53, 124, 144, 185, 179, 47, 229, 128, 162, 102, 108, 178, 29 }; byte[] numArray4 = new byte[] { 78, 227, 176, 41, 143, 104, 175, 7, 56, 183, 255, 18, 255, 55, 78, 109 }; ulong num = 5793138720705260506L; byte[] numArray5 = new byte[] { 73, 217, 13, 12, 31, 228, 141, 202, 216, 215, 67, 157, 130, 132, 127, 190, 140, 67, 2, 225, 154, 29, 230, 39 }; byte[] numArray6 = new byte[] { 74, 43, 54, 227, 47, 242, 173, 15, 166, 230, 105, 27, 126, 94, 167, 172, 173, 109, 25, 146, 229, 113, 125, 45, 125, 168, 233, 176, 201, 155, 71, 12, 199, 110, 211, 48, 92, 160, 231, 41 }; byte[] numArray7 = new byte[] { 122, 17, 5, 194, 174, 42, 175, 11, 175, 153, 229, 247, 188, 184, 17, 100, 32, 127, 229, 167, 236, 74, 96, 132 }; byte[] numArray8 = WowAuthCrypto.ProveRealmJoinChallenge(numArray, numArray1, numArray2, numArray3); Console.WriteLine(WowAuthCrypto.CompareBytes(numArray5, numArray8)); Console.WriteLine(WowAuthCrypto.VerifyRealmJoinChallenge(numArray5, numArray, numArray1, numArray2, numArray3)); byte[] numArray9 = WowAuthCrypto.MakeSessionKey(numArray, numArray1, numArray2, numArray4); Console.WriteLine(WowAuthCrypto.CompareBytes(numArray6, numArray9)); byte[] numArray10 = WowAuthCrypto.ProveContinueSessionChallenge(numArray9, numArray2, numArray3, num); Console.WriteLine(WowAuthCrypto.CompareBytes(numArray7, numArray10)); Console.WriteLine(WowAuthCrypto.VerifyContinueSessionChallenge(numArray10, numArray9, numArray2, numArray3, num)); }
private static void Main(string[] args) { byte[] clientSecret = new byte[] { 176, 78, 211, 218, 114, 8, 0, 13, 123, 221, 218, 157, 108, 99, 149, 198, 119, 9, 57, 63, 0, 71, 192, 27, 250, 64, 179, 242, 236, 206, 83, 13 }; byte[] joinSecret = new byte[] { 125, 73, 96, 253, 110, 64, 35, 206, 201, 11, 222, 183, 70, 22, 93, 32, 137, 184, 228, 228, 142, 16, 50, 68, 42, 99, 74, 105, 38, 131, 42, 69 }; byte[] clientChallenge = new byte[] { 215, 45, 27, 195, 145, 121, 49, 207, 52, 62, 232, 194, 241, 226, 8, 189 }; byte[] serverChallenge = new byte[] { 216, 246, 86, 53, 124, 144, 185, 179, 47, 229, 128, 162, 102, 108, 178, 29 }; byte[] userRouterChallenge = new byte[] { 78, 227, 176, 41, 143, 104, 175, 7, 56, 183, 255, 18, 255, 55, 78, 109 }; ulong connectionKey = 5793138720705260506uL; byte[] array = new byte[] { 73, 217, 13, 12, 31, 228, 141, 202, 216, 215, 67, 157, 130, 132, 127, 190, 140, 67, 2, 225, 154, 29, 230, 39 }; byte[] left = new byte[] { 74, 43, 54, 227, 47, 242, 173, 15, 166, 230, 105, 27, 126, 94, 167, 172, 173, 109, 25, 146, 229, 113, 125, 45, 125, 168, 233, 176, 201, 155, 71, 12, 199, 110, 211, 48, 92, 160, 231, 41 }; byte[] left2 = new byte[] { 122, 17, 5, 194, 174, 42, 175, 11, 175, 153, 229, 247, 188, 184, 17, 100, 32, 127, 229, 167, 236, 74, 96, 132 }; byte[] right = WowAuthCrypto.ProveRealmJoinChallenge(clientSecret, joinSecret, clientChallenge, serverChallenge); Console.WriteLine(WowAuthCrypto.CompareBytes(array, right)); Console.WriteLine(WowAuthCrypto.VerifyRealmJoinChallenge(array, clientSecret, joinSecret, clientChallenge, serverChallenge)); byte[] array2 = WowAuthCrypto.MakeSessionKey(clientSecret, joinSecret, clientChallenge, userRouterChallenge); Console.WriteLine(WowAuthCrypto.CompareBytes(left, array2)); byte[] array3 = WowAuthCrypto.ProveContinueSessionChallenge(array2, clientChallenge, serverChallenge, connectionKey); Console.WriteLine(WowAuthCrypto.CompareBytes(left2, array3)); Console.WriteLine(WowAuthCrypto.VerifyContinueSessionChallenge(array3, array2, clientChallenge, serverChallenge, connectionKey)); }
public static bool VerifyContinueSessionChallenge(byte[] proof, byte[] sessionKey, byte[] clientChallenge, byte[] serverChallenge, ulong connectionKey) { WowAuthCrypto.ValidateParameter(proof, 24, "proof"); byte[] right = WowAuthCrypto.ProveContinueSessionChallenge(sessionKey, clientChallenge, serverChallenge, connectionKey); return(WowAuthCrypto.CompareBytes(proof, right)); }
public static bool VerifyRealmJoinChallenge(byte[] proof, byte[] clientSecret, byte[] joinSecret, byte[] clientChallenge, byte[] serverChallenge) { WowAuthCrypto.ValidateParameter(proof, 24, "proof"); byte[] right = WowAuthCrypto.ProveRealmJoinChallenge(clientSecret, joinSecret, clientChallenge, serverChallenge); return(WowAuthCrypto.CompareBytes(proof, right)); }