Пример #1
0
        private void TestGetEnvelopeEncryptionBytes()
        {
            IEnvelopeEncryption <byte[]> envelopeEncryption =
                sessionFactory.GetEnvelopeEncryptionBytes(TestPartitionId);

            Assert.NotNull(envelopeEncryption);
        }
Пример #2
0
        public void ParameterizedTests(
            IEnvelopeEncryption <byte[]> envelopeEncryptionJson,
            Mock <IMetastore <JObject> > metastore,
            KeyState cacheIK,
            KeyState metaIK,
            KeyState cacheSK,
            KeyState metaSK,
            Partition partition)
        {
            using (Session <JObject, byte[]> sessionJsonImpl =
                       new SessionJsonImpl <byte[]>(envelopeEncryptionJson))
            {
                EncryptMetastoreInteractions encryptMetastoreInteractions =
                    new EncryptMetastoreInteractions(cacheIK, metaIK, cacheSK, metaSK);
                DecryptMetastoreInteractions decryptMetastoreInteractions =
                    new DecryptMetastoreInteractions(cacheIK, cacheSK);

                // encrypt with library object(sessionJsonImpl)
                byte[] encryptedPayload = sessionJsonImpl.Encrypt(payload);

                Assert.NotNull(encryptedPayload);
                VerifyEncryptFlow(metastore, encryptMetastoreInteractions, partition);

                metastore.Invocations.Clear();
                JObject decryptedPayload = sessionJsonImpl.Decrypt(encryptedPayload);

                VerifyDecryptFlow(metastore, decryptMetastoreInteractions, partition);
                Assert.True(JToken.DeepEquals(payload, decryptedPayload));
            }
        }
Пример #3
0
        public void ParameterizedTests(
            IEnvelopeEncryption <byte[]> envelopeEncryptionJson,
            Mock <MemoryPersistenceImpl <JObject> > metastorePersistence,
            KeyState cacheIK,
            KeyState metaIK,
            KeyState cacheSK,
            KeyState metaSK,
            AppEncryptionPartition appEncryptionPartition)
        {
            using (AppEncryption <JObject, byte[]> appEncryptionJsonImpl =
                       new AppEncryptionJsonImpl <byte[]>(envelopeEncryptionJson))
            {
                EncryptMetastoreInteractions encryptMetastoreInteractions =
                    new EncryptMetastoreInteractions(cacheIK, metaIK, cacheSK, metaSK);
                DecryptMetastoreInteractions decryptMetastoreInteractions =
                    new DecryptMetastoreInteractions(cacheIK, cacheSK);

                // encrypt with library object(appEncryptionJsonImpl)
                byte[] encryptedPayload = appEncryptionJsonImpl.Encrypt(payload);

                Assert.NotNull(encryptedPayload);
                VerifyEncryptFlow(metastorePersistence, encryptMetastoreInteractions, appEncryptionPartition);

                metastorePersistence.Reset();
                JObject decryptedPayload = appEncryptionJsonImpl.Decrypt(encryptedPayload);

                VerifyDecryptFlow(metastorePersistence, decryptMetastoreInteractions, appEncryptionPartition);
                Assert.True(JToken.DeepEquals(payload, decryptedPayload));
            }
        }
Пример #4
0
        public Session <byte[], byte[]> GetSessionBytes(string partitionId)
        {
            IEnvelopeEncryption <byte[]> envelopeEncryption = GetEnvelopeEncryptionBytes(partitionId);

            return(new SessionBytesImpl <byte[]>(envelopeEncryption));
        }
Пример #5
0
        public Session <byte[], JObject> GetSessionBytesAsJson(string partitionId)
        {
            IEnvelopeEncryption <JObject> envelopeEncryption = GetEnvelopeEncryptionJson(partitionId);

            return(new SessionBytesImpl <JObject>(envelopeEncryption));
        }
Пример #6
0
 public SessionJsonImpl(IEnvelopeEncryption <TD> envelopeEncryption)
 {
     this.envelopeEncryption = envelopeEncryption;
 }
Пример #7
0
 public AppEncryptionBytesImpl(IEnvelopeEncryption <TD> envelopeEncryption)
 {
     this.envelopeEncryption = envelopeEncryption;
 }
Пример #8
0
        public AppEncryption <JObject, byte[]> GetAppEncryptionJson(string partitionId)
        {
            IEnvelopeEncryption <byte[]> envelopeEncryption = GetEnvelopeEncryptionBytes(partitionId);

            return(new AppEncryptionJsonImpl <byte[]>(envelopeEncryption));
        }
Пример #9
0
        public AppEncryption <JObject, JObject> GetAppEncryptionJsonAsJson(string partitionId)
        {
            IEnvelopeEncryption <JObject> envelopeEncryption = GetEnvelopeEncryptionJson(partitionId);

            return(new AppEncryptionJsonImpl <JObject>(envelopeEncryption));
        }
Пример #10
0
 public EnvelopeEncryptionBytesImpl(IEnvelopeEncryption <JObject> envelopeEncryptionJson)
 {
     this.envelopeEncryptionJson = envelopeEncryptionJson;
 }