private void TestWithSecretBytesWithClosedSecretShouldFail() { byte[] secretBytes = { 0, 1 }; ProtectedMemorySecret secret = new ProtectedMemorySecret((byte[])secretBytes.Clone(), protectedMemoryAllocatorController); secret.Close(); Assert.Throws <InvalidOperationException>(() => { secret.WithSecretBytes(decryptedBytes => true); }); }
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); }); } }
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); }); } }