示例#1
0
        public async Task IsValid_should_require_at_least_password_or_keyfile()
        {
            // Not specified
            var data = new PasswordData();

            Assert.False(data.IsValid);

            // Password only
            data.Password = "******";
            Assert.True(data.IsValid);

            using (var keyfile = TestFiles.Read("IO.Demo7Pass.bin"))
            {
                // Password & keyfile
                await data.AddKeyFile(keyfile);

                Assert.True(data.IsValid);
            }

            // Keyfile only
            data.Password = null;
            Assert.True(data.IsValid);

            // Not specified
            data.ClearKeyfile();
            Assert.False(data.IsValid);
        }
示例#2
0
        public async Task AddKeyFile(IStorageFile file)
        {
            KeyfileName = file.Name;
            using (var input = await file.OpenReadAsync())
                await _password.AddKeyFile(input);

            NotifyOfPropertyChange(() => CanOpenDatabase);
            NotifyOfPropertyChange(() => CanClearKeyfile);
            NotifyOfPropertyChange(() => KeyfileGroupVisibility);
        }
示例#3
0
        public async Task Should_support_hex_keyfile()
        {
            using (var input = TestFiles.Read("IO.Demo7Pass.hex"))
            {
                var data = new PasswordData();
                await data.AddKeyFile(input);

                var master = data.GetMasterKey();
                Assert.Equal(
                    "964b383286fba51581e844762576671ba02f62dc9834a0d4954a6d0023d879e8",
                    CryptographicBuffer.EncodeToHexString(master));
            }
        }
示例#4
0
        public async Task Should_support_xml_keyfile()
        {
            using (var input = TestFiles.Read("IO.Demo7Pass.key"))
            {
                var data = new PasswordData();
                await data.AddKeyFile(input);

                var master = data.GetMasterKey();
                Assert.Equal(
                    "2e6f6954faadf36c27b72d93da06a8f541cc54c4d4e84db886c0e06e99ab8e48",
                    CryptographicBuffer.EncodeToHexString(master));
            }
        }
示例#5
0
        public async Task Should_support_random_keyfile()
        {
            using (var input = TestFiles.Read("IO.Demo7Pass.txt"))
            {
                var data = new PasswordData();
                await data.AddKeyFile(input);

                var master = data.GetMasterKey();
                Assert.Equal(
                    "f625b4ef8ccbb16ffcd96bf0742a5bf55e339f826ec103cfa13b1d97d3860c2e",
                    CryptographicBuffer.EncodeToHexString(master));
            }
        }
示例#6
0
        public async Task ClearKeyfile_should_clear_registered_keyfile()
        {
            using (var keyfile = TestFiles.Read("IO.Demo7Pass.bin"))
            {
                var data = new PasswordData();
                await data.AddKeyFile(keyfile);

                Assert.True(data.HasKeyFile);

                data.ClearKeyfile();
                Assert.False(data.HasKeyFile);
            }
        }
示例#7
0
        public async Task Should_support_password_and_keyfile()
        {
            using (var input = TestFiles.Read("IO.Demo7Pass.key"))
            {
                var data = new PasswordData
                {
                    Password = "******",
                };
                await data.AddKeyFile(input);

                var master = data.GetMasterKey();
                Assert.Equal(
                    "f78be10350f04cc87d3f7030eede60e33799c6665316975bb442f8b803bd6baa",
                    CryptographicBuffer.EncodeToHexString(master));
            }
        }