public static void TestHeaderBlockFactory(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            V1DocumentHeaders headers = new V1DocumentHeaders(new Passphrase("passphrase"), 10);

            using (MemoryStream stream = new MemoryStream())
            {
                headers.WriteWithoutHmac(stream);
                stream.Position = 0;

                UnversionedAxCryptReader reader = new UnversionedAxCryptReader(new LookAheadStream(stream));
                bool unexpectedHeaderTypeFound  = false;
                while (reader.Read())
                {
                    if (reader.CurrentItemType != AxCryptItemType.HeaderBlock)
                    {
                        continue;
                    }
                    switch (reader.CurrentHeaderBlock.HeaderBlockType)
                    {
                    case HeaderBlockType.Preamble:
                    case HeaderBlockType.Version:
                    case HeaderBlockType.Data:
                    case HeaderBlockType.Unrecognized:
                        break;

                    default:
                        unexpectedHeaderTypeFound = !(reader.CurrentHeaderBlock is UnrecognizedHeaderBlock);
                        break;
                    }
                }
                Assert.That(unexpectedHeaderTypeFound, Is.False);
            }
        }
Пример #2
0
        public static void Setup()
        {
            SetupAssembly.AssemblySetup();

            _fileSystemState = new FileSystemState();
            _fileSystemState.Load(OS.Current.FileInfo(_fileSystemStateFilePath));
        }
        public async Task TestNotificationEncryptPendingFilesInLoggedOnFolders(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            FakeDataStore.AddFolder(@"C:\My Documents\");
            Mock <AxCryptFile> mock = new Mock <AxCryptFile>();

            mock.Setup(acf => acf.EncryptFoldersUniqueWithBackupAndWipeAsync(It.IsAny <IEnumerable <IDataContainer> >(), It.IsAny <EncryptionParameters>(), It.IsAny <IProgressContext>()));

            Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>();

            SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, New <ActiveFileAction>(), mock.Object, mockStatusChecker.Object);
            LogOnIdentity defaultKey           = new LogOnIdentity("default");
            await Resolve.KnownIdentities.SetDefaultEncryptionIdentity(defaultKey);

            await Resolve.FileSystemState.AddWatchedFolderAsync(new WatchedFolder(@"C:\My Documents\", defaultKey.Tag));

            List <SessionNotification> sessionEvents = new List <SessionNotification>();

            sessionEvents.Add(new SessionNotification(SessionNotificationType.EncryptPendingFiles));

            foreach (SessionNotification sessionEvent in sessionEvents)
            {
                await handler.HandleNotificationAsync(sessionEvent);
            }
            mock.Verify(acf => acf.EncryptFoldersUniqueWithBackupAndWipeAsync(It.Is <IEnumerable <IDataContainer> >(infos => infos.Any((i) => i.FullName == @"C:\My Documents\".NormalizeFolderPath())), It.IsAny <EncryptionParameters>(), It.IsAny <IProgressContext>()), Times.Exactly(1));
        }
        public async Task TestHandleSessionEventLogOn(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            MockAxCryptFile mock        = new MockAxCryptFile();
            bool            called      = false;
            int             folderCount = -1;

            mock.EncryptFilesUniqueWithBackupAndWipeMockAsync = async(IEnumerable <IDataContainer> folderInfos, EncryptionParameters encryptionParameters, IProgressContext progress) =>
            {
                folderCount = folderInfos.Count();
                called      = true;
                await Task.Delay(0);
            };

            Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>();

            SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, New <ActiveFileAction>(), mock, mockStatusChecker.Object);

            FakeDataStore.AddFolder(@"C:\WatchedFolder");
            LogOnIdentity key = new LogOnIdentity("passphrase");
            await Resolve.FileSystemState.AddWatchedFolderAsync(new WatchedFolder(@"C:\WatchedFolder", key.Tag));

            await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.SignIn, key));

            Assert.That(called, Is.True);
            Assert.That(folderCount, Is.EqualTo(1), "There should be one folder passed for encryption as a result of the event.");
        }
        public void Setup()
        {
            SetupAssembly.AssemblySetup();
            SetupAssembly.AssemblySetupCrypto(_cryptoImplementation);

            TypeMap.Register.Singleton <ParallelFileOperation>(() => new ParallelFileOperation());
        }
Пример #6
0
        public void Setup()
        {
            SetupAssembly.AssemblySetup();
            SetupAssembly.AssemblySetupCrypto(_cryptoImplementation);

            TypeMap.Register.Singleton <IKnownFolderImageProvider>(() => new TestKnownImageProvider());
        }
        public async Task TestHandleSessionEventLogOffWithWatchedFolders(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            MockAxCryptFile mock   = new MockAxCryptFile();
            bool            called = false;

            mock.EncryptFilesUniqueWithBackupAndWipeMockAsync = async(IEnumerable <IDataContainer> folderInfos, EncryptionParameters encryptionParameters, IProgressContext progress) => { await Task.Delay(0); called = true; };

            Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>();

            await Resolve.KnownIdentities.SetDefaultEncryptionIdentity(new LogOnIdentity("passphrase"));

            SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, New <ActiveFileAction>(), mock, mockStatusChecker.Object);

            FakeDataStore.AddFolder(@"C:\WatchedFolder");
            await Resolve.FileSystemState.AddWatchedFolderAsync(new WatchedFolder(@"C:\WatchedFolder", Resolve.KnownIdentities.DefaultEncryptionIdentity.Tag));

            called = false;
            await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.EncryptPendingFiles));

            await handler.HandleNotificationAsync(new SessionNotification(SessionNotificationType.SignOut, Resolve.KnownIdentities.DefaultEncryptionIdentity));

            Assert.That(called, Is.True, nameof(AxCryptFile.EncryptFoldersUniqueWithBackupAndWipeAsync) + " should be called when a signing out.");
        }
Пример #8
0
        public static void TestPrematureEndOfFile(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            V1DocumentHeaders headers = new V1DocumentHeaders(new Passphrase("passphrase"), 10);

            using (MemoryStream stream = new MemoryStream())
            {
                headers.WriteWithoutHmac(stream);
                stream.Position = 0;

                using (V1AxCryptReader reader = new V1AxCryptReader(new LookAheadStream(stream)))
                {
                    AxCryptItemType lastItemType = AxCryptItemType.Undefined;
                    while (reader.Read())
                    {
                        lastItemType = reader.CurrentItemType;
                    }
                    Assert.That(lastItemType, Is.EqualTo(AxCryptItemType.Data));
                    Assert.That(reader.CurrentItemType, Is.EqualTo(AxCryptItemType.Data));

                    reader.SetStartOfData();
                    Assert.That(reader.Read(), Is.False);
                    Assert.That(reader.CurrentItemType, Is.EqualTo(AxCryptItemType.EndOfStream));

                    Assert.That(reader.Read(), Is.False);
                    Assert.That(reader.CurrentItemType, Is.EqualTo(AxCryptItemType.EndOfStream));
                }
            }
        }
Пример #9
0
        public void Setup()
        {
            SetupAssembly.AssemblySetup();
            SetupAssembly.AssemblySetupCrypto(_cryptoImplementation);

            TypeMap.Register.Singleton <FileSystemState>(() => new FileSystemState());
        }
Пример #10
0
        public void Setup()
        {
            SetupAssembly.AssemblySetup();
            SetupAssembly.AssemblySetupCrypto(_cryptoImplementation);

            TypeMap.Register.Singleton <FileSystemState>(() => FileSystemState.Create(New <IDataStore>(_fileSystemStateFilePath)));
        }
        public async Task TestHandleSessionEvents(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            MockAxCryptFile mock      = new MockAxCryptFile();
            int             callTimes = 0;

            mock.EncryptFilesUniqueWithBackupAndWipeMockAsync = async(IEnumerable <IDataContainer> folderInfos, EncryptionParameters encryptionParameters, IProgressContext progress) => { await Task.Delay(0); if (folderInfos.First().FullName == @"C:\My Documents\".NormalizeFilePath())
                                                                                                                                                                                           {
                                                                                                                                                                                               ++callTimes;
                                                                                                                                                                                           }
            };

            Mock <IStatusChecker> mockStatusChecker = new Mock <IStatusChecker>();

            SessionNotificationHandler handler = new SessionNotificationHandler(Resolve.FileSystemState, Resolve.KnownIdentities, New <ActiveFileAction>(), mock, mockStatusChecker.Object);

            FakeDataStore.AddFolder(@"C:\My Documents");
            LogOnIdentity key = new LogOnIdentity("passphrase");
            await Resolve.FileSystemState.AddWatchedFolderAsync(new WatchedFolder(@"C:\My Documents", key.Tag));

            List <SessionNotification> sessionEvents = new List <SessionNotification>();

            sessionEvents.Add(new SessionNotification(SessionNotificationType.WatchedFolderAdded, new LogOnIdentity("passphrase1"), @"C:\My Documents\"));
            sessionEvents.Add(new SessionNotification(SessionNotificationType.WatchedFolderAdded, new LogOnIdentity("passphrase"), @"C:\My Documents\"));

            foreach (SessionNotification sessionEvent in sessionEvents)
            {
                await handler.HandleNotificationAsync(sessionEvent);
            }
            Assert.That(callTimes, Is.EqualTo(2));
        }
Пример #12
0
        public static void TestInvalidArguments(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            SymmetricKey key = new SymmetricKey(128);
            SymmetricIV  iv  = new SymmetricIV(128);

            Assert.Throws <ArgumentNullException>(() =>
            {
                if (new V1AesCrypto(new V1Aes128CryptoFactory(), null, SymmetricIV.Zero128) == null)
                {
                }
            });

            Assert.Throws <ArgumentNullException>(() =>
            {
                if (new V1AesCrypto(new V1Aes128CryptoFactory(), null, iv) == null)
                {
                }
            });

            Assert.DoesNotThrow(() =>
            {
                if (new V1AesCrypto(new V1Aes128CryptoFactory(), key, iv) == null)
                {
                }
            });
        }
Пример #13
0
        public static void TestSubkeyMethods(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            SymmetricKey key    = new SymmetricKey(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 });
            Subkey       subkey = null;

            Assert.Throws <ArgumentNullException>(() =>
            {
                subkey = new Subkey(null, HeaderSubkey.Data);
            });

            Assert.Throws <InternalErrorException>(() =>
            {
                subkey = new Subkey(key, HeaderSubkey.None);
            });

            subkey = new Subkey(key, HeaderSubkey.Data);
            Assert.That(subkey.Key.Size, Is.EqualTo(128), "A Subkey is exactly 16 bytes.");
            Assert.That(subkey.Key.GetBytes(), Is.EquivalentTo(new byte[] { 0x5f, 0xfe, 0x14, 0x56, 0xd5, 0x94, 0xf9, 0x22, 0x42, 0xe3, 0x66, 0x8f, 0x8c, 0xe6, 0xea, 0xc6 }), "Comparing with a pre-calculated value assumed to be correct.");
            subkey = new Subkey(key, HeaderSubkey.Headers);
            Assert.That(subkey.Key.Size, Is.EqualTo(128), "A Subkey is exactly 16 bytes.");
            Assert.That(subkey.Key.GetBytes(), Is.EquivalentTo(new byte[] { 0x1c, 0x81, 0x0e, 0xe7, 0x65, 0xe7, 0x0b, 0x8f, 0x7a, 0xa3, 0x2b, 0x03, 0x05, 0x07, 0xf8, 0x8a }), "Comparing with a pre-calculated value assumed to be correct.");
            subkey = new Subkey(key, HeaderSubkey.Hmac);
            Assert.That(subkey.Key.Size, Is.EqualTo(128), "A Subkey is exactly 16 bytes.");
            Assert.That(subkey.Key.GetBytes(), Is.EquivalentTo(new byte[] { 0xdb, 0xf1, 0x84, 0x11, 0x2e, 0xb9, 0x11, 0x16, 0x59, 0x71, 0x2b, 0xaf, 0xcf, 0xf2, 0xab, 0x24 }), "Comparing with a pre-calculated value assumed to be correct.");
            subkey = new Subkey(key, HeaderSubkey.Validator);
            Assert.That(subkey.Key.Size, Is.EqualTo(128), "A Subkey is exactly 16 bytes.");
            Assert.That(subkey.Key.GetBytes(), Is.EquivalentTo(new byte[] { 0x45, 0x22, 0xa0, 0x3d, 0x98, 0x00, 0x9d, 0x55, 0x45, 0xed, 0x42, 0xfb, 0xd8, 0x35, 0x78, 0xd0 }), "Comparing with a pre-calculated value assumed to be correct.");

            Assert.That(new Subkey(key, HeaderSubkey.Hmac).Key.GetBytes(), Is.EquivalentTo(new Subkey(key, HeaderSubkey.Hmac).Key.GetBytes()), "The subkey generation should be stable.");
        }
Пример #14
0
        public static void Teardown()
        {
            _fileSystemState.Dispose();
            _fileSystemState = null;

            SetupAssembly.AssemblyTeardown();
        }
Пример #15
0
        public static void Setup()
        {
            SetupAssembly.AssemblySetup();

            FakeDataStore.AddFile(_davidCopperfieldTxtPath, FakeDataStore.TestDate4Utc, FakeDataStore.TestDate5Utc, FakeDataStore.TestDate6Utc, FakeDataStore.ExpandableMemoryStream(Encoding.GetEncoding(1252).GetBytes(Resources.david_copperfield)));
            FakeDataStore.AddFile(_uncompressedAxxPath, FakeDataStore.ExpandableMemoryStream(Resources.uncompressable_zip));
            FakeDataStore.AddFile(_helloWorldAxxPath, FakeDataStore.ExpandableMemoryStream(Resources.helloworld_key_a_txt));
        }
        public void Setup()
        {
            SetupAssembly.AssemblySetup();
            SetupAssembly.AssemblySetupCrypto(_cryptoImplementation);

            TypeMap.Register.Singleton <IRandomGenerator>(() => new FakePseudoRandomGenerator());
            TypeMap.Register.Singleton <IAsymmetricFactory>(() => new FakeAsymmetricFactory("MD5"));
        }
Пример #17
0
        public static void Setup()
        {
            SetupAssembly.AssemblySetup();

            _keyEncryptingKey = new AesKey(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F });
            _keyData          = new AesKey(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF });
            _wrapped          = new byte[] { 0x1F, 0xA6, 0x8B, 0x0A, 0x81, 0x12, 0xB4, 0x47, 0xAE, 0xF3, 0x4B, 0xD8, 0xFB, 0x5A, 0x7B, 0x82, 0x9D, 0x3E, 0x86, 0x23, 0x71, 0xD2, 0xCF, 0xE5 };
        }
Пример #18
0
 public static void Setup()
 {
     SetupAssembly.AssemblySetup();
     TypeMap.Register.Singleton <ISettingsStore>(() => new SettingsStore(Resolve.WorkFolder.FileInfo.FileItemInfo("UserSettings.txt")));
     TypeMap.Register.Singleton <UserSettingsVersion>(() => new UserSettingsVersion());
     TypeMap.Register.Singleton <UserSettings>(() => new UserSettings(New <ISettingsStore>(), New <IterationCalculator>()));
     FakeDataStore.AddFolder(@"C:\Folder\");
 }
Пример #19
0
 public static void Setup()
 {
     SetupAssembly.AssemblySetup();
     TypeMap.Register.Singleton <FakeRequestClient>(() => new FakeRequestClient());
     TypeMap.Register.Singleton <FakeRequestServer>(() => new FakeRequestServer());
     _fakeClient = New <FakeRequestClient>();
     _fakeServer = New <FakeRequestServer>();
     TypeMap.Register.Singleton <CommandService>(() => new CommandService(_fakeServer, _fakeClient));
 }
Пример #20
0
 public static void Setup()
 {
     TypeMap.Register.Singleton <IRuntimeEnvironment>(() => new FakeRuntimeEnvironment());
     TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory());
     TypeMap.Register.Singleton <CryptoFactory>(() => SetupAssembly.CreateCryptoFactory());
     TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512());
     TypeMap.Register.New <ICryptoPolicy>(() => new ProCryptoPolicy());
     TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged());
 }
Пример #21
0
        public static void Setup()
        {
            SetupAssembly.AssemblySetup();

            FakeRuntimeFileInfo.AddFile(_testTextPath, FakeRuntimeFileInfo.TestDate1Utc, FakeRuntimeFileInfo.TestDate2Utc, FakeRuntimeFileInfo.TestDate3Utc, FakeRuntimeFileInfo.ExpandableMemoryStream(Encoding.UTF8.GetBytes("This is a short file")));
            FakeRuntimeFileInfo.AddFile(_davidCopperfieldTxtPath, FakeRuntimeFileInfo.TestDate4Utc, FakeRuntimeFileInfo.TestDate5Utc, FakeRuntimeFileInfo.TestDate6Utc, FakeRuntimeFileInfo.ExpandableMemoryStream(Encoding.GetEncoding(1252).GetBytes(Resources.david_copperfield)));
            FakeRuntimeFileInfo.AddFile(_uncompressedAxxPath, FakeRuntimeFileInfo.ExpandableMemoryStream(Resources.uncompressable_zip));
            FakeRuntimeFileInfo.AddFile(_helloWorldAxxPath, FakeRuntimeFileInfo.ExpandableMemoryStream(Resources.helloworld_key_a_txt));
        }
Пример #22
0
        public static void TestConstructorWithKnownDefaultIdentity(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            _identities.Add(Passphrase.Empty);
            NewPasswordViewModel npvm = new NewPasswordViewModel(String.Empty, String.Empty);

            Assert.That(npvm.PasswordText, Is.EqualTo(String.Empty));
        }
Пример #23
0
        public static void Setup()
        {
            SetupAssembly.AssemblySetup();

            _identities = new List <Passphrase>();
            Mock <FileSystemState> fileSystemStateMock = new Mock <FileSystemState>();

            fileSystemStateMock.Setup <IList <Passphrase> >(f => f.KnownPassphrases).Returns(_identities);
            TypeMap.Register.Singleton <FileSystemState>(() => fileSystemStateMock.Object);
        }
Пример #24
0
        public static void TestExtensions_AccountKeyToUserAsymmetricKeysWithWrongPassphrase(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            UserKeyPair originalKeys  = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512);
            AccountKey  accountKey    = originalKeys.ToAccountKey(new Passphrase("password"));
            UserKeyPair roundtripKeys = accountKey.ToUserKeyPair(new Passphrase("wrong password"));

            Assert.That(roundtripKeys, Is.Null);
        }
Пример #25
0
        public static void TestThumbprint(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            Passphrase key1 = new Passphrase("genericPassphrase");

            SymmetricKeyThumbprint originalThumbprint = key1.Thumbprint;

            Assert.That(originalThumbprint, Is.EqualTo(key1.Thumbprint), "The thumbprints should be the same.");
        }
        public static void TestFileNameInfoAnsiName(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            V1AesCrypto headerCrypto = new V1AesCrypto(new V1Aes128CryptoFactory(), new V1DerivedKey(new Passphrase("nonterminating")).DerivedKey, SymmetricIV.Zero128);
            V1FileNameInfoEncryptedHeaderBlock fileInfoHeaderBlock = new V1FileNameInfoEncryptedHeaderBlock(headerCrypto);

            fileInfoHeaderBlock.FileName = "Dépôsé.txt";

            Assert.That(fileInfoHeaderBlock.FileName, Is.EqualTo("Dépôsé.txt"));
        }
Пример #27
0
        public static void TestExtensions_UserAsymmetricKeysToAccountKeyAndBackUsingDataProtection(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            UserKeyPair originalKeys  = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512);
            AccountKey  accountKey    = originalKeys.ToAccountKey(Passphrase.Empty);
            UserKeyPair roundtripKeys = accountKey.ToUserKeyPair(Passphrase.Empty);

            Assert.That(accountKey.KeyPair.PrivateEncryptedPem.Length, Is.GreaterThan(0));
            Assert.That(originalKeys, Is.EqualTo(roundtripKeys));
        }
        public void Setup()
        {
            SetupAssembly.AssemblySetup();
            SetupAssembly.AssemblySetupCrypto(_cryptoImplementation);

            FakeDataStore.AddFile(_davidCopperfieldTxtPath, FakeDataStore.TestDate4Utc, FakeDataStore.TestDate5Utc, FakeDataStore.TestDate6Utc, FakeDataStore.ExpandableMemoryStream(Encoding.GetEncoding(1252).GetBytes(Resources.david_copperfield)));
            FakeDataStore.AddFile(_uncompressedAxxPath, FakeDataStore.ExpandableMemoryStream(Resources.uncompressable_zip));
            FakeDataStore.AddFile(_helloWorldAxxPath, FakeDataStore.ExpandableMemoryStream(Resources.helloworld_key_a_txt));

            TypeMap.Register.Singleton <IUIThread>(() => new FakeUIThread());
        }
Пример #29
0
        public static void Setup()
        {
            SetupAssembly.AssemblySetup();

            FakeRuntimeFileInfo.AddFile(_davidCopperfieldTxtPath, FakeRuntimeFileInfo.TestDate4Utc, FakeRuntimeFileInfo.TestDate5Utc, FakeRuntimeFileInfo.TestDate6Utc, FakeRuntimeFileInfo.ExpandableMemoryStream(Encoding.GetEncoding(1252).GetBytes(Resources.david_copperfield)));
            FakeRuntimeFileInfo.AddFile(_uncompressedAxxPath, FakeRuntimeFileInfo.ExpandableMemoryStream(Resources.uncompressable_zip));
            FakeRuntimeFileInfo.AddFile(_helloWorldAxxPath, FakeRuntimeFileInfo.ExpandableMemoryStream(Resources.helloworld_key_a_txt));

            _fileSystemState = new FileSystemState();
            _fileSystemState.Load(FileSystemState.DefaultPathInfo);
        }
Пример #30
0
        public static void TestExtensions_DecryptToBadArgumentsCausingEarlyException(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            Stream           nullStream    = null;
            ICryptoTransform nullEncryptor = null;
            ICryptoTransform encryptor     = new V2AesCrypto(SymmetricKey.Zero256, SymmetricIV.Zero128, 0).DecryptingTransform();

            Assert.Throws <ArgumentNullException>(() => nullStream.DecryptTo(Stream.Null, encryptor, true));
            Assert.Throws <ArgumentNullException>(() => Stream.Null.DecryptTo(nullStream, encryptor, true));
            Assert.Throws <ArgumentNullException>(() => Stream.Null.DecryptTo(Stream.Null, nullEncryptor, true));
        }