10 Commits
V1.7 ... V1.8

Author SHA1 Message Date
BONNEVILLE Geoffroy
abb12accc7 Correct two bugs related to key file opening
Bettter error messages with composite key
Show an error message if save has failed and don't close the database
2017-11-13 11:28:14 +01:00
2779e5b7c7 Updated README.md 2017-11-09 16:54:43 +00:00
3970d485f6 Updated README.md 2017-11-09 16:53:47 +00:00
BONNEVILLE Geoffroy
7b888cc4a2 Merge branch 'master' of https://geogeob.visualstudio.com/_git/ModernKeePass 2017-11-09 13:46:15 +01:00
BONNEVILLE Geoffroy
117513d6bf Correct credits in About 2017-11-09 13:46:10 +01:00
97511ab290 Updated README.md 2017-11-09 12:43:41 +00:00
3131eca8a1 Updated README.md 2017-11-09 12:39:55 +00:00
91a5507217 Added file README.md 2017-11-09 11:16:13 +00:00
7d904b7120 Updated README.md 2017-11-09 11:08:46 +00:00
BONNEVILLE Geoffroy
be72fc4f7e Minor change for Designer 2017-11-08 18:52:48 +01:00
12 changed files with 116 additions and 45 deletions

View File

@@ -14,6 +14,9 @@ namespace ModernKeePass.Common
{
public enum DatabaseStatus
{
Error = -3,
NoCompositeKey = -2,
CompositeKeyError = -1,
Closed = 0,
Opening = 1,
Opened = 2
@@ -77,11 +80,11 @@ namespace ModernKeePass.Common
/// <param name="key">The database composite key</param>
/// <param name="createNew">True to create a new database before opening it</param>
/// <returns>An error message, if any</returns>
public string Open(CompositeKey key, bool createNew = false)
public void Open(CompositeKey key, bool createNew = false)
{
try
{
if (key == null) return "No composite key";
if (key == null) Status = DatabaseStatus.NoCompositeKey;
var ioConnection = IOConnectionInfo.FromFile(DatabaseFile);
if (createNew) _pwDatabase.New(ioConnection, key);
else _pwDatabase.Open(ioConnection, key, new NullStatusLogger());
@@ -92,19 +95,14 @@ namespace ModernKeePass.Common
RootGroup = new GroupVm(_pwDatabase.RootGroup, null, RecycleBinEnabled ? _pwDatabase.RecycleBinUuid : null);
}
}
catch (ArgumentNullException)
{
return "Password cannot be empty";
}
catch (InvalidCompositeKeyException)
{
return "Wrong password";
Status = DatabaseStatus.CompositeKeyError;
}
catch (Exception ex)
{
return ex.Message;
Status = DatabaseStatus.Error;
}
return string.Empty;
}
/// <summary>
@@ -121,11 +119,19 @@ namespace ModernKeePass.Common
/// <summary>
/// Commit the changes to the currently opened database to file
/// </summary>
public void Save()
public bool Save()
{
if (_pwDatabase == null || !_pwDatabase.IsOpen) return false;
try
{
// TODO: Save is disabled for now for Argon2Kdf because it corrupts DB (read works)
if (_pwDatabase == null || !_pwDatabase.IsOpen /*|| KdfPool.Get(KeyDerivation.KdfUuid) is Argon2Kdf*/) return;
_pwDatabase.Save(new NullStatusLogger());
return true;
}
catch (Exception ex)
{
MessageDialogHelper.ShowErrorDialog(ex);
}
return false;
}
/// <summary>

View File

@@ -23,5 +23,17 @@ namespace ModernKeePass.Common
// Show the message dialog
await messageDialog.ShowAsync();
}
public static async void ShowErrorDialog(Exception exception)
{
// Create the message dialog and set its content
var messageDialog = new MessageDialog(exception.Message, "Error occured");
// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
messageDialog.Commands.Add(new UICommand("OK"));
// Show the message dialog
await messageDialog.ShowAsync();
}
}
}

View File

@@ -47,7 +47,7 @@
Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushConverter}}"
Visibility="{Binding ShowComplexityIndicator, ElementName=UserControl, Converter={StaticResource BooleanToVisibilityConverter}}" />
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding HasKeyFile, Mode=TwoWay}" />
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0" Content="Select key file from disk..." IsEnabled="{Binding HasKeyFile}" Click="KeyFileButton_Click" />
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0" Content="{Binding KeyFileText}" IsEnabled="{Binding HasKeyFile}" Click="KeyFileButton_Click" />
<Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" Background="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" IsEnabled="{Binding IsValid}" />
<TextBlock Grid.Column="1" Grid.Row="2" Height="28" FontSize="14" FontWeight="Light" HorizontalAlignment="Right" Text="{Binding Status}" Foreground="{Binding StatusType, Converter={StaticResource DiscreteIntToSolidColorBrushConverter}}" />
</Grid>

View File

@@ -3,7 +3,6 @@ using Windows.Storage.Pickers;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
using ModernKeePass.Common;
using ModernKeePass.Events;
using ModernKeePass.ViewModels;
@@ -56,7 +55,7 @@ namespace ModernKeePass.Controls
ValidationChecking?.Invoke(this, new EventArgs());
if (UpdateKey) Model.UpdateKey();
else if (Model.OpenDatabase(CreateNew) == DatabaseHelper.DatabaseStatus.Opened)
else if (Model.OpenDatabase(CreateNew))
{
ValidationChecked?.Invoke(this, new PasswordEventArgs(Model.RootGroup));
}
@@ -78,7 +77,9 @@ namespace ModernKeePass.Controls
picker.FileTypeFilter.Add(".key");
// Application now has read/write access to the picked file
Model.KeyFile = await picker.PickSingleFileAsync();
var file = await picker.PickSingleFileAsync();
if (file == null) return;
Model.KeyFile = file;
}
}
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.7.0.28" />
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.8.0.28" />
<Properties>
<DisplayName>ModernKeePass</DisplayName>
<PublisherDisplayName>wismna</PublisherDisplayName>

View File

@@ -32,7 +32,7 @@
<Run Text="Dominik Reichl for the KeePass application and file format"/>
</TextBlock>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Margin="30,0,0,0">
<Run Text="ArtjomP for his PCL adapatation of the KeePass Library"/>
<Run Text="David Lechner for his PCL adapatation of the KeePass Library and his correlated tests"/>
</TextBlock>
</StackPanel>
</Page>

View File

@@ -24,6 +24,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: ComVisible(false)]

View File

@@ -1,4 +1,5 @@
using Windows.Storage;
using System.Text;
using Windows.Storage;
using Windows.UI.Xaml;
using ModernKeePass.Common;
using ModernKeePassLib.Cryptography;
@@ -24,6 +25,7 @@ namespace ModernKeePass.ViewModels
private string _status;
private StatusTypes _statusType;
private StorageFile _keyFile;
private string _keyFileText = "Select key file from disk...";
public bool HasPassword
{
@@ -45,7 +47,7 @@ namespace ModernKeePass.ViewModels
}
}
public bool IsValid => HasPassword || HasKeyFile;
public bool IsValid => HasPassword || HasKeyFile && KeyFile != null;
public string Status
{
@@ -76,18 +78,37 @@ namespace ModernKeePass.ViewModels
set
{
_keyFile = value;
UpdateStatus($"Key file: {value.Name}", StatusTypes.Normal);
KeyFileText = value?.Name;
OnPropertyChanged("IsValid");
}
}
public string KeyFileText
{
get { return _keyFileText; }
set { SetProperty(ref _keyFileText, value); }
}
public GroupVm RootGroup { get; set; }
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password?.ToCharArray());
public DatabaseHelper.DatabaseStatus OpenDatabase(bool createNew)
public bool OpenDatabase(bool createNew)
{
UpdateStatus(_app.Database.Open(CreateCompositeKey(), createNew), StatusTypes.Error);
_app.Database.Open(CreateCompositeKey(), createNew);
switch (_app.Database.Status)
{
case DatabaseHelper.DatabaseStatus.Opened:
RootGroup = _app.Database.RootGroup;
return _app.Database.Status;
return true;
case DatabaseHelper.DatabaseStatus.CompositeKeyError:
var errorMessage = new StringBuilder("Error: wrong ");
if (HasPassword) errorMessage.Append("password");
if (HasPassword && HasKeyFile) errorMessage.Append(" or ");
if (HasKeyFile) errorMessage.Append("key file");
UpdateStatus(errorMessage.ToString(), StatusTypes.Error);
break;
}
return false;
}
public void UpdateKey()

View File

@@ -91,7 +91,7 @@ namespace ModernKeePass.ViewModels
public SettingsDatabaseVm()
{
Groups = _app.Database.RootGroup.Groups;
Groups = _app?.Database.RootGroup.Groups;
}
// TODO: Move to another setting class (or a static class)

View File

@@ -8,9 +8,7 @@ namespace ModernKeePass.ViewModels
public void Save(bool close = true)
{
var app = (App)Application.Current;
app.Database.Save();
if (!close) return;
app.Database.Close();
if (close && app.Database.Save()) app.Database.Close();
}
internal void Save(StorageFile file)

View File

@@ -0,0 +1,13 @@
# ModernKeePassLib
This is my adaptation of the KeePassLib (KeePass library) for the Universal Windows Platform and Windows Runtime (WinRT).
It aims at introducing as little change as possible to the original library: overall, except for namespace changes and some added classes (see below), there is almost no change.
Download the Nuget package [here](https://www.nuget.org/packages/ModernKeePassLib)
# Features
- Custom implementation of the System.Security.Cryptography.HashAlgoritm class by using WinRT equivalents
- Use of BouncyCastle PCL to implement AES key derivation features
- Lots of small changes in .NET methods (UTF8 instead of ASCII, string.)
- Disabled native functions (because not compatible with WinRT)
- Use of Splat for GfxUtil

View File

@@ -1,20 +1,40 @@
# Introduction
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
**ModernKeePass** is port of the classic Windows application KeePass 2.x for the Windows Store.
It does not aim to be feature perfect, but aims at being simple to use and user-friendly.
# Getting Started
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
1. Installation process
2. Software dependencies
3. Latest releases
4. API references
You can get it [here](https://www.microsoft.com/fr-fr/store/p/modernkeepass/9mwq48zk8nhv?rtc=1)
# Features
- Works on Windows 10, 8.1 and RT
- Read and write support of KDBX files version 2, 3 and 4
- Open database with password and key file
- Create new databases
- Create, edit and delete groups
- Create, edit and delete entries
- Generate passwords for entries
- Use Recycle Bin
- Search entries
- Use Semantic Zoom to see your entries in a grouped mode
- List recently opened databases
- Open database from Windows Explorer
- Change database encryption
- Change database compression
- Change database key derivation
- Displays entry colors and icons (set in KeePass)
# Build and Test
TODO: Describe and show how to build your code and run the tests.
1. Clone the repository
2. Build the main app (the library reference dll is actually a NuGet dependency, built from the [**ModernKeePassLib** project](../ModernKeePassLib/README.md))
# Contribute
TODO: Explain how other users and developers can contribute to make your code better.
I'm not the best at creating nice assets, so if anyone would like to contribute some nice icons, it would be awesome :)
Otherwise, there are still many things left to implement:
- Entry custom fields
- Multi entry selection (for delete, or move)
- Move entries from a group to another
- Create key files
- Open database from URL (and maybe some clouds?)
If you want to learn more about creating good readme files then refer the following [guidelines](https://www.visualstudio.com/en-us/docs/git/create-a-readme). You can also seek inspiration from the below readme files:
- [ASP.NET Core](https://github.com/aspnet/Home)
- [Visual Studio Code](https://github.com/Microsoft/vscode)
- [Chakra Core](https://github.com/Microsoft/ChakraCore)
# Credits
*Dominik Reichl* for the [KeePass application](https://keepass.info/), library and file format
*David Lechner* for his [PCL adapatation](https://github.com/dlech/KeePass2PCL) of the KeePass Library and the correlated tests which served as an inspiration basis for my own adaptation