mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Open database control button is now purple to be more visible
WIP Argon2KDF - still no luck in saving => disabled for now
This commit is contained in:
@@ -3,7 +3,6 @@ using Windows.Storage;
|
|||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
using ModernKeePassLib;
|
using ModernKeePassLib;
|
||||||
using ModernKeePassLib.Cryptography.Cipher;
|
|
||||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||||
using ModernKeePassLib.Interfaces;
|
using ModernKeePassLib.Interfaces;
|
||||||
using ModernKeePassLib.Keys;
|
using ModernKeePassLib.Keys;
|
||||||
@@ -129,7 +128,7 @@ namespace ModernKeePass.Common
|
|||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
// TODO: Save is disabled for now for Argon2Kdf because it corrupts DB (read works)
|
// TODO: Save is disabled for now for Argon2Kdf because it corrupts DB (read works)
|
||||||
if (_pwDatabase == null || !_pwDatabase.IsOpen || KdfPool.Get(_pwDatabase.KdfParameters.KdfUuid) is Argon2Kdf) return;
|
if (_pwDatabase == null || !_pwDatabase.IsOpen || KdfPool.Get(KeyDerivation.KdfUuid) is Argon2Kdf) return;
|
||||||
_pwDatabase.Save(new NullStatusLogger());
|
_pwDatabase.Save(new NullStatusLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,16 +24,16 @@
|
|||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<CheckBox x:Name="PasswordCheckBox" Grid.Row="0" Grid.Column="0" />
|
<CheckBox x:Name="PasswordCheckBox" Grid.Row="0" Grid.Column="0" />
|
||||||
<PasswordBox Grid.Row="0" Grid.Column="1" x:Name="PasswordBox" Password="{Binding Password, ElementName=UserControl, Mode=TwoWay}" Height="30" IsEnabled="{Binding IsChecked, ElementName=PasswordCheckBox}" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" >
|
<PasswordBox Grid.Row="0" Grid.Column="1" x:Name="PasswordBox" Password="{Binding Password, ElementName=UserControl, Mode=TwoWay}" Height="30" IsEnabled="{Binding IsChecked, ElementName=PasswordCheckBox}" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" >
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:DataTriggerBehavior Binding="{Binding Visibility, ElementName=UserControl}" Value="Visible">
|
<core:DataTriggerBehavior Binding="{Binding IsChecked, ElementName=PasswordCheckBox}" Value="True">
|
||||||
<actions:SetupFocusAction TargetObject="{Binding ElementName=PasswordBox}" />
|
<actions:SetupFocusAction TargetObject="{Binding ElementName=PasswordBox}" />
|
||||||
</core:DataTriggerBehavior>
|
</core:DataTriggerBehavior>
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</PasswordBox>
|
</PasswordBox>
|
||||||
<CheckBox x:Name="KeyFileCheckBox" Grid.Row="1" Grid.Column="0" />
|
<CheckBox x:Name="KeyFileCheckBox" Grid.Row="1" Grid.Column="0" />
|
||||||
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-10,0,0,0" Content="Select key file from disk..." IsEnabled="{Binding IsChecked, ElementName=KeyFileCheckBox}" Click="KeyFileButton_Click" />
|
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0" Content="Select key file from disk..." IsEnabled="{Binding IsChecked, ElementName=KeyFileCheckBox}" Click="KeyFileButton_Click" />
|
||||||
<Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" />
|
<Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" Background="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" />
|
||||||
<TextBlock Grid.Column="1" Grid.Row="2" x:Name="StatusTextBlock" Height="28" FontSize="14" FontWeight="Light" TextWrapping="WrapWholeWords" HorizontalAlignment="Right" />
|
<TextBlock Grid.Column="1" Grid.Row="2" x:Name="StatusTextBlock" Height="28" FontSize="14" FontWeight="Light" TextWrapping="WrapWholeWords" HorizontalAlignment="Right" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security;
|
|
||||||
using ModernKeePassLib.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
using ModernKeePassLib.Cryptography.Cipher;
|
using ModernKeePassLib.Cryptography.Cipher;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
@@ -1,50 +1,38 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using Windows.UI;
|
|
||||||
#if KeePassLib
|
|
||||||
using KeePassLib;
|
|
||||||
using KeePassLib.Keys;
|
|
||||||
using KeePassLib.Security;
|
|
||||||
using KeePassLib.Serialization;
|
|
||||||
using KeePassLib.Collections;
|
|
||||||
#else
|
|
||||||
using ModernKeePassLib;
|
|
||||||
using ModernKeePassLib.Keys;
|
using ModernKeePassLib.Keys;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
using ModernKeePassLib.Serialization;
|
using ModernKeePassLib.Serialization;
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Test.Serialization
|
namespace ModernKeePassLib.Test.Serialization
|
||||||
{
|
{
|
||||||
[TestFixture()]
|
[TestFixture()]
|
||||||
public class KdbxFileTests
|
public class KdbxFileTests
|
||||||
{
|
{
|
||||||
const string testLocalizedAppName = "My Localized App Name";
|
const string TestLocalizedAppName = "My Localized App Name";
|
||||||
|
|
||||||
const string testDatabaseName = "My Database Name";
|
const string TestDatabaseName = "My Database Name";
|
||||||
const string testDatabaseDescription = "My Database Description";
|
const string TestDatabaseDescription = "My Database Description";
|
||||||
const string testDefaultUserName = "My Default User Name";
|
const string TestDefaultUserName = "My Default User Name";
|
||||||
const string testColor = "#FF0000"; // Red
|
const string TestColor = "#FF0000"; // Red
|
||||||
|
|
||||||
const string testRootGroupName = "My Root Group Name";
|
const string TestRootGroupName = "My Root Group Name";
|
||||||
const string testRootGroupNotes = "My Root Group Notes";
|
const string TestRootGroupNotes = "My Root Group Notes";
|
||||||
const string testRootGroupDefaultAutoTypeSequence = "My Root Group Default Auto Type Sequence";
|
const string TestRootGroupDefaultAutoTypeSequence = "My Root Group Default Auto Type Sequence";
|
||||||
|
|
||||||
const string testDatabase = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n" +
|
const string TestDatabase = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n" +
|
||||||
"<KeePassFile>\r\n" +
|
"<KeePassFile>\r\n" +
|
||||||
"\t<Meta>\r\n" +
|
"\t<Meta>\r\n" +
|
||||||
"\t\t<Generator>" + testLocalizedAppName + "</Generator>\r\n" +
|
"\t\t<Generator>" + TestLocalizedAppName + "</Generator>\r\n" +
|
||||||
"\t\t<DatabaseName>" + testDatabaseName + "</DatabaseName>\r\n" +
|
"\t\t<DatabaseName>" + TestDatabaseName + "</DatabaseName>\r\n" +
|
||||||
"\t\t<DatabaseNameChanged>2017-10-23T08:03:55Z</DatabaseNameChanged>\r\n" +
|
"\t\t<DatabaseNameChanged>2017-10-23T08:03:55Z</DatabaseNameChanged>\r\n" +
|
||||||
"\t\t<DatabaseDescription>" + testDatabaseDescription + "</DatabaseDescription>\r\n" +
|
"\t\t<DatabaseDescription>" + TestDatabaseDescription + "</DatabaseDescription>\r\n" +
|
||||||
"\t\t<DatabaseDescriptionChanged>2017-10-23T08:03:55Z</DatabaseDescriptionChanged>\r\n" +
|
"\t\t<DatabaseDescriptionChanged>2017-10-23T08:03:55Z</DatabaseDescriptionChanged>\r\n" +
|
||||||
"\t\t<DefaultUserName>" + testDefaultUserName + "</DefaultUserName>\r\n" +
|
"\t\t<DefaultUserName>" + TestDefaultUserName + "</DefaultUserName>\r\n" +
|
||||||
"\t\t<DefaultUserNameChanged>2017-10-23T08:03:55Z</DefaultUserNameChanged>\r\n" +
|
"\t\t<DefaultUserNameChanged>2017-10-23T08:03:55Z</DefaultUserNameChanged>\r\n" +
|
||||||
"\t\t<MaintenanceHistoryDays>365</MaintenanceHistoryDays>\r\n" +
|
"\t\t<MaintenanceHistoryDays>365</MaintenanceHistoryDays>\r\n" +
|
||||||
//"\t\t<Color>" + testColor + "</Color>\r\n" +
|
//"\t\t<Color>" + testColor + "</Color>\r\n" +
|
||||||
@@ -74,8 +62,8 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
"\t<Root>\r\n" +
|
"\t<Root>\r\n" +
|
||||||
"\t\t<Group>\r\n" +
|
"\t\t<Group>\r\n" +
|
||||||
"\t\t\t<UUID>AAAAAAAAAAAAAAAAAAAAAA==</UUID>\r\n" +
|
"\t\t\t<UUID>AAAAAAAAAAAAAAAAAAAAAA==</UUID>\r\n" +
|
||||||
"\t\t\t<Name>" + testRootGroupName + "</Name>\r\n" +
|
"\t\t\t<Name>" + TestRootGroupName + "</Name>\r\n" +
|
||||||
"\t\t\t<Notes>" + testRootGroupNotes + "</Notes>\r\n" +
|
"\t\t\t<Notes>" + TestRootGroupNotes + "</Notes>\r\n" +
|
||||||
"\t\t\t<IconID>49</IconID>\r\n" +
|
"\t\t\t<IconID>49</IconID>\r\n" +
|
||||||
"\t\t\t<Times>\r\n" +
|
"\t\t\t<Times>\r\n" +
|
||||||
"\t\t\t\t<CreationTime>2017-10-23T08:03:55Z</CreationTime>\r\n" +
|
"\t\t\t\t<CreationTime>2017-10-23T08:03:55Z</CreationTime>\r\n" +
|
||||||
@@ -87,7 +75,7 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
"\t\t\t\t<LocationChanged>2017-10-23T08:03:55Z</LocationChanged>\r\n" +
|
"\t\t\t\t<LocationChanged>2017-10-23T08:03:55Z</LocationChanged>\r\n" +
|
||||||
"\t\t\t</Times>\r\n" +
|
"\t\t\t</Times>\r\n" +
|
||||||
"\t\t\t<IsExpanded>True</IsExpanded>\r\n" +
|
"\t\t\t<IsExpanded>True</IsExpanded>\r\n" +
|
||||||
"\t\t\t<DefaultAutoTypeSequence>" + testRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
|
"\t\t\t<DefaultAutoTypeSequence>" + TestRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
|
||||||
"\t\t\t<EnableAutoType>null</EnableAutoType>\r\n" +
|
"\t\t\t<EnableAutoType>null</EnableAutoType>\r\n" +
|
||||||
"\t\t\t<EnableSearching>null</EnableSearching>\r\n" +
|
"\t\t\t<EnableSearching>null</EnableSearching>\r\n" +
|
||||||
"\t\t\t<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>\r\n" +
|
"\t\t\t<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>\r\n" +
|
||||||
@@ -96,13 +84,13 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
"\t</Root>\r\n" +
|
"\t</Root>\r\n" +
|
||||||
"</KeePassFile>";
|
"</KeePassFile>";
|
||||||
|
|
||||||
const string testDate = "2017-10-23T08:03:55Z";
|
const string TestDate = "2017-10-23T08:03:55Z";
|
||||||
|
|
||||||
[Test()]
|
[Test()]
|
||||||
public void TestLoad()
|
public void TestLoad()
|
||||||
{
|
{
|
||||||
var database = new PwDatabase();
|
var database = new PwDatabase();
|
||||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(testDatabase)))
|
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(TestDatabase)))
|
||||||
{
|
{
|
||||||
var file = new KdbxFile(database);
|
var file = new KdbxFile(database);
|
||||||
file.Load(ms, KdbxFormat.PlainXml, null);
|
file.Load(ms, KdbxFormat.PlainXml, null);
|
||||||
@@ -121,23 +109,23 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
{
|
{
|
||||||
var database = new PwDatabase();
|
var database = new PwDatabase();
|
||||||
database.New(new IOConnectionInfo(), new CompositeKey());
|
database.New(new IOConnectionInfo(), new CompositeKey());
|
||||||
var date = DateTime.Parse(testDate, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);
|
var date = DateTime.Parse(TestDate, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);
|
||||||
//var date = DateTime.UtcNow;
|
//var date = DateTime.UtcNow;
|
||||||
PwDatabase.LocalizedAppName = testLocalizedAppName;
|
PwDatabase.LocalizedAppName = TestLocalizedAppName;
|
||||||
database.Name = testDatabaseName;
|
database.Name = TestDatabaseName;
|
||||||
database.NameChanged = date;
|
database.NameChanged = date;
|
||||||
database.Description = testDatabaseDescription;
|
database.Description = TestDatabaseDescription;
|
||||||
database.DescriptionChanged = date;
|
database.DescriptionChanged = date;
|
||||||
database.DefaultUserName = testDefaultUserName;
|
database.DefaultUserName = TestDefaultUserName;
|
||||||
database.DefaultUserNameChanged = date;
|
database.DefaultUserNameChanged = date;
|
||||||
//database.Color = Color.Red;
|
//database.Color = Color.Red;
|
||||||
database.MasterKeyChanged = date;
|
database.MasterKeyChanged = date;
|
||||||
database.RecycleBinChanged = date;
|
database.RecycleBinChanged = date;
|
||||||
database.EntryTemplatesGroupChanged = date;
|
database.EntryTemplatesGroupChanged = date;
|
||||||
database.RootGroup.Uuid = PwUuid.Zero;
|
database.RootGroup.Uuid = PwUuid.Zero;
|
||||||
database.RootGroup.Name = testRootGroupName;
|
database.RootGroup.Name = TestRootGroupName;
|
||||||
database.RootGroup.Notes = testRootGroupNotes;
|
database.RootGroup.Notes = TestRootGroupNotes;
|
||||||
database.RootGroup.DefaultAutoTypeSequence = testRootGroupDefaultAutoTypeSequence;
|
database.RootGroup.DefaultAutoTypeSequence = TestRootGroupDefaultAutoTypeSequence;
|
||||||
database.RootGroup.CreationTime = date;
|
database.RootGroup.CreationTime = date;
|
||||||
database.RootGroup.LastModificationTime = date;
|
database.RootGroup.LastModificationTime = date;
|
||||||
database.RootGroup.LastAccessTime = date;
|
database.RootGroup.LastAccessTime = date;
|
||||||
@@ -154,14 +142,14 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
// so it uses native line endings.
|
// so it uses native line endings.
|
||||||
fileContents = fileContents.Replace("\n", "\r\n");
|
fileContents = fileContents.Replace("\n", "\r\n");
|
||||||
}
|
}
|
||||||
Assert.That(fileContents, Is.EqualTo(testDatabase));
|
Assert.That(fileContents, Is.EqualTo(TestDatabase));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSearch()
|
public void TestSearch()
|
||||||
{
|
{
|
||||||
var database = new PwDatabase();
|
var database = new PwDatabase();
|
||||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(testDatabase)))
|
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(TestDatabase)))
|
||||||
{
|
{
|
||||||
var file = new KdbxFile(database);
|
var file = new KdbxFile(database);
|
||||||
file.Load(ms, KdbxFormat.PlainXml, null);
|
file.Load(ms, KdbxFormat.PlainXml, null);
|
||||||
|
@@ -35,6 +35,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography.Hash;
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
@@ -468,6 +469,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
|
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
Task.Factory.StartNew(FillSegmentThr, ti);
|
Task.Factory.StartNew(FillSegmentThr, ti);
|
||||||
|
//ThreadPool.RunAsync(a => FillSegmentThr(ti));
|
||||||
#else
|
#else
|
||||||
if(!ThreadPool.QueueUserWorkItem(FillSegmentThr, ti))
|
if(!ThreadPool.QueueUserWorkItem(FillSegmentThr, ti))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user