Ejemplo n.º 1
0
 public KeyGenerator(ICanSHA256Hash hasher, 
     IKeyTransformer keyTransformer, 
     CompositeKey compositeKey, 
     IProgress<double> progress)
 {             
     _hasher = hasher;
     _keyTransformer = keyTransformer;
     _compositeKey = compositeKey;
     _progress = progress;
 }
Ejemplo n.º 2
0
        public async void Save()
        {
            CanSave = false;
            var databaseXDocument = GenerateDatabase.NewDatabase();
            var parser = new Kdb4Parser(null);
            var passwordKey = await KcpPassword.Create(Password, new SHA256HasherRT());

            var compositeKey = new CompositeKey(new List<IUserKey> { passwordKey }, new NullableProgress<double>());
            var pwDatabase = new PwDatabase(compositeKey);



            pwDatabase.Tree = parser.ParseXmlDocument(databaseXDocument);
            pwDatabase.DataCipherUuid = new PwUuid(new byte[]{
						0x31, 0xC1, 0xF2, 0xE6, 0xBF, 0x71, 0x43, 0x50,
						0xBE, 0x58, 0x05, 0x21, 0x6A, 0xFC, 0x5A, 0xFF });


            if (await _pageServices.EnsureUnsnapped())
            {
                FileSavePicker saver = new FileSavePicker();
                saver.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                saver.SuggestedFileName = this.Name;
                saver.FileTypeChoices.Add(".kdbx", new List<string> { ".kdbx" });
                var storageFile = await saver.PickSaveFileAsync();

                if (storageFile != null)
                {

                    _dataSource.PwDatabase = pwDatabase;
                    _dataSource.StorageFile = storageFile;
                    await _dataSource.SavePwDatabase();
                    var encodedUUID = _dataSource.PwDatabase.Tree.Group.UUID;
                    _navigationService.UriFor<EntryGroupListViewModel>().WithParam(vm => vm.GroupId, encodedUUID).Navigate();
                }
            }


        }
Ejemplo n.º 3
0
 public PwDatabase(CompositeKey masterKey)
 {
     MasterKey = masterKey;
 }
Ejemplo n.º 4
0
        private async void NavigateToCreateDemo(object obj)
        {
            var databaseXDocument = GenerateDatabase.NewDatabase();
            var parser = new Kdb4Parser(null);
            var passwordKey = await KcpPassword.Create("demo", _hasher);

            var compositeKey = new CompositeKey(new List<IUserKey> { passwordKey }, new NullableProgress<double>());
            var pwDatabase = new PwDatabase(compositeKey);



            pwDatabase.Tree = parser.ParseXmlDocument(databaseXDocument);
            pwDatabase.DataCipherUuid = new PwUuid(new byte[]{
						0x31, 0xC1, 0xF2, 0xE6, 0xBF, 0x71, 0x43, 0x50,
						0xBE, 0x58, 0x05, 0x21, 0x6A, 0xFC, 0x5A, 0xFF });


            _databaseSource.PwDatabase = pwDatabase;

            await _databaseInfoRepository.SaveDatabaseFromDatasouce("demo.kdbx", "", "", new MemoryStream());
            var databaseInfo = await _databaseInfoRepository.GetDatabaseInfo("demo.kdbx");

            _databaseSource.StorageFile = await databaseInfo.GetDatabase();
            await _databaseSource.SavePwDatabase();

            _dialogService.ShowDialogBox("Demo information", "The password to the database is 'demo'");

            _navigationService.GoBack();
        }