示例#1
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));
            }
        }
示例#2
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));
            }
        }
示例#3
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));
            }
        }
示例#4
0
        public void Should_support_password_only()
        {
            var data = new PasswordData
            {
                Password = "******",
            };

            var master = data.GetMasterKey();

            Assert.Equal(
                "175939018983abcaa4029ba81e61adbaa63f3fabe38bed84a9edd03bea587ade",
                CryptographicBuffer.EncodeToHexString(master));
        }
示例#5
0
        public async Task Should_transform_master_key()
        {
            var data = new PasswordData
            {
                Password = "******",
            };

            var seed = CryptographicBuffer.DecodeFromHexString(
                "9525f6992beb739cbaa73ae6e050627fcaff378d3cd6f6c232d20aa92f6d0927");

            var masterKey = await data.GetMasterKey(seed, 6000);

            Assert.Equal(
                "87730050341ff55c46421f2f2a5f4e1e018d0443d19cacc8682f128f1874d0a4",
                CryptographicBuffer.EncodeToHexString(masterKey));
        }
示例#6
0
        public async Task OpenDatabase()
        {
            var database = await OpenFileAsync();

            using (var fs = await database.OpenReadAsync())
            {
                // TODO: handle errors & display transformation progress
                var result = await FileFormat.Headers(fs);

                var headers = result.Headers;

                var masterKey = await _password
                                .GetMasterKey(headers);

                using (var decrypted = await FileFormat
                                       .Decrypt(fs, masterKey, headers))
                {
                    // TODO: verify start bytes
                    await FileFormat.VerifyStartBytes(
                        decrypted, headers);

                    // Parse content
                    var doc = await FileFormat.ParseContent(
                        decrypted, headers.UseGZip, headers);

                    // TODO: verify headers integrity

                    _cache.Cache(new CachedDatabase
                    {
                        Id       = Id,
                        Document = doc,
                        Name     = DisplayName,
                        Headers  = headers,
                    });

                    _navigation
                    .UriFor <GroupViewModel>()
                    .Navigate();

                    _navigation.BackStack.Remove(
                        _navigation.BackStack.Last());
                }
            }
        }