Argon2KDF write mode works! (thanks to an option in XMLWriterSettings)

This commit is contained in:
BONNEVILLE Geoffroy
2017-11-08 17:52:00 +01:00
parent 29e7b22953
commit 65f2e529f4
9 changed files with 29 additions and 28 deletions

View File

@@ -124,7 +124,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(KeyDerivation.KdfUuid) is Argon2Kdf) return; if (_pwDatabase == null || !_pwDatabase.IsOpen /*|| KdfPool.Get(KeyDerivation.KdfUuid) is Argon2Kdf*/) return;
_pwDatabase.Save(new NullStatusLogger()); _pwDatabase.Save(new NullStatusLogger());
} }

View File

@@ -296,10 +296,6 @@
<HintPath>..\packages\Microsoft.Toolkit.Uwp.Notifications.2.0.0\lib\dotnet\Microsoft.Toolkit.Uwp.Notifications.dll</HintPath> <HintPath>..\packages\Microsoft.Toolkit.Uwp.Notifications.2.0.0\lib\dotnet\Microsoft.Toolkit.Uwp.Notifications.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="ModernKeePassLib, Version=2.37.0.2000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ModernKeePassLib.2.37.5000\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.2.0.0\lib\Portable-Win81+Wpa81\Splat.dll</HintPath> <HintPath>..\packages\Splat.2.0.0\lib\Portable-Win81+Wpa81\Splat.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@@ -360,6 +356,12 @@
<Content Include="Assets\Wide310x150Logo.scale-180.png" /> <Content Include="Assets\Wide310x150Logo.scale-180.png" />
<Content Include="Assets\Wide310x150Logo.scale-80.png" /> <Content Include="Assets\Wide310x150Logo.scale-80.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModernKeePassLib\ModernKeePassLib.csproj">
<Project>{2e710089-9559-4967-846c-e763dd1f3acb}</Project>
<Name>ModernKeePassLib</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' "> <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion> <VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?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"> <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.6.0.27" /> <Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.7.0.27" />
<Properties> <Properties>
<DisplayName>ModernKeePass</DisplayName> <DisplayName>ModernKeePass</DisplayName>
<PublisherDisplayName>wismna</PublisherDisplayName> <PublisherDisplayName>wismna</PublisherDisplayName>

View File

@@ -24,6 +24,6 @@
<TextBlock Text="Compression Algorithm" FontSize="14" Margin="5,20,0,10" /> <TextBlock Text="Compression Algorithm" FontSize="14" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding CompressionName, Mode=TwoWay}" /> <ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding CompressionName, Mode=TwoWay}" />
<TextBlock Text="Key Derivation Algorithm" FontSize="14" Margin="5,20,0,10" /> <TextBlock Text="Key Derivation Algorithm" FontSize="14" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding KeyDerivationName, Mode=TwoWay}" IsEnabled="False" /> <ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding KeyDerivationName, Mode=TwoWay}" />
</StackPanel> </StackPanel>
</Page> </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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.0.0")] [assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")] [assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View File

@@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>ModernKeePassLib</id> <id>ModernKeePassLib</id>
<version>2.37.5000</version> <version>2.37.6000</version>
<title>ModernKeePassLib</title> <title>ModernKeePassLib</title>
<authors>Geoffroy Bonneville</authors> <authors>Geoffroy Bonneville</authors>
<owners>Geoffroy Bonneville</owners> <owners>Geoffroy Bonneville</owners>
@@ -10,7 +10,7 @@
<projectUrl>https://github.com/wismna/ModernKeePass</projectUrl> <projectUrl>https://github.com/wismna/ModernKeePass</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</description> <description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</description>
<releaseNotes>KDBX 4 file format supported</releaseNotes> <releaseNotes>TBD</releaseNotes>
<copyright>Copyright © 2017 Geoffroy Bonneville</copyright> <copyright>Copyright © 2017 Geoffroy Bonneville</copyright>
<tags>KeePass KeePassLib Portable PCL NetStandard</tags> <tags>KeePass KeePassLib Portable PCL NetStandard</tags>
<dependencies> <dependencies>

View File

@@ -26,11 +26,8 @@ using System.IO;
using System.Security; using System.Security;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
#if ModernKeePassLib
using Windows.Security.Cryptography; #if !ModernKeePassLib && !KeePassUAP
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
#else
using System.Security.Cryptography; using System.Security.Cryptography;
#endif #endif
@@ -40,15 +37,15 @@ using System.IO.Compression;
using KeePassLibSD; using KeePassLibSD;
#endif #endif
using ModernKeePassLib.Collections;
using ModernKeePassLib.Cryptography; using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Cipher; using ModernKeePassLib.Cryptography.Cipher;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Interfaces; using ModernKeePassLib.Interfaces;
using ModernKeePassLib.Keys; using ModernKeePassLib.Keys;
using ModernKeePassLib.Resources; using ModernKeePassLib.Resources;
using ModernKeePassLib.Utility;
using ModernKeePassLib.Collections;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Security; using ModernKeePassLib.Security;
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Serialization namespace ModernKeePassLib.Serialization
{ {

View File

@@ -25,9 +25,8 @@ using System.IO;
using System.Security; using System.Security;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
#if ModernKeePassLib
using Windows.Security.Cryptography; #if !ModernKeePassLib && !KeePassUAP
#else
using System.Drawing; using System.Drawing;
using System.Security.Cryptography; using System.Security.Cryptography;
#endif #endif
@@ -41,15 +40,13 @@ using System.IO.Compression;
using ModernKeePassLib.Collections; using ModernKeePassLib.Collections;
using ModernKeePassLib.Cryptography; using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Cipher; using ModernKeePassLib.Cryptography.Cipher;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Delegates; using ModernKeePassLib.Delegates;
using ModernKeePassLib.Interfaces; using ModernKeePassLib.Interfaces;
using ModernKeePassLib.Keys; using ModernKeePassLib.Keys;
using ModernKeePassLib.Resources; using ModernKeePassLib.Resources;
using ModernKeePassLib.Security; using ModernKeePassLib.Security;
using ModernKeePassLib.Utility; using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using ModernKeePassLib.Cryptography.KeyDerivation;
namespace ModernKeePassLib.Serialization namespace ModernKeePassLib.Serialization
{ {
@@ -212,6 +209,11 @@ namespace ModernKeePassLib.Serialization
xws.Indent = true; xws.Indent = true;
xws.IndentChars = "\t"; xws.IndentChars = "\t";
xws.NewLineOnAttributes = false; xws.NewLineOnAttributes = false;
#if ModernKeePassLib
// This is needed for Argon2Kdf write
xws.Async = true;
if (m_uFileVersion >= FileVersion32_4) xws.CloseOutput = true;
#endif
XmlWriter xw = XmlWriter.Create(sXml, xws); XmlWriter xw = XmlWriter.Create(sXml, xws);
#else #else

View File

@@ -519,8 +519,8 @@ namespace ModernKeePassLib.Serialization
byte[] pbData = pb.ReadData(); byte[] pbData = pb.ReadData();
/*var file = FileSystem.Current.GetFileFromPathAsync(strPath).Result; /*var file = FileSystem.Current.GetFileFromPathAsync(strPath).Result;
using (var stream = file.OpenAsync(FileAccess.ReadAndWrite).Result) {*/ using (var stream = file.OpenAsync(FileAccess.ReadAndWrite).Result) {*/
var file = StorageFile.GetFileFromPathAsync(strPath).GetResults(); var file = StorageFile.GetFileFromPathAsync(strPath).GetAwaiter().GetResult();
using (var stream = file.OpenAsync(FileAccessMode.ReadWrite).GetResults().AsStream()) using (var stream = file.OpenAsync(FileAccessMode.ReadWrite).GetAwaiter().GetResult().AsStream())
{ {
stream.Write (pbData, 0, pbData.Length); stream.Write (pbData, 0, pbData.Length);
} }