private void TestWithSecretBytesWithClosedSecretShouldFail()
        {
            byte[] secretBytes           = { 0, 1 };
            ProtectedMemorySecret secret =
                new ProtectedMemorySecret((byte[])secretBytes.Clone(), protectedMemoryAllocatorController);

            secret.Close();
            Assert.Throws <InvalidOperationException>(() => { secret.WithSecretBytes(decryptedBytes => true); });
        }
示例#2
0
        private void TestWithSecretBytesWithClosedSecretShouldFail(IProtectedMemoryAllocator protectedMemoryAllocator)
        {
            Debug.WriteLine("TestWithSecretBytesWithClosedSecretShouldFail");
            byte[] secretBytes           = { 0, 1 };
            ProtectedMemorySecret secret =
                new ProtectedMemorySecret((byte[])secretBytes.Clone(), protectedMemoryAllocator, configuration);

            secret.Close();
            Assert.Throws <InvalidOperationException>(() => { secret.WithSecretBytes(decryptedBytes => true); });
        }
 private void TestWithSecretBytesAction()
 {
     byte[] secretBytes = { 0, 1 };
     using (ProtectedMemorySecret secret =
                new ProtectedMemorySecret((byte[])secretBytes.Clone(), protectedMemoryAllocatorController))
     {
         secret.WithSecretBytes(decryptedBytes =>
         {
             Assert.Equal(secretBytes, decryptedBytes);
         });
     }
 }
示例#4
0
 private void TestWithSecretBytesAction(IProtectedMemoryAllocator protectedMemoryAllocator)
 {
     Debug.WriteLine("TestWithSecretBytesAction");
     byte[] secretBytes = { 0, 1 };
     using (ProtectedMemorySecret secret =
                new ProtectedMemorySecret((byte[])secretBytes.Clone(), protectedMemoryAllocator, configuration))
     {
         secret.WithSecretBytes(decryptedBytes =>
         {
             Assert.Equal(secretBytes, decryptedBytes);
         });
     }
 }