WIP Lib 2.37 - databases created by ModernKeepass work fine, but no interoperability...

This commit is contained in:
2017-10-23 18:48:46 +02:00
committed by BONNEVILLE Geoffroy
parent 2bbd931b1a
commit 5b31d3ff72
30 changed files with 250 additions and 244 deletions

View File

@@ -253,9 +253,9 @@
<HintPath>..\packages\Microsoft.Toolkit.Uwp.Notifications.2.0.0\lib\dotnet\Microsoft.Toolkit.Uwp.Notifications.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ModernKeePassLib, Version=2.37.0.2000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ModernKeePassLib.2.37.2000\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
<Private>True</Private>
<Reference Include="ModernKeePassLib, Version=2.28.1.4000, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ModernKeePassLib\bin\Debug\ModernKeePassLib.dll</HintPath>
</Reference>
<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>

View File

@@ -3,7 +3,7 @@
<package id="Microsoft.NETCore.Platforms" version="2.0.0" targetFramework="win81" />
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" />
<package id="Microsoft.Toolkit.Uwp.Notifications" version="2.0.0" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.37.2000" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.37.3000" targetFramework="win81" />
<package id="NETStandard.Library" version="2.0.1" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.1.3" targetFramework="win81" />
<package id="Splat" version="2.0.0" targetFramework="win81" />

View File

@@ -1,18 +1,13 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Keys;
#else
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Keys;
#endif
namespace ModernKeePassLib.Test.Shared.Keys
{
[TestFixture ()]
public class CompositeKeyTests
{
[Test ()]
[Test]
public void TestGenerateKey32 ()
{
var originalKey = new byte[32];
@@ -25,7 +20,11 @@ namespace ModernKeePassLib.Test.Shared.Keys
const ulong rounds = 1;
var composite = new CompositeKey ();
var key = composite.GenerateKey32 (originalKey, rounds);
AesKdf kdf = new AesKdf();
KdfParameters p = kdf.GetDefaultParameters();
p.SetUInt64(AesKdf.ParamRounds, rounds);
p.SetByteArray(AesKdf.ParamSeed, originalKey);
var key = composite.GenerateKey32(p);
Assert.That (key, Is.Not.Null);
var keyData = key.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedKey));

View File

@@ -25,7 +25,6 @@ using System.Diagnostics;
using ModernKeePassLib.Interfaces;
using ModernKeePassLib.Security;
using ModernKeePassLib.Utility;
#if KeePassLibSD
using KeePassLibSD;

View File

@@ -122,16 +122,15 @@ namespace ModernKeePassLib.Cryptography.Cipher
Array.Copy(pbKey, pbLocalKey, 32);
#if ModernKeePassLib
AesEngine aes = new AesEngine();
CbcBlockCipher cbc = new CbcBlockCipher(aes);
PaddedBufferedBlockCipher bc = new PaddedBufferedBlockCipher(cbc,
var cbc = new CbcBlockCipher(new AesEngine());
var bc = new PaddedBufferedBlockCipher(cbc,
new Pkcs7Padding());
KeyParameter kp = new KeyParameter(pbLocalKey);
ParametersWithIV prmIV = new ParametersWithIV(kp, pbLocalIV);
var kp = new KeyParameter(pbLocalKey);
var prmIV = new ParametersWithIV(kp, pbLocalIV);
bc.Init(bEncrypt, prmIV);
IBufferedCipher cpRead = (bEncrypt ? null : bc);
IBufferedCipher cpWrite = (bEncrypt ? bc : null);
var cpRead = (bEncrypt ? null : bc);
var cpWrite = (bEncrypt ? bc : null);
return new CipherStream(s, cpRead, cpWrite);
#elif KeePassUAP
return StandardAesEngineExt.CreateStream(s, bEncrypt, pbLocalKey, pbLocalIV);

View File

@@ -19,18 +19,20 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
#if ModernKeePassLib
using Windows.Security.Cryptography;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
#else
using System.Security.Cryptography;
#endif
using System.IO;
using System.Diagnostics;
using System.Globalization;
using ModernKeePassLib.Native;
using ModernKeePassLib.Native;
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Cryptography
{

View File

@@ -20,8 +20,13 @@
using System;
using System.Diagnostics;
#if ModernKeePassLib
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
#elif !KeePassUAP
using System.Security.Cryptography;
#endif
using ModernKeePassLib.Cryptography.Cipher;
using ModernKeePassLib.Utility;

View File

@@ -22,13 +22,17 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using ModernKeePassLib.Cryptography.Hash;
#if ModernKeePassLib
using Org.BouncyCastle.Asn1.Pkcs;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using ModernKeePassLib.Cryptography.Hash;
#elif !KeePassUAP
using System.Security.Cryptography;
#endif
using ModernKeePassLib.Native;
using ModernKeePassLib.Utility;
using Org.BouncyCastle.Asn1.Pkcs;
namespace ModernKeePassLib.Cryptography
{

View File

@@ -21,17 +21,19 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
#if ModernKeePassLib
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
#else
using Org.BouncyCastle.Crypto.Tls;
#elif !KeePassUAP
using System.Security.Cryptography;
#endif
using System.Runtime.InteropServices.ComTypes;
using ModernKeePassLib.Utility;
using Org.BouncyCastle.Crypto.Tls;
namespace ModernKeePassLib.Cryptography
{
@@ -81,8 +83,7 @@ namespace ModernKeePassLib.Cryptography
}
#if ModernKeePassLib
//public HashingStreamEx(Stream sBaseStream, bool bWriting, HashAlgorithm? hashAlgorithm)
public HashingStreamEx(Stream sBaseStream, bool bWriting, string hashAlgorithm)
public HashingStreamEx(Stream sBaseStream, bool bWriting, IDigest hashAlgorithm)
#else
public HashingStreamEx(Stream sBaseStream, bool bWriting, HashAlgorithm hashAlgorithm)
#endif
@@ -94,7 +95,7 @@ namespace ModernKeePassLib.Cryptography
#if ModernKeePassLib
//m_hash = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(hashAlgorithm ?? HashAlgorithm.Sha256).CreateHash();
//m_hash = HashAlgorithmProvider.OpenAlgorithm(hashAlgorithm ?? HashAlgorithmNames.Sha256).CreateHash();
m_hash = new Sha256Digest();
m_hash = hashAlgorithm ?? new Sha256Digest();
#elif !KeePassLibSD
m_hash = (hashAlgorithm ?? new SHA256Managed());
#else // KeePassLibSD
@@ -108,26 +109,24 @@ namespace ModernKeePassLib.Cryptography
if(m_hash == null) { Debug.Assert(false); return; }
// Validate hash algorithm
/*if(!m_hash.CanReuseTransform || !m_hash.CanTransformMultipleBlocks)
#if ModernKeePassLib
#else
if(!m_hash.CanReuseTransform || !m_hash.CanTransformMultipleBlocks)
{
Debug.Assert(false);
m_hash = null;
}*/
}
#endif
}
#if ModernKeePassLib || KeePassRT
protected override void Dispose(bool disposing)
{
if (!disposing) return;
#else
public override void Close()
if(disposing)
{
#endif
if(m_hash != null)
{
try
{
//m_hash.TransformFinalBlock(new byte[0], 0, 0);
#if ModernKeePassLib
//m_pbFinalHash = (m_hash as CryptographicHash).GetValueAndReset ();
//CryptographicBuffer.CopyToByteArray(m_hash.GetValueAndReset(), out m_pbFinalHash);
@@ -135,17 +134,21 @@ namespace ModernKeePassLib.Cryptography
m_hash.DoFinal(m_pbFinalHash, 0);
m_hash.Reset();
#else
m_hash.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
m_pbFinalHash = m_hash.Hash;
#endif
}
catch (Exception)
{
Debug.Assert(false);
catch(Exception) { Debug.Assert(false); }
m_hash = null;
}
m_sBaseStream.Dispose();
}
base.Dispose(disposing);
}
}
public override void Flush()
{
@@ -181,8 +184,11 @@ namespace ModernKeePassLib.Cryptography
#endif
if((m_hash != null) && (nRead > 0))
//m_hash.TransformBlock(pbBuffer, nOffset, nRead, pbBuffer, nOffset);
#if ModernKeePassLib
m_hash.BlockUpdate(pbBuffer, nOffset, nRead);
#else
m_hash.TransformBlock(pbBuffer, nOffset, nRead, pbBuffer, nOffset);
#endif
#if DEBUG
Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg));
@@ -201,8 +207,11 @@ namespace ModernKeePassLib.Cryptography
#endif
if((m_hash != null) && (nCount > 0))
//m_hash.TransformBlock(pbBuffer, nOffset, nCount, pbBuffer, nOffset);
#if ModernKeePassLib
m_hash.BlockUpdate(pbBuffer, nOffset, nCount);
#else
m_hash.TransformBlock(pbBuffer, nOffset, nCount, pbBuffer, nOffset);
#endif
#if DEBUG
Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg));

View File

@@ -19,18 +19,18 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
#if ModernKeePassLib
using Windows.Security.Cryptography;
#else
using Windows.Security.Cryptography.Core;
#elif !KeePassUAP
using System.Security.Cryptography;
#endif
using System.Globalization;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
#if (!KeePassLibSD && !KeePassRT)
#if !KeePassLibSD
namespace ModernKeePassLib.Cryptography
{
/// <summary>
@@ -47,11 +47,15 @@ namespace ModernKeePassLib.Cryptography
byte[] pbText = MemUtil.UInt64ToBytes(uFactor);
Array.Reverse(pbText); // To big-endian
#if ModernKeePassLib
var hsha1 = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1).CreateHash(CryptographicBuffer.CreateFromByteArray(pbSecret));
hsha1.Append(CryptographicBuffer.CreateFromByteArray(pbText));
byte[] pbHash;
CryptographicBuffer.CopyToByteArray(hsha1.GetValueAndReset(), out pbHash);
#else
HMACSHA1 hsha1 = new HMACSHA1(pbSecret);
byte[] pbHash = hsha1.ComputeHash(pbText);
#endif
uint uOffset = (uint)(pbHash[pbHash.Length - 1] & 0xF);
if((iTruncationOffset >= 0) && (iTruncationOffset < (pbHash.Length - 4)))
uOffset = (uint)iTruncationOffset;

View File

@@ -114,7 +114,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
ctx.LaneLength = ctx.SegmentLength * NbSyncPoints;
Debug.Assert(NbBlockSize == (NbBlockSizeInQW *
#if KeePassUAP
#if ModernKeePassLib || KeePassUAP
(ulong)Marshal.SizeOf<ulong>()
#else
(ulong)Marshal.SizeOf(typeof(ulong))

View File

@@ -21,9 +21,14 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Diagnostics;
#if ModernKeePassLib
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
#elif !KeePassUAP
using System.Security.Cryptography;
#endif
using ModernKeePassLib.Security;
using ModernKeePassLib.Utility;
@@ -88,7 +93,6 @@ namespace ModernKeePassLib.Cryptography.PasswordGenerator
byte[] pbHash;
CryptographicBuffer.CopyToByteArray(h, out pbHash);
MemUtil.XorArray(pbHash, 0, pbKey, 0, pbHash.Length);
#else
using(SHA512Managed h = new SHA512Managed())
{

View File

@@ -265,7 +265,7 @@ namespace ModernKeePassLib.Cryptography.PasswordGenerator
else pcs.Add(ch);
}
Array.Clear(vChars, 0, vChars.Length);
MemUtil.ZeroArray<char>(vChars);
MemUtil.ZeroByteArray(pbUtf8);
return pp;
}

View File

@@ -18,32 +18,15 @@
*/
using System;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices.WindowsRuntime;
#if ModernKeePassLib
using Windows.Security.Cryptography;
#else
using System.Security.Cryptography;
#endif
using System.Text;
#if KeePassRT
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
#endif
using ModernKeePassLib.Native;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Resources;
using ModernKeePassLib.Security;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.KeyDerivation;
using Org.BouncyCastle.Crypto.Engines;
using KdfParameters = Org.BouncyCastle.Crypto.Parameters.KdfParameters;
namespace ModernKeePassLib.Keys
{
@@ -119,7 +102,6 @@ namespace ModernKeePassLib.Keys
return m_vUserKeys.Remove(pKey);
}
#if !ModernKeePassLib && !KeePassRT
/// <summary>
/// Test whether the composite key contains a specific type of
/// user keys (password, key file, ...). If at least one user
@@ -137,7 +119,7 @@ namespace ModernKeePassLib.Keys
{
if(pKey == null) { Debug.Assert(false); continue; }
#if KeePassUAP
#if ModernKeePassLib || KeePassUAP
if(pKey.GetType() == tUserKeyType)
return true;
#else
@@ -164,7 +146,7 @@ namespace ModernKeePassLib.Keys
{
if(pKey == null) { Debug.Assert(false); continue; }
#if KeePassUAP
#if ModernKeePassLib || KeePassUAP
if(pKey.GetType() == tUserKeyType)
return pKey;
#else
@@ -175,7 +157,6 @@ namespace ModernKeePassLib.Keys
return null;
}
#endif
/// <summary>
/// Creates the composite key from the supplied user key sources (password,
@@ -236,7 +217,7 @@ namespace ModernKeePassLib.Keys
if(pbKeySeed32.Length != 32) throw new ArgumentException("pbKeySeed32");
AesKdf kdf = new AesKdf();
var p = kdf.GetDefaultParameters();
KdfParameters p = kdf.GetDefaultParameters();
p.SetUInt64(AesKdf.ParamRounds, uNumRounds);
p.SetByteArray(AesKdf.ParamSeed, pbKeySeed32);
@@ -246,7 +227,7 @@ namespace ModernKeePassLib.Keys
/// <summary>
/// Generate a 32-byte (256-bit) key from the composite key.
/// </summary>
public ProtectedBinary GenerateKey32(Cryptography.KeyDerivation.KdfParameters p)
public ProtectedBinary GenerateKey32(KdfParameters p)
{
if(p == null) { Debug.Assert(false); throw new ArgumentNullException("p"); }

View File

@@ -19,18 +19,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
#if ModernKeePassLib
using Windows.Security.Cryptography;
#else
using System.Security.Cryptography;
#endif
using System.Text;
using ModernKeePassLib.Security;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Security;
namespace ModernKeePassLib.Keys
{

View File

@@ -18,26 +18,27 @@
*/
using System;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Xml;
using System.Security;
using System.Text;
using System.Xml;
#if ModernKeePassLib
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
#else
using System.Security.Cryptography;
#endif
using System.Diagnostics;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Resources;
using ModernKeePassLib.Security;
using ModernKeePassLib.Serialization;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLib.Keys
{

View File

@@ -18,17 +18,11 @@
*/
using System;
using System.Text;
using System.Diagnostics;
#if ModernKeePassLib
using Windows.Security.Cryptography;
#else
using System.Security.Cryptography;
#endif
using System.Text;
using ModernKeePassLib.Security;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
using ModernKeePassLib.Cryptography;
namespace ModernKeePassLib.Keys

View File

@@ -21,8 +21,9 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Security;
#if ModernKeePassLib
using Windows.Storage;
#if !KeePassUAP
using Windows.Security.Cryptography;
#endif

View File

@@ -125,7 +125,8 @@
<Compile Include="Serialization\IOConnectionInfo.cs" />
<Compile Include="Serialization\OldFormatException.cs" />
<Compile Include="Utility\AppLogEx.cs" />
<Compile Include="Utility\GfxUtil.cs" />
<None Include="Utility\GfxUtil.cs" />
<Compile Include="Utility\GfxUtil.PCL.cs" />
<Compile Include="Utility\MemUtil.cs" />
<Compile Include="Cryptography\PasswordGenerator\PwGenerator.cs" />
<Compile Include="Utility\MonoWorkaround.PCL.cs" />
@@ -173,6 +174,7 @@
<Reference Include="Windows, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\Windows.winmd</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup />

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,16 +19,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
#if ModernKeePassLib
using System.Threading.Tasks;
#else
using System.Threading;
#endif
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
#if ModernKeePassLib
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Storage.Streams;
#endif
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Resources;
using ModernKeePassLib.Utility;

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,9 +19,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.IO;
using System.Text;
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
using System.Security.AccessControl;

View File

@@ -29,6 +29,7 @@ using ModernKeePassLib.Resources;
using ModernKeePassLib.Utility;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Macs;
using Org.BouncyCastle.Crypto.Parameters;
namespace ModernKeePassLib.Serialization
{
@@ -244,16 +245,17 @@ namespace ModernKeePassLib.Serialization
byte[] pbCmpHmac;
byte[] pbBlockKey = GetHmacKey64(m_pbKey, m_uBlockIndex);
/*#if ModernKeePassLib
#if ModernKeePassLib
var h = new HMac(new Sha256Digest());
h.Init(new KeyParameter(pbBlockKey));
h.BlockUpdate(pbBlockIndex, 0, pbBlockIndex.Length);
h.BlockUpdate(pbBlockSize, 0, pbBlockSize.Length);
if (m_pbBuffer.Length > 0)
h.BlockUpdate(m_pbBuffer, 0, m_pbBuffer.Length);
pbCmpHmac = MemUtil.EmptyByteArray;
h.DoFinal(pbCmpHmac, 0);
h.Reset();
#else*/
#else
using(HMACSHA256 h = new HMACSHA256(pbBlockKey))
{
h.TransformBlock(pbBlockIndex, 0, pbBlockIndex.Length,
@@ -269,7 +271,7 @@ namespace ModernKeePassLib.Serialization
pbCmpHmac = h.Hash;
}
//#endif
#endif
MemUtil.ZeroByteArray(pbBlockKey);
if(!MemUtil.ArraysEqual(pbCmpHmac, pbStoredHmac))
@@ -317,16 +319,18 @@ namespace ModernKeePassLib.Serialization
byte[] pbBlockHmac;
byte[] pbBlockKey = GetHmacKey64(m_pbKey, m_uBlockIndex);
/*#if ModernKeePassLib
#if ModernKeePassLib
var h = new HMac(new Sha256Digest());
h.Init(new KeyParameter(pbBlockKey));
h.BlockUpdate(pbBlockIndex, 0, pbBlockIndex.Length);
h.BlockUpdate(pbBlockSize, 0, pbBlockSize.Length);
if (m_pbBuffer.Length > 0)
h.BlockUpdate(m_pbBuffer, 0, m_pbBuffer.Length);
if (cbBlockSize > 0)
h.BlockUpdate(m_pbBuffer, 0, cbBlockSize);
pbBlockHmac = MemUtil.EmptyByteArray;
h.DoFinal(pbBlockHmac, 0);
h.Reset();
#else*/
#else
using(HMACSHA256 h = new HMACSHA256(pbBlockKey))
{
h.TransformBlock(pbBlockIndex, 0, pbBlockIndex.Length,
@@ -341,7 +345,7 @@ namespace ModernKeePassLib.Serialization
pbBlockHmac = h.Hash;
}
//#endif
#endif
MemUtil.ZeroByteArray(pbBlockKey);
MemUtil.Write(m_sBase, pbBlockHmac);

View File

@@ -1,13 +1,12 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -19,24 +18,27 @@
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Diagnostics;
using Windows.Storage.Streams;
using System.Threading.Tasks;
using ModernKeePassLib.Native;
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
using System.Reflection;
using System.Text;
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassUAP)
using System.Net.Cache;
using System.Net.Security;
#endif
#if !ModernKeePassLib && !KeePassRT
#if !ModernKeePassLib && !KeePassUAP
using System.Security.Cryptography.X509Certificates;
#endif
#if ModernKeePassLib
using Windows.Storage;
using Windows.Storage.Streams;
#endif
using ModernKeePassLib.Native;
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Serialization
@@ -44,10 +46,17 @@ namespace ModernKeePassLib.Serialization
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
internal sealed class IOWebClient : WebClient
{
private IOConnectionInfo m_ioc;
public IOWebClient(IOConnectionInfo ioc) : base()
{
m_ioc = ioc;
}
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
IOConnection.ConfigureWebRequest(request);
IOConnection.ConfigureWebRequest(request, m_ioc);
return request;
}
}

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,12 +19,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml.Serialization;
#if ModernKeePassLib
using Windows.Storage;
//using PCLStorage;
@@ -338,13 +337,13 @@ namespace ModernKeePassLib.Serialization
public StorageFile StorageFile { get; set; }
public async Task<bool> CanProbablyAccess()
public bool CanProbablyAccess()
{
#if ModernKeePassLib
if (IsLocalFile())
{
//return (FileSystem.Current.GetFileFromPathAsync(m_strUrl).Result != null);
var file = await StorageFile.GetFileFromPathAsync(m_strUrl);
var file = StorageFile.GetFileFromPathAsync(m_strUrl).GetAwaiter().GetResult();
return file != null;
}
#else

View File

@@ -25,8 +25,6 @@ using System.Text;
using System.Security;
using System.Drawing;
using System.Xml;
using System.IO;
using System.Diagnostics;
using ModernKeePassLib;
using ModernKeePassLib.Collections;

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,18 +17,22 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// #define KDBX_BENCHMARK
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.IO;
using System.Security;
using System.Text;
using System.Xml;
#if ModernKeePassLib
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
#else
using System.Security.Cryptography;
#endif
using System.Xml;
#if !KeePassLibSD
using System.IO.Compression;
@@ -42,8 +46,6 @@ using ModernKeePassLib.Interfaces;
using ModernKeePassLib.Keys;
using ModernKeePassLib.Resources;
using ModernKeePassLib.Utility;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using ModernKeePassLib.Collections;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Security;

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,23 +19,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Security;
using System.Text;
using System.Xml;
#if ModernKeePassLib
using Windows.Security.Cryptography;
#else
using System.Drawing;
using System.Security.Cryptography;
#endif
using System.Drawing;
using System.Globalization;
using System.Diagnostics;
#if !KeePassLibSD
using System.IO.Compression;
#else
#if KeePassLibSD
using KeePassLibSD;
#else
using System.IO.Compression;
#endif
using ModernKeePassLib.Collections;

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,20 +19,17 @@
using System;
using System.Collections.Generic;
using System.Xml;
using System.Text;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Diagnostics;
using System.Security;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
#if !KeePassLibSD
using System.IO.Compression;
#endif
using System.Text;
using System.Xml;
#if ModernKeePassLib
using Windows.Storage;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
#endif
using ModernKeePassLib.Collections;
@@ -207,11 +204,7 @@ namespace ModernKeePassLib.Serialization
private PwDatabase m_pwDatabase; // Not null, see constructor
private bool m_bUsedOnce = false;
#if ModernKeePassLib
private XmlWriter m_xmlWriter = null;
#else
private XmlTextWriter m_xmlWriter = null;
#endif
private CryptoRandomStream m_randomStream = null;
private KdbxFormat m_format = KdbxFormat.Default;
private IStatusLogger m_slLogger = null;
@@ -525,7 +518,6 @@ namespace ModernKeePassLib.Serialization
++iTry;
}
#if ModernKeePassLib
//while(FileSystem.Current.GetFileFromPathAsync(strPath).Result != null);
while (StorageFile.GetFileFromPathAsync(strPath).GetResults() != null);
#else
while(File.Exists(strPath));

View File

@@ -0,0 +1,22 @@
using System.IO;
using System.Threading.Tasks;
using Splat;
namespace ModernKeePassLib.Utility
{
public class GfxUtil
{
public static async Task<IBitmap> LoadImage(byte[] pb)
{
return await ScaleImage(pb, null, null);
}
public static async Task<IBitmap> ScaleImage(byte[] pb, int? w, int? h)
{
using (var ms = new MemoryStream(pb, false))
{
return await BitmapLoader.Current.Load(ms, w, h);
}
}
}
}

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,16 +19,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
#if ModernKeePassLib
using Splat;
#else
using System.Text;
#if !KeePassUAP
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
#endif
using System.Diagnostics;
using System.Threading.Tasks;
namespace ModernKeePassLib.Utility
{
@@ -68,19 +67,6 @@ namespace ModernKeePassLib.Utility
try { return Image.FromStream(ms); }
finally { ms.Close(); }
}
#elif ModernKeePassLib
public static async Task<IBitmap> LoadImage(byte[] pb)
{
return await ScaleImage(pb, null, null);
}
public static async Task<IBitmap> ScaleImage(byte[] pb, int? w, int? h)
{
using (var ms = new MemoryStream(pb, false))
{
return await BitmapLoader.Current.Load(ms, w, h);
}
}
#else
public static Image LoadImage(byte[] pb)
{
@@ -437,8 +423,7 @@ namespace ModernKeePassLib.Utility
#endif // DEBUG
#endif // !KeePassLibSD
#endif // KeePassUAP
#if ModernKeePassLib
#else
internal static string ImageToDataUri(Image img)
{
if(img == null) { Debug.Assert(false); return string.Empty; }
@@ -452,6 +437,5 @@ namespace ModernKeePassLib.Utility
return StrUtil.DataToDataUri(pb, "image/png");
}
#endif
}
}