Ejemplo n.º 1
0
 private void TestWithSecretIntPtrActionSuccess(ISecureMemoryAllocator protectedMemoryAllocator)
 {
     Debug.WriteLine("TestWithSecretIntPtrActionSuccess");
     char[] secretChars = { 'a', 'b' };
     using (SecureMemorySecret secret =
                SecureMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration))
     {
         secret.WithSecretIntPtr((ptr, len) =>
         {
             Assert.NotEqual(ptr, IntPtr.Zero);
             Assert.True(len == 2);
         });
     }
 }
Ejemplo n.º 2
0
        private void TestWithSecretIntPtrDisposed(ISecureMemoryAllocator protectedMemoryAllocator)
        {
            Debug.WriteLine("TestWithSecretIntPtrDisposed");
            char[]             secretChars = { 'a', 'b' };
            SecureMemorySecret secret      =
                SecureMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration);

            secret.Dispose();
            Assert.Throws <InvalidOperationException>(() =>
            {
                secret.WithSecretIntPtr((ptr, len) =>
                {
                    return(true);
                });
            });
        }