예제 #1
0
        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.
        }
예제 #2
0
        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);
        }
예제 #3
0
파일: Package.cs 프로젝트: scoggs/p2crypt
 public Package(IPublicProfile user, byte[] data)
 {
     this.user = user;
     this.data = data;
 }