Esempio n. 1
0
        private void TestWithSecretUtf8CharsWithClosedSecretShouldFail(ISecureMemoryAllocator protectedMemoryAllocator)
        {
            Debug.WriteLine("TestWithSecretUtf8CharsWithClosedSecretShouldFail");
            char[]             secretChars = { 'a', 'b' };
            SecureMemorySecret secret      =
                SecureMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration);

            secret.Close();
            Assert.Throws <InvalidOperationException>(() => { secret.WithSecretUtf8Chars(decryptedChars => true); });
        }
Esempio n. 2
0
 private void TestWithSecretUtf8CharsAction(ISecureMemoryAllocator protectedMemoryAllocator)
 {
     Debug.WriteLine("TestWithSecretUtf8CharsAction");
     char[] secretChars = { 'a', 'b' };
     using (SecureMemorySecret secret =
                SecureMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration))
     {
         secret.WithSecretUtf8Chars(decryptedChars =>
         {
             Assert.Equal(secretChars, decryptedChars);
         });
     }
 }
Esempio n. 3
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);
         });
     }
 }
Esempio n. 4
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);
                });
            });
        }