private void TestRegionSuffix() { byte[] originalPayload = PayloadGenerator.CreateDefaultRandomBytePayload(); byte[] decryptedBytes; byte[] dataRowRecordBytes; // Encrypt originalPayloadString with metastore with key suffix using (SessionFactory sessionFactory = SessionFactoryGenerator .CreateDefaultSessionFactory(configFixture.KeyManagementService, dynamoDbMetastoreImplWithKeySuffix)) { using (Session <byte[], byte[]> sessionBytes = sessionFactory.GetSessionBytes("shopper123")) { dataRowRecordBytes = sessionBytes.Encrypt(originalPayload); } } // Decrypt dataRowString with metastore with key suffix using (SessionFactory sessionFactory = SessionFactoryGenerator .CreateDefaultSessionFactory(configFixture.KeyManagementService, dynamoDbMetastoreImplWithKeySuffix)) { using (Session <byte[], byte[]> sessionBytes = sessionFactory.GetSessionBytes("shopper123")) { // Decrypt the payload decryptedBytes = sessionBytes.Decrypt(dataRowRecordBytes); } } // Verify that we were able to decrypt with a suffixed builder Assert.Equal(decryptedBytes, originalPayload); }
public AppEncryptionByteMultiThreadedTest() { payload = PayloadGenerator.CreateDefaultRandomBytePayload(); appEncryptionSessionFactory = SessionFactoryGenerator.CreateDefaultAppEncryptionSessionFactory(); partitionId = DefaultPartitionId + "_" + DateTimeUtils.GetCurrentTimeAsUtcIsoDateTimeOffset(); appEncryptionBytes = appEncryptionSessionFactory.GetAppEncryptionBytes(partitionId); }
private void TestCrossRegionDecryption() { byte[] originalPayload = PayloadGenerator.CreateDefaultRandomBytePayload(); byte[] decryptedBytes; byte[] dataRowRecordBytes; // Encrypt originalPayloadString with metastore without key suffix using (SessionFactory sessionFactory = GetSessionFactory(true, DefaultRegion)) { using (Session <byte[], byte[]> sessionBytes = sessionFactory.GetSessionBytes("shopper123")) { dataRowRecordBytes = sessionBytes.Encrypt(originalPayload); } } // Decrypt dataRowString with metastore with key suffix using (SessionFactory sessionFactory = GetSessionFactory(true, "us-east-1")) { using (Session <byte[], byte[]> sessionBytes = sessionFactory.GetSessionBytes("shopper123")) { // Decrypt the payload decryptedBytes = sessionBytes.Decrypt(dataRowRecordBytes); } } // Verify that we were able to decrypt with a suffixed builder Assert.Equal(decryptedBytes, originalPayload); }
public SessionByteMultiThreadedTest(ConfigFixture configFixture) { payload = PayloadGenerator.CreateDefaultRandomBytePayload(); sessionFactory = SessionFactoryGenerator.CreateDefaultSessionFactory( configFixture.KeyManagementService, configFixture.Metastore); partitionId = DefaultPartitionId + "_" + DateTimeUtils.GetCurrentTimeAsUtcIsoDateTimeOffset(); sessionBytes = sessionFactory.GetSessionBytes(partitionId); }
public AppEncryptionBytesTest(ConfigFixture configFixture) { payload = PayloadGenerator.CreateDefaultRandomBytePayload(); appEncryptionSessionFactory = SessionFactoryGenerator.CreateDefaultAppEncryptionSessionFactory( configFixture.KeyManagementService, configFixture.MetastorePersistence); partitionId = DefaultPartitionId + "_" + DateTimeUtils.GetCurrentTimeAsUtcIsoDateTimeOffset(); appEncryptionBytes = appEncryptionSessionFactory.GetAppEncryptionBytes(partitionId); }
private void BytesStoreOverwritePayload() { string key = "some_key"; byte[] otherPayload = PayloadGenerator.CreateDefaultRandomBytePayload(); sessionBytes.Store(key, payload, PersistenceBytes); sessionBytes.Store(key, otherPayload, PersistenceBytes); Option <byte[]> decryptedPayload = sessionBytes.Load(key, PersistenceBytes); Assert.Equal(otherPayload, (byte[])decryptedPayload); }
private void BytesEncryptDecryptWithDifferentPayloads() { byte[] otherPayload = PayloadGenerator.CreateDefaultRandomBytePayload(); byte[] dataRowRecord1 = sessionBytes.Encrypt(payload); byte[] dataRowRecord2 = sessionBytes.Encrypt(otherPayload); byte[] decryptedPayload1 = sessionBytes.Decrypt(dataRowRecord1); byte[] decryptedPayload2 = sessionBytes.Decrypt(dataRowRecord2); Assert.Equal(payload, decryptedPayload1); Assert.Equal(otherPayload, decryptedPayload2); }
private void TestCrossPartitionDecryptShouldFail() { byte[] payload = PayloadGenerator.CreateDefaultRandomBytePayload(); byte[] dataRowRecordBytes; string originalPartitionId = "shopper123"; string alternatePartitionId = "shopper1234"; using (SessionFactory sessionFactory = SessionFactoryGenerator.CreateDefaultSessionFactory( configFixture.KeyManagementService, configFixture.Metastore)) { using (Session <byte[], byte[]> sessionBytes = sessionFactory.GetSessionBytes(originalPartitionId)) { dataRowRecordBytes = sessionBytes.Encrypt(payload); } using (Session <byte[], byte[]> sessionBytes = sessionFactory.GetSessionBytes(alternatePartitionId)) { Assert.Throws <MetadataMissingException>(() => sessionBytes.Decrypt(dataRowRecordBytes)); } } }