Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
451 lines (419 sloc) 22.9 KB
using Microsoft.VisualStudio.TestTools.UnitTesting;
using S22.Imap.Auth.Sasl;
using S22.Imap.Auth.Sasl.Mechanisms;
using S22.Imap.Auth.Sasl.Mechanisms.Srp;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
namespace S22.Imap.Test {
/// <summary>
/// Contains unit tests for the SASL SRP authentication mechanism.
/// </summary>
[TestClass]
public class SrpTest {
/// <summary>
/// Serializes an instance of the ClientMessage1 class and verifies the
/// serialized byte sequence is identical to the pre-computed expected
/// byte sequence.
/// </summary>
[TestMethod]
[TestCategory("Srp")]
public void SerializeClientFirstMessage() {
byte[] expected = new byte[] {
0x00, 0x00, 0x00, 0x11, 0x00, 0x04, 0x74, 0x65,
0x73, 0x74, 0x00, 0x06, 0x61, 0x75, 0x74, 0x68,
0x49, 0x64, 0x00, 0x00, 0x00
};
ClientMessage1 m = new ClientMessage1("test", "authId");
Assert.IsTrue(m.Serialize().SequenceEqual(expected));
}
/// <summary>
/// Serializes an instance of the ClientMessage2 class and verifies the
/// serialized byte sequence is identical to the pre-computed expected
/// byte sequence.
/// </summary>
[TestMethod]
[TestCategory("Srp")]
public void SerializeClientSecondMessage() {
BigInteger key = BigInteger.Parse(clientPublicKey,
NumberStyles.HexNumber);
Mpi _publicKey = new Mpi(key);
ClientMessage2 m = new ClientMessage2(_publicKey, clientProof);
m.InitialVector = clientInitialVector;
foreach (KeyValuePair<string, string> p in clientOptions)
m.Options.Add(p.Key, p.Value);
byte[] serialized = m.Serialize();
Assert.IsTrue(serialized.SequenceEqual(expectedClientMessage2));
}
/// <summary>
/// Deserializes a byte sequence into an instance of the ServerMessage1
/// class and verifies the instance fields contain the expected values.
/// </summary>
[TestMethod]
[TestCategory("Srp")]
public void DeserializeServerFirstMessage() {
ServerMessage1 m = ServerMessage1.Deserialize(serverMessage1);
BigInteger expectedGenerator = new BigInteger(2),
expectedModulus = BigInteger.Parse(expectedSafePrimeModulus,
NumberStyles.HexNumber),
_expectedPublicKey = BigInteger.Parse(expectedPublicKey,
NumberStyles.HexNumber);
Assert.AreEqual<BigInteger>(expectedGenerator, m.Generator.Value);
Assert.AreEqual<BigInteger>(expectedModulus, m.SafePrimeModulus.Value);
Assert.AreEqual<BigInteger>(_expectedPublicKey, m.PublicKey.Value);
Assert.IsTrue(m.Salt.SequenceEqual(expectedSalt));
Assert.AreEqual<string>(expectedOptions, m.RawOptions);
Assert.AreEqual<int>(expectedParsedOptions.Count, m.Options.Count);
foreach (KeyValuePair<string, string> pair in expectedParsedOptions)
Assert.AreEqual<string>(pair.Value, m.Options[pair.Key]);
}
/// <summary>
/// Deserializes a byte sequence into an instance of the ServerMessage2
/// class and verifies the instance fields contain the expected values.
/// </summary>
[TestMethod]
[TestCategory("Srp")]
public void DeserializeServerSecondMessage() {
ServerMessage2 m = ServerMessage2.Deserialize(serverMessage2);
Assert.IsTrue(m.Proof.SequenceEqual(expectedServerProof));
Assert.IsTrue(m.InitialVector.SequenceEqual(expectedInitialVector));
Assert.AreEqual<string>(String.Empty, m.SessionId);
Assert.AreEqual<uint>(0, m.Ttl);
}
/// <summary>
/// Verifies the various parts of a sample authentication exchange
/// (Challenge generated by the Cyrus Sasl library).
/// </summary>
/// <remarks>The exchange was generated with the authorization id
/// (authId) set to the same value as the username.</remarks>
[TestMethod]
[TestCategory("Srp")]
public void VerifyAuthenticationExchange() {
byte[] privateKey = new byte[] {
0xAB, 0x1A, 0x11, 0x07, 0xDF, 0x5D, 0x91, 0xC5,
0xD6, 0x21, 0x47, 0x06, 0x41, 0xD7, 0x04, 0x63
};
SaslMechanism m = new SaslSrp("test@debian", "test", privateKey);
// Ensure the expected client initial-response is generated.
byte[] clientResponse = m.GetResponse(new byte[0]);
Assert.IsTrue(clientResponse.SequenceEqual(expectedClientFirst));
// Hand the server-challenge to the client and verify the expected
// client-response is generated.
clientResponse = m.GetResponse(serverFirst);
Assert.IsTrue(clientResponse.SequenceEqual(expectedClientSecond));
// Finally, hand the server-evidence to the client and verify the client
// responds with the empty string which concludes authentication.
clientResponse = m.GetResponse(serverSecond);
Assert.AreEqual<int>(0, clientResponse.Length);
}
#region Server Message 1
static byte[] serverMessage1 = new byte[] {
0x00, 0x00, 0x02, 0xF9, 0x00, 0x01, 0x00, 0xAC, 0x6B, 0xDB, 0x41,
0x32, 0x4A, 0x9A, 0x9B, 0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58,
0x2F, 0xAF, 0x72, 0xB6, 0x65, 0x19, 0x87, 0xEE, 0x07, 0xFC, 0x31,
0x92, 0x94, 0x3D, 0xB5, 0x60, 0x50, 0xA3, 0x73, 0x29, 0xCB, 0xB4,
0xA0, 0x99, 0xED, 0x81, 0x93, 0xE0, 0x75, 0x77, 0x67, 0xA1, 0x3D,
0xD5, 0x23, 0x12, 0xAB, 0x4B, 0x03, 0x31, 0x0D, 0xCD, 0x7F, 0x48,
0xA9, 0xDA, 0x04, 0xFD, 0x50, 0xE8, 0x08, 0x39, 0x69, 0xED, 0xB7,
0x67, 0xB0, 0xCF, 0x60, 0x95, 0x17, 0x9A, 0x16, 0x3A, 0xB3, 0x66,
0x1A, 0x05, 0xFB, 0xD5, 0xFA, 0xAA, 0xE8, 0x29, 0x18, 0xA9, 0x96,
0x2F, 0x0B, 0x93, 0xB8, 0x55, 0xF9, 0x79, 0x93, 0xEC, 0x97, 0x5E,
0xEA, 0xA8, 0x0D, 0x74, 0x0A, 0xDB, 0xF4, 0xFF, 0x74, 0x73, 0x59,
0xD0, 0x41, 0xD5, 0xC3, 0x3E, 0xA7, 0x1D, 0x28, 0x1E, 0x44, 0x6B,
0x14, 0x77, 0x3B, 0xCA, 0x97, 0xB4, 0x3A, 0x23, 0xFB, 0x80, 0x16,
0x76, 0xBD, 0x20, 0x7A, 0x43, 0x6C, 0x64, 0x81, 0xF1, 0xD2, 0xB9,
0x07, 0x87, 0x17, 0x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 0xB0, 0x8E, 0x41,
0x82, 0x96, 0x63, 0x8C, 0x11, 0x75, 0x57, 0xE6, 0xA2, 0xF5, 0xCB,
0xCB, 0xA0, 0x00, 0xDE, 0x6D, 0x64, 0x61, 0x3D, 0x53, 0x48, 0x41,
0x2D, 0x31, 0x2C, 0x72, 0x65, 0x70, 0x6C, 0x61, 0x79, 0x5F, 0x64,
0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x69, 0x6E,
0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x3D, 0x48, 0x4D, 0x41,
0x43, 0x2D, 0x53, 0x48, 0x41, 0x2D, 0x31, 0x2C, 0x69, 0x6E, 0x74,
0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x3D, 0x48, 0x4D, 0x41, 0x43,
0x2D, 0x52, 0x49, 0x50, 0x45, 0x4D, 0x44, 0x2D, 0x31, 0x36, 0x30,
0x2C, 0x69, 0x6E, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x3D,
0x48, 0x4D, 0x41, 0x43, 0x2D, 0x4D, 0x44, 0x35, 0x2C, 0x63, 0x6F,
0x6E, 0x66, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69,
0x74, 0x79, 0x3D, 0x44, 0x45, 0x53, 0x2C, 0x63, 0x6F, 0x6E, 0x66,
0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79,
0x3D, 0x33, 0x44, 0x45, 0x53, 0x2C, 0x63, 0x6F, 0x6E, 0x66, 0x69,
0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x3D,
0x41, 0x45, 0x53, 0x2C, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x64, 0x65,
0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x3D, 0x42, 0x6C,
0x6F, 0x77, 0x66, 0x69, 0x73, 0x68, 0x2C, 0x63, 0x6F, 0x6E, 0x66,
0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79,
0x3D, 0x43, 0x41, 0x53, 0x54, 0x2D, 0x31, 0x32, 0x38, 0x2C, 0x6D,
0x61, 0x78, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x73, 0x69, 0x7A,
0x65, 0x3D, 0x32, 0x30, 0x34, 0x38
};
#endregion
#region Server Message 2
static byte[] serverMessage2 = new byte[] {
0x00, 0x00, 0x00, 0x2C, 0x14, 0xEF, 0xC0, 0x2A, 0xD0, 0x1F, 0xCB,
0x35, 0x8C, 0x0F, 0xC9, 0xF7, 0x2A, 0x35, 0xE5, 0x92, 0xDC, 0x15,
0x7A, 0x00, 0x6D, 0x10, 0x8C, 0x6E, 0x44, 0x75, 0xD6, 0xF0, 0x95,
0x4B, 0xD5, 0xBF, 0x89, 0xA1, 0xDD, 0x52, 0x4D, 0x97, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
#endregion
#region Client Message 2
static byte[] clientProof = new byte[] {
0xA5, 0x84, 0xC6, 0x97, 0x07, 0x46, 0xFE, 0x80, 0xE5, 0x2D, 0xBB,
0x03, 0xF2, 0x3E, 0xC8, 0x10, 0xAE, 0xC1, 0xE3, 0x88
};
static byte[] clientInitialVector = new byte[] {
0x02, 0x3A, 0x90, 0x6C, 0x28, 0xEE, 0xB8, 0x37, 0x9F, 0xC1, 0x15,
0x62, 0xAE, 0x60, 0x41, 0xBF
};
static string clientPublicKey = "08A1FE2384AFB6214C1428692B564E11D" +
"07BE4F242E458A54EB96A19366CDF531F8B52A3B7E942B09B4C44A3477E4769" +
"CB900FC1862D4C29913EC9464B31D50EB07111152E4B503F2EB180628EE0036" +
"DB8FC97EAE16B450FEA3B49C60F5AD59C25D2EED1C1DF9026782F513445279A" +
"FB8B63E7C89AAE1A17AD1BF5E1A53ACACDDD0005AD8CF745B59969A29A22FF5" +
"40C151D3361F636D624B267DE80310B9FE49BC1DE9981084C2830084026D4D2" +
"EC5932C5F817FF87CB911DD3FA05710966E484D6A75C502E4BB9854478C6F97" +
"B7EE77999F5C2E5138B8F289F4A2DCA3FA9CEB045B2DEDB05E768A3AA416CF9" +
"14B7F96B7F2C6AF00C750D60F754554EA171972";
static Dictionary<string, string> clientOptions =
new Dictionary<string, string>() {
{ "mda", "SHA-1" },
{ "replay_detection", "true" },
{ "integrity", "HMAC-SHA-1" },
{ "confidentiality", "AES" },
{ "maxbuffersize", "2048" }
};
static byte[] expectedClientMessage2 = new byte[] {
0x00, 0x00, 0x01, 0x80, 0x01, 0x00, 0x8A, 0x1F, 0xE2, 0x38, 0x4A,
0xFB, 0x62, 0x14, 0xC1, 0x42, 0x86, 0x92, 0xB5, 0x64, 0xE1, 0x1D,
0x07, 0xBE, 0x4F, 0x24, 0x2E, 0x45, 0x8A, 0x54, 0xEB, 0x96, 0xA1,
0x93, 0x66, 0xCD, 0xF5, 0x31, 0xF8, 0xB5, 0x2A, 0x3B, 0x7E, 0x94,
0x2B, 0x09, 0xB4, 0xC4, 0x4A, 0x34, 0x77, 0xE4, 0x76, 0x9C, 0xB9,
0x00, 0xFC, 0x18, 0x62, 0xD4, 0xC2, 0x99, 0x13, 0xEC, 0x94, 0x64,
0xB3, 0x1D, 0x50, 0xEB, 0x07, 0x11, 0x11, 0x52, 0xE4, 0xB5, 0x03,
0xF2, 0xEB, 0x18, 0x06, 0x28, 0xEE, 0x00, 0x36, 0xDB, 0x8F, 0xC9,
0x7E, 0xAE, 0x16, 0xB4, 0x50, 0xFE, 0xA3, 0xB4, 0x9C, 0x60, 0xF5,
0xAD, 0x59, 0xC2, 0x5D, 0x2E, 0xED, 0x1C, 0x1D, 0xF9, 0x02, 0x67,
0x82, 0xF5, 0x13, 0x44, 0x52, 0x79, 0xAF, 0xB8, 0xB6, 0x3E, 0x7C,
0x89, 0xAA, 0xE1, 0xA1, 0x7A, 0xD1, 0xBF,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69, 0x6E, 0x74, 0x65, 0x67, 0x72, 0x69,
0x74, 0x79, 0x3D, 0x48, 0x4D, 0x41, 0x43, 0x2D, 0x53, 0x48, 0x41,
0x2D, 0x31, 0x2C, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x64, 0x65, 0x6E,
0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x3D, 0x41, 0x45, 0x53,
0x2C, 0x6D, 0x61, 0x78, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x73,
0x69, 0x7A, 0x65, 0x3D, 0x32, 0x30, 0x34, 0x38, 0x10, 0x02, 0x3A,
0x90, 0x6C, 0x28, 0xEE, 0xB8, 0x37, 0x9F, 0xC1, 0x15, 0x62, 0xAE,
0x60, 0x41, 0xBF
};
#endregion
#region Expected values
static string expectedSafePrimeModulus =
"0AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37" +
"329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E808396" +
"9EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC9" +
"75EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801" +
"676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA" +
"77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041" +
"C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525" +
"F54759B65E372FCD68EF20FA7111F9E4AFF73";
static string expectedPublicKey =
"09B4967B7A07C12DB492163C8204FF2BE5A49A8C93EE808E504380A26551E5061E24" +
"581BA689B6F876114CA7327B40FBD79D7D54D3CB8AD60258032FDD60FA92D44C082C" +
"BE51C83FE213B71424474B7FAB2B90EB56C5497FA110DD77C722F654707950605272" +
"EEE74DE3ED9C9E53285E4A141D0EB1F07BED49F58113B9DC29B0BF87E92D3F231C5E" +
"3471011DEA6826146BE8467A87C9EEDD5677361CA04D70F250DD778C136EEB91D975" +
"4EC14FFB0DE65F674DE1CF99059AE622352FA6F1D03286FB5600E0CA07F195CB2115" +
"A67A5D97B37EE74B6588BC1336D2A2416EF93608049D156364146440249A8E2F9937" +
"FB833B08E418296638C117557E6A2F5CBCBA0";
static byte[] expectedSalt = new byte[] {
0x0E, 0xC3, 0x6A, 0x9E, 0xA3, 0x39, 0x7C, 0xE8, 0x2D, 0x0E, 0xAC, 0x18,
0xA7, 0xD4, 0xCD, 0x16
};
static string expectedOptions = "mda=SHA-1,replay_detection,integrity=H" +
"MAC-SHA-1,integrity=HMAC-RIPEMD-160,integrity=HMAC-MD5,confidentiali" +
"ty=DES,confidentiality=3DES,confidentiality=AES,confidentiality=Blow" +
"fish,confidentiality=CAST-128,maxbuffersize=2048";
static Dictionary<string, string> expectedParsedOptions =
new Dictionary<string, string>() {
{ "mda", "SHA-1" },
{ "replay_detection", "true" },
{ "integrity", "HMAC-SHA-1,HMAC-RIPEMD-160,HMAC-MD5" },
{ "confidentiality", "DES,3DES,AES,Blowfish,CAST-128" },
{ "maxbuffersize", "2048" }
};
static byte[] expectedServerProof = new byte[] {
0xEF, 0xC0, 0x2A, 0xD0, 0x1F, 0xCB, 0x35, 0x8C, 0x0F, 0xC9, 0xF7, 0x2A,
0x35, 0xE5, 0x92, 0xDC, 0x15, 0x7A, 0x00, 0x6D
};
static byte[] expectedInitialVector = new byte[] {
0x8C, 0x6E, 0x44, 0x75, 0xD6, 0xF0, 0x95, 0x4B, 0xD5, 0xBF, 0x89, 0xA1,
0xDD, 0x52, 0x4D, 0x97
};
#endregion
#region Authentication Exchange
static byte[] serverFirst = new byte[] {
0x00, 0x00, 0x02, 0xF9, 0x00, 0x01, 0x00, 0xAC, 0x6B, 0xDB, 0x41,
0x32, 0x4A, 0x9A, 0x9B, 0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58,
0x2F, 0xAF, 0x72, 0xB6, 0x65, 0x19, 0x87, 0xEE, 0x07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,
0x43, 0x2D, 0x53, 0x48, 0x41, 0x2D, 0x31, 0x2C, 0x69, 0x6E, 0x74,
0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x3D, 0x48, 0x4D, 0x41, 0x43,
0x2D, 0x52, 0x49, 0x50, 0x45, 0x4D, 0x44, 0x2D, 0x31, 0x36, 0x30,
0x2C, 0x69, 0x6E, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x3D,
0x48, 0x4D, 0x41, 0x43, 0x2D, 0x4D, 0x44, 0x35, 0x2C, 0x63, 0x6F,
0x6E, 0x66, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69,
0x74, 0x79, 0x3D, 0x44, 0x45, 0x53, 0x2C, 0x63, 0x6F, 0x6E, 0x66,
0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79,
0x3D, 0x33, 0x44, 0x45, 0x53, 0x2C, 0x63, 0x6F, 0x6E, 0x66, 0x69,
0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x3D,
0x41, 0x45, 0x53, 0x2C, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x64, 0x65,
0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x3D, 0x42, 0x6C,
0x6F, 0x77, 0x66, 0x69, 0x73, 0x68, 0x2C, 0x63, 0x6F, 0x6E, 0x66,
0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x74, 0x79,
0x3D, 0x43, 0x41, 0x53, 0x54, 0x2D, 0x31, 0x32, 0x38, 0x2C, 0x6D,
0x61, 0x78, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x73, 0x69, 0x7A,
0x65, 0x3D, 0x32, 0x30, 0x34, 0x38
};
static byte[] expectedClientFirst = new byte[] {
0x00, 0x00, 0x00, 0x1D, 0x00, 0x0B, 0x74, 0x65, 0x73, 0x74, 0x40,
0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x00, 0x0B, 0x74, 0x65, 0x73,
0x74, 0x40, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x00, 0x00, 0x00
};
static byte[] expectedClientSecond = new byte[] {
0x00, 0x00, 0x01, 0x23, 0x01, 0x00, 0x1A, 0x2B, 0x50, 0xE8, 0x91,
0xB7, 0xE4, 0x6C, 0x6D, 0x30, 0x4F, 0x8D, 0x20, 0x85, 0xA0, 0xB5,
0xD6, 0x1F, 0xD6, 0x40, 0xAF, 0xEF, 0x78, 0xDE, 0xDA, 0xC6, 0x6A,
0x90, 0xB2, 0xD8, 0xBC, 0x56, 0x6B, 0xE6, 0xD4, 0x07, 0xBF, 0x8B,
0xD5, 0x8C, 0xDD, 0xE5, 0xA4, 0xC9, 0xF3, 0xAA, 0x25, 0xDC, 0x4F,
0x4A, 0x99, 0x9D, 0x17, 0x6E, 0xDF, 0xC4, 0x23, 0x8C, 0x48, 0x4C,
0x66, 0xC5, 0x66, 0x94, 0x36, 0xF2, 0x3C, 0xF7, 0xC2, 0x51, 0x2B,
0xD6, 0xA7, 0x2C, 0xD9, 0x2B, 0xC8, 0x16, 0xA9, 0xDE, 0x9E, 0x3D,
0xFB, 0xA4, 0xAA, 0x8F, 0x43, 0x5F, 0x90, 0xAF, 0x4B, 0xA9, 0xE3,
0x39, 0x63, 0xA4, 0x4F, 0x50, 0x27, 0x63, 0x3B, 0x37, 0x6D, 0x3F,
0xEB, 0xE1, 0x92, 0xCA, 0x78, 0xE4, 0x59, 0xD3, 0x8C, 0xD3, 0xFC,
0xCA, 0x62, 0xC9, 0x0C, 0x28, 0xD1, 0x83, 0x44, 0x78, 0x89, 0xF8,
0x48, 0xAA, 0xCD, 0x51, 0x17, 0x71, 0x31, 0x53, 0x28, 0xD6, 0x44,
0x56, 0x23, 0xDB, 0x99, 0x90, 0x4B, 0xA9, 0xFD, 0x7D, 0xB0, 0x80,
0xB7, 0xFC, 0x28, 0x88, 0x31, 0x9C, 0x1D, 0x2F, 0xD0, 0xCF, 0xA9,
0x3E, 0x92, 0x4E, 0x95, 0xDC, 0xAD, 0x12, 0xB6, 0xB4, 0x51, 0x53,
0x3E, 0xF5, 0x8D, 0xD1, 0x8B, 0xD2, 0x4C, 0x16, 0x79, 0x46, 0x13,
0x2F, 0x25, 0x80, 0x96, 0x53, 0x0E, 0x08, 0xEA, 0x8D, 0xC3, 0x58,
0xB7, 0x7C, 0xDC, 0x62, 0x1D, 0x37, 0xD4, 0x90, 0x35, 0xD4, 0x5E,
0x8B, 0x16, 0xBE, 0x2B, 0xB7, 0xD8, 0x5B, 0xD9, 0x0C, 0xDC, 0x6B,
0x46, 0x46, 0xFD, 0x15, 0x3F, 0x17, 0x90, 0xC4, 0xAB, 0x92, 0x5B,
0x00, 0xE9, 0xB8, 0x97, 0x10, 0xEF, 0xF4, 0x35, 0x32, 0xAC, 0x01,
0xDB, 0x81, 0x33, 0xA5, 0x64, 0x79, 0xDE, 0x45, 0x93, 0x38, 0xC0,
0x19, 0x5B, 0x82, 0x47, 0xBD, 0xDC, 0x52, 0x80, 0xC1, 0x14, 0xA8,
0xDC, 0x11, 0x00, 0xED, 0x94, 0xA9, 0x0F, 0xC5, 0x2A, 0x15, 0xC2,
0x01, 0x6F, 0xA7, 0xB7, 0xBF, 0x74, 0x7E, 0x43, 0x00, 0x09, 0x6D,
0x64, 0x61, 0x3D, 0x53, 0x48, 0x41, 0x2D, 0x31, 0x00
};
static byte[] serverSecond = new byte[] {
0x00, 0x00, 0x00, 0x2C, 0x14, 0xC7, 0x40, 0x3C, 0x3A, 0xB3, 0x5D,
0xB4, 0xB4, 0xD4, 0x28, 0x99, 0xC2, 0x0A, 0x0E, 0x04, 0xD2, 0x7C,
0xF2, 0x87, 0x98, 0x10, 0x0E, 0x46, 0x0B, 0x63, 0x0E, 0x80, 0xE6,
0x6A, 0xDF, 0xD4, 0xCF, 0xA0, 0x88, 0x1A, 0xFC, 0x67, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
#endregion
}
}