Example #1
0
        public void TestRoundTrip2()
        {
            EncryptMessage msg = new EncryptMessage();

            msg.AddAttribute(HeaderKeys.Algorithm, AlgorithmValues.AES_GCM_128, Attributes.PROTECTED);
            msg.AddAttribute(HeaderKeys.IV, CBORObject.FromObject(rgbIV96), Attributes.PROTECTED);
            msg.SetContent(rgbContent);
            msg.AddRecipient(recipient128);
            msg.Encrypt();

            List <Recipient> rList = msg.RecipientList;

            Assert.AreEqual(rList.Count(), (1));

            byte[] rgbMsg = msg.EncodeToBytes();

            msg = EncryptMessage.DecodeFromBytes(rgbMsg);
            Recipient r = msg.RecipientList[0];

            r.SetKey(cnKey128);
            byte[] contentNew = msg.Decrypt(r);

            CollectionAssert.AreEqual(contentNew, (rgbContent));
        }