public void SerializeEncryptedMessage()
        {
            var result = new ClientSideEncryptor(new ClientSideEncryptionOptions(ClientSideEncryptionVersion.V1_0)
            {
                KeyEncryptionKey = GetIKeyEncryptionKey().Object,
                KeyWrapAlgorithm = KeyWrapAlgorithm
            }).BufferedEncryptInternal(
                new MemoryStream(Encoding.UTF8.GetBytes(TestMessage)),
                async: false,
                default).EnsureCompleted();
            var encryptedMessage = new EncryptedMessage()
            {
                EncryptedMessageText = Convert.ToBase64String(result.Ciphertext),
                EncryptionData       = result.EncryptionData
            };

            var serializedMessage = EncryptedMessageSerializer.Serialize(encryptedMessage);

            // success = don't throw. test values in another test with deserialization (can't control serialization order)
        }
        public void DeserializeEncryptedMessage()
        {
            var result = new ClientSideEncryptor(new ClientSideEncryptionOptions(ClientSideEncryptionVersion.V1_0)
            {
                KeyEncryptionKey = GetIKeyEncryptionKey().Object,
                KeyWrapAlgorithm = KeyWrapAlgorithm
            }).BufferedEncryptInternal(
                new MemoryStream(Encoding.UTF8.GetBytes(TestMessage)),
                async: false,
                default).EnsureCompleted();
            var encryptedMessage = new EncryptedMessage()
            {
                EncryptedMessageText = Convert.ToBase64String(result.Ciphertext),
                EncryptionData       = result.EncryptionData
            };
            var serializedMessage = EncryptedMessageSerializer.Serialize(encryptedMessage);

            var parsedEncryptedMessage = EncryptedMessageSerializer.Deserialize(serializedMessage);

            Assert.IsTrue(AreEqual(encryptedMessage, parsedEncryptedMessage));
        }
Ejemplo n.º 3
0
 public BlobClientSideEncryptor(ClientSideEncryptor encryptor)
 {
     _encryptor = encryptor;
 }
 public QueueClientSideEncryptor(ClientSideEncryptor encryptor)
 {
     _encryptor = encryptor;
 }