public void ProfileExchangeTest() { UserAccount userA = new UserAccount() { UserNick = "UserA" }; UserAccount userB = new UserAccount() { UserNick = "UserB" }; UserAccount userC = new UserAccount() { UserNick = "UserC" }; IPublicProfile publicB = userB.PublicProfile; byte[] data = new byte[] { 1, 2, 3, 4, 5 }; //User A has the public profile of B, and thus can encrypt for B. byte[] dataToSend = publicB.Encrypt(data); byte[] received = userB.Decrypt(dataToSend); //byte[] eavesDropped = userC.Decrypt(dataToSend); //This throws exception. CollectionAssert.AreEqual(data, received); //CollectionAssert.AreNotEqual(data, eavesDropped); }
public void ProfileExchangeEvesdroppingTest() { UserAccount userA = new UserAccount() { UserNick = "UserA" }; UserAccount userB = new UserAccount() { UserNick = "UserB" }; UserAccount userC = new UserAccount() { UserNick = "UserC" }; IPublicProfile publicB = userB.PublicProfile; byte[] data = new byte[] { 1, 2, 3, 4, 5 }; //User A has the public profile of B, and thus can encrypt for B. byte[] dataToSend = publicB.Encrypt(data); //User C should not be able to decrypt this byte[] eavesDropped = userC.Decrypt(dataToSend); //This throws exception. }