Exemplo n.º 1
0
 private void TestCreateSecretByteArray()
 {
     Debug.WriteLine("\nTestCreateSecretByteArray: Start");
     using Secret secret = transientSecretFactory.CreateSecret(new byte[] { 0, 1 });
     Assert.Equal(typeof(SecureMemorySecret), secret.GetType());
     Debug.WriteLine("TestCreateSecretByteArray: Finish\n");
 }
Exemplo n.º 2
0
        private void MultiThreadedWithSecretBytesAccess()
        {
            ISecretFactory secretFactory = new TransientSecretFactory(null);
            Secret         secret        = secretFactory.CreateSecret(payload.Clone() as byte[]);

            // Get the current settings and try to force minWorkers
            ThreadPool.GetMinThreads(out _, out var currentMinIOC);
            Assert.True(ThreadPool.SetMinThreads(NumThreads, currentMinIOC));

            int completedTasks = 0;

            Parallel.ForEach(Enumerable.Range(0, NumThreads), i =>
            {
                try
                {
                    secret.WithSecretBytes(decryptedBytes =>
                    {
                        Assert.Equal(payload, decryptedBytes);
                        Interlocked.Increment(ref completedTasks);
                    });
                }
                catch (ThreadInterruptedException e)
                {
                    Logger.LogError(e, "Unexpected error during call");
                    throw;
                }
            });
            Assert.Equal(NumThreads, completedTasks);
        }
Exemplo n.º 3
0
        private void TestCreateSecretByteArray()
        {
            Secret secret = transientSecretFactory.CreateSecret(new byte[] { 0, 1 });

            Assert.Equal(typeof(ProtectedMemorySecret), secret.GetType());
        }