mirror of
https://github.com/wismna/ModernKeePassLib.git
synced 2025-10-03 15:40:20 -04:00
Downgrade to net standard 1.2
This commit is contained in:
@@ -29,7 +29,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestEncryptStream()
|
public void TestEncryptStream()
|
||||||
{
|
{
|
||||||
var a = CryptoUtil.CreateAes();
|
/*var a = CryptoUtil.CreateAes();
|
||||||
if (a.BlockSize != 128) // AES block size
|
if (a.BlockSize != 128) // AES block size
|
||||||
{
|
{
|
||||||
//Debug.Assert(false);
|
//Debug.Assert(false);
|
||||||
@@ -44,7 +44,20 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
|
|||||||
|
|
||||||
iCrypt.TransformBlock(_pbTestData, 0, 16, _pbTestData, 0);
|
iCrypt.TransformBlock(_pbTestData, 0, 16, _pbTestData, 0);
|
||||||
|
|
||||||
Assert.That(MemUtil.ArraysEqual(_pbTestData, _pbReferenceCt), Is.True);
|
Assert.That(MemUtil.ArraysEqual(_pbTestData, _pbReferenceCt), Is.True);*/
|
||||||
|
|
||||||
|
using var outStream = new MemoryStream();
|
||||||
|
var aes = new StandardAesEngine();
|
||||||
|
|
||||||
|
using var inStream = aes.EncryptStream(outStream, _pbTestKey, _pbIv);
|
||||||
|
new BinaryWriter(inStream, Encoding.UTF8).Write(_pbTestData);
|
||||||
|
|
||||||
|
//Assert.That(outStream.Position, Is.EqualTo(16));
|
||||||
|
|
||||||
|
//outStream.Position = 0;
|
||||||
|
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
|
||||||
|
|
||||||
|
Assert.That(MemUtil.ArraysEqual(outBytes, _pbReferenceCt), Is.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -55,8 +68,10 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
|
|||||||
inStream.Write(_pbReferenceCt, 0, _pbReferenceCt.Length);
|
inStream.Write(_pbReferenceCt, 0, _pbReferenceCt.Length);
|
||||||
inStream.Position = 0;
|
inStream.Position = 0;
|
||||||
var aes = new StandardAesEngine();
|
var aes = new StandardAesEngine();
|
||||||
|
|
||||||
using var outStream = aes.DecryptStream(inStream, _pbTestKey, _pbIv);
|
using var outStream = aes.DecryptStream(inStream, _pbTestKey, _pbIv);
|
||||||
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
|
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
|
||||||
|
|
||||||
Assert.That(MemUtil.ArraysEqual(outBytes, _pbTestData), Is.True);
|
Assert.That(MemUtil.ArraysEqual(outBytes, _pbTestData), Is.True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
|||||||
using ModernKeePassLib.Keys;
|
using ModernKeePassLib.Keys;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
using Windows.Storage;
|
using Windows.Storage;
|
||||||
using Windows.Storage.Streams;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace ModernKeePassLib.Test.Keys
|
namespace ModernKeePassLib.Test.Keys
|
||||||
|
@@ -6,6 +6,10 @@
|
|||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DefineConstants>TRACE;ModernKeePassLib</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0-preview-20200310-03" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0-preview-20200310-03" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
@@ -13,11 +17,12 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Splat" Version="3.0.0" />
|
||||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
|
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ModernKeePassLib\ModernKeePassLib.csproj" />
|
<ProjectReference Include="..\ModernKeePassLib\ModernKeePass.Lib.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@@ -95,7 +95,7 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
var file = new KdbxFile(database);
|
var file = new KdbxFile(database);
|
||||||
file.Load(ms, KdbxFormat.PlainXml, null);
|
file.Load(ms, KdbxFormat.PlainXml, null);
|
||||||
}
|
}
|
||||||
Assert.That(database.Color.ToArgb(), Is.EqualTo(Color.Red.ToArgb()));
|
//Assert.That(database.Color.ToArgb(), Is.EqualTo(Color.Red.ToArgb()));
|
||||||
Assert.That(database.Compression, Is.EqualTo(PwCompressionAlgorithm.GZip));
|
Assert.That(database.Compression, Is.EqualTo(PwCompressionAlgorithm.GZip));
|
||||||
//Assert.That (database.CustomData, Is.EqualTo ());
|
//Assert.That (database.CustomData, Is.EqualTo ());
|
||||||
Assert.True(database.CustomIcons.Count == 0);
|
Assert.True(database.CustomIcons.Count == 0);
|
||||||
@@ -118,7 +118,7 @@ namespace ModernKeePassLib.Test.Serialization
|
|||||||
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;
|
||||||
|
@@ -1,71 +1,31 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29009.5
|
VisualStudioVersion = 16.0.29911.84
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernKeePassLib", "ModernKeePassLib\ModernKeePassLib.csproj", "{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePass.Lib", "ModernKeePassLib\ModernKeePass.Lib.csproj", "{2E710089-9559-4967-846C-E763DD1F3ACB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{4797E768-279A-493A-B21B-CD96AB1F8C20}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{25A15ECA-3648-47B2-97DF-491D69126231}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|ARM = Debug|ARM
|
|
||||||
Debug|ARM64 = Debug|ARM64
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Debug|x86 = Debug|x86
|
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
Release|ARM = Release|ARM
|
|
||||||
Release|ARM64 = Release|ARM64
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
Release|x86 = Release|x86
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2E710089-9559-4967-846C-E763DD1F3ACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2E710089-9559-4967-846C-E763DD1F3ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{2E710089-9559-4967-846C-E763DD1F3ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|ARM.Build.0 = Debug|Any CPU
|
{2E710089-9559-4967-846C-E763DD1F3ACB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
{25A15ECA-3648-47B2-97DF-491D69126231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|ARM64.Build.0 = Debug|Any CPU
|
{25A15ECA-3648-47B2-97DF-491D69126231}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{25A15ECA-3648-47B2-97DF-491D69126231}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|x64.Build.0 = Debug|Any CPU
|
{25A15ECA-3648-47B2-97DF-491D69126231}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|ARM.ActiveCfg = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|ARM.Build.0 = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|ARM64.ActiveCfg = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|ARM64.Build.0 = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{15A7E2E5-2B46-4975-AFBD-2898E47E5BA1}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|ARM.Build.0 = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|ARM64.Build.0 = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|ARM.ActiveCfg = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|ARM.Build.0 = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|ARM64.ActiveCfg = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|ARM64.Build.0 = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{4797E768-279A-493A-B21B-CD96AB1F8C20}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {57DC80FC-1822-4F0A-9BA0-7BC823DA9521}
|
SolutionGuid = {5BB1D946-0C93-4219-997F-C2532F355FAE}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
8
ModernKeePassLib/Cryptography/Cipher/CryptoStreamMode.cs
Normal file
8
ModernKeePassLib/Cryptography/Cipher/CryptoStreamMode.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace ModernKeePassLib.Cryptography.Cipher
|
||||||
|
{
|
||||||
|
public enum CryptoStreamMode
|
||||||
|
{
|
||||||
|
Write,
|
||||||
|
Read
|
||||||
|
}
|
||||||
|
}
|
@@ -24,17 +24,17 @@ using System.IO;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if ModernKeePassLib
|
||||||
|
using ModernKeePassLib.Resources;
|
||||||
|
#else
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Resources;
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography.Cipher
|
namespace ModernKeePassLib.Cryptography.Cipher
|
||||||
{
|
{
|
||||||
public sealed class StandardAesEngine : ICipherEngine
|
public sealed class StandardAesEngine : ICipherEngine
|
||||||
{
|
{
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib && !KeePassUAP
|
||||||
private const CipherMode SaeCipherMode = CipherMode.CBC;
|
private const CipherMode SaeCipherMode = CipherMode.CBC;
|
||||||
private const PaddingMode SaePaddingMode = PaddingMode.PKCS7;
|
private const PaddingMode SaePaddingMode = PaddingMode.PKCS7;
|
||||||
#endif
|
#endif
|
||||||
@@ -97,7 +97,7 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
|||||||
{
|
{
|
||||||
StandardAesEngine.ValidateArguments(s, bEncrypt, pbKey, pbIV);
|
StandardAesEngine.ValidateArguments(s, bEncrypt, pbKey, pbIV);
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
return StandardAesEngineExt.CreateStream(s, bEncrypt, pbKey, pbIV);
|
return StandardAesEngineExt.CreateStream(s, bEncrypt, pbKey, pbIV);
|
||||||
#else
|
#else
|
||||||
SymmetricAlgorithm a = CryptoUtil.CreateAes();
|
SymmetricAlgorithm a = CryptoUtil.CreateAes();
|
||||||
|
26
ModernKeePassLib/Cryptography/Cipher/StandardAesEngineExt.cs
Normal file
26
ModernKeePassLib/Cryptography/Cipher/StandardAesEngineExt.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System.IO;
|
||||||
|
using Org.BouncyCastle.Crypto.Engines;
|
||||||
|
using Org.BouncyCastle.Crypto.IO;
|
||||||
|
using Org.BouncyCastle.Crypto.Modes;
|
||||||
|
using Org.BouncyCastle.Crypto.Paddings;
|
||||||
|
using Org.BouncyCastle.Crypto.Parameters;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Cipher
|
||||||
|
{
|
||||||
|
public class StandardAesEngineExt
|
||||||
|
{
|
||||||
|
internal static Stream CreateStream(Stream s, bool bEncrypt, byte[] pbKey, byte[] pbIV)
|
||||||
|
{
|
||||||
|
var cbc = new CbcBlockCipher(new AesEngine());
|
||||||
|
//var cbc = new CbcBlockCipher(new RijndaelEngine());
|
||||||
|
var bc = new PaddedBufferedBlockCipher(cbc, new Pkcs7Padding());
|
||||||
|
var kp = new KeyParameter(pbKey);
|
||||||
|
var prmIV = new ParametersWithIV(kp, pbIV);
|
||||||
|
bc.Init(bEncrypt, prmIV);
|
||||||
|
|
||||||
|
var cpRead = bEncrypt ? null : bc;
|
||||||
|
var cpWrite = bEncrypt ? bc : null;
|
||||||
|
return new CipherStream(s, cpRead, cpWrite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -23,12 +23,11 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
#if ModernKeePassLib
|
||||||
#if !KeePassUAP
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
using System.Drawing;
|
using Windows.Security.Cryptography;
|
||||||
|
#else
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
|
||||||
#if !ModernKeePassLib
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -190,7 +189,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
fI32(Environment.TickCount);
|
fI32(Environment.TickCount);
|
||||||
fI64(DateTime.UtcNow.ToBinary());
|
fI64(DateTime.UtcNow.ToBinary());
|
||||||
|
|
||||||
#if !KeePassLibSD && !ModernKeePassLib
|
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||||
// In try-catch for systems without GUI;
|
// In try-catch for systems without GUI;
|
||||||
// https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/
|
// https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/
|
||||||
try
|
try
|
||||||
@@ -207,19 +206,20 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
fI32((int)NativeLib.GetPlatformID());
|
fI32((int)NativeLib.GetPlatformID());
|
||||||
#if KeePassUAP
|
#if KeePassUAP
|
||||||
fStr(EnvironmentExt.OSVersion.VersionString);
|
fStr(EnvironmentExt.OSVersion.VersionString);
|
||||||
#else
|
#elif !ModernKeePassLib
|
||||||
fStr(Environment.OSVersion.VersionString);
|
fStr(Environment.OSVersion.VersionString);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fI32(Environment.ProcessorCount);
|
fI32(Environment.ProcessorCount);
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib && !KeePassUAP
|
||||||
fStr(Environment.CommandLine);
|
fStr(Environment.CommandLine);
|
||||||
fI64(Environment.WorkingSet);
|
fI64(Environment.WorkingSet);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
|
|
||||||
|
#if !ModernKeePassLib
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach(DictionaryEntry de in Environment.GetEnvironmentVariables())
|
foreach(DictionaryEntry de in Environment.GetEnvironmentVariables())
|
||||||
@@ -229,12 +229,13 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if KeePassUAP
|
#if KeePassUAP
|
||||||
f(DiagnosticsExt.GetProcessEntropy(), true);
|
f(DiagnosticsExt.GetProcessEntropy(), true);
|
||||||
#elif !KeePassLibSD
|
#elif !KeePassLibSD && !ModernKeePassLib
|
||||||
using(Process p = Process.GetCurrentProcess())
|
using(Process p = Process.GetCurrentProcess())
|
||||||
{
|
{
|
||||||
fI64(p.Handle.ToInt64());
|
fI64(p.Handle.ToInt64());
|
||||||
@@ -281,6 +282,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
{
|
{
|
||||||
byte[] pb = new byte[32];
|
byte[] pb = new byte[32];
|
||||||
|
|
||||||
|
|
||||||
try { m_rng.GetBytes(pb); }
|
try { m_rng.GetBytes(pb); }
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
|
@@ -20,7 +20,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if ModernKeePassLib
|
||||||
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib && !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography
|
namespace ModernKeePassLib.Cryptography
|
||||||
|
@@ -23,8 +23,10 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using ModernKeePassLib.Cryptography.Cipher;
|
||||||
#if !KeePassUAP
|
#if ModernKeePassLib
|
||||||
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -105,6 +107,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
return pbHash;
|
return pbHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ModernKeePassLib
|
||||||
internal static byte[] HashSha256(string strFilePath)
|
internal static byte[] HashSha256(string strFilePath)
|
||||||
{
|
{
|
||||||
byte[] pbHash = null;
|
byte[] pbHash = null;
|
||||||
@@ -120,6 +123,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
|
|
||||||
return pbHash;
|
return pbHash;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a cryptographic key of length <paramref name="cbOut" />
|
/// Create a cryptographic key of length <paramref name="cbOut" />
|
||||||
@@ -181,7 +185,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
return pbRet;
|
return pbRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib
|
||||||
private static bool? g_obAesCsp = null;
|
private static bool? g_obAesCsp = null;
|
||||||
public static SymmetricAlgorithm CreateAes()
|
public static SymmetricAlgorithm CreateAes()
|
||||||
{
|
{
|
||||||
|
@@ -23,9 +23,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if ModernKeePassLib
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -33,8 +35,14 @@ using ModernKeePassLib.Utility;
|
|||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography.Hash
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
{
|
{
|
||||||
public sealed class Blake2b : HashAlgorithm
|
public sealed class Blake2b : IDisposable
|
||||||
{
|
{
|
||||||
|
protected int HashSizeValue;
|
||||||
|
protected internal byte[] HashValue;
|
||||||
|
protected int State = 0;
|
||||||
|
|
||||||
|
private bool m_bDisposed = false;
|
||||||
|
|
||||||
private const int NbRounds = 12;
|
private const int NbRounds = 12;
|
||||||
private const int NbBlockBytes = 128;
|
private const int NbBlockBytes = 128;
|
||||||
private const int NbMaxOutBytes = 64;
|
private const int NbMaxOutBytes = 64;
|
||||||
@@ -72,6 +80,23 @@ namespace ModernKeePassLib.Cryptography.Hash
|
|||||||
private ulong[] m_m = new ulong[16];
|
private ulong[] m_m = new ulong[16];
|
||||||
private ulong[] m_v = new ulong[16];
|
private ulong[] m_v = new ulong[16];
|
||||||
|
|
||||||
|
public int HashSize
|
||||||
|
{
|
||||||
|
get { return HashSizeValue; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Hash
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_bDisposed)
|
||||||
|
throw new ObjectDisposedException(null);
|
||||||
|
if (State != 0)
|
||||||
|
throw new InvalidOperationException("Blak2B Cryptography Hash Not Yet Finalized");
|
||||||
|
return (byte[])HashValue.Clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Blake2b()
|
public Blake2b()
|
||||||
{
|
{
|
||||||
m_cbHashLength = NbMaxOutBytes;
|
m_cbHashLength = NbMaxOutBytes;
|
||||||
@@ -91,7 +116,7 @@ namespace ModernKeePassLib.Cryptography.Hash
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
Debug.Assert(m_h.Length == g_vIV.Length);
|
Debug.Assert(m_h.Length == g_vIV.Length);
|
||||||
Array.Copy(g_vIV, m_h, m_h.Length);
|
Array.Copy(g_vIV, m_h, m_h.Length);
|
||||||
@@ -166,7 +191,7 @@ namespace ModernKeePassLib.Cryptography.Hash
|
|||||||
if(m_t[0] < cb) ++m_t[1];
|
if(m_t[0] < cb) ++m_t[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
private void HashCore(byte[] array, int ibStart, int cbSize)
|
||||||
{
|
{
|
||||||
Debug.Assert(m_f[0] == 0);
|
Debug.Assert(m_f[0] == 0);
|
||||||
|
|
||||||
@@ -201,7 +226,7 @@ namespace ModernKeePassLib.Cryptography.Hash
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override byte[] HashFinal()
|
private byte[] HashFinal()
|
||||||
{
|
{
|
||||||
if(m_f[0] != 0) { Debug.Assert(false); throw new InvalidOperationException(); }
|
if(m_f[0] != 0) { Debug.Assert(false); throw new InvalidOperationException(); }
|
||||||
Debug.Assert(((m_t[1] == 0) && (m_t[0] == 0)) ||
|
Debug.Assert(((m_t[1] == 0) && (m_t[0] == 0)) ||
|
||||||
@@ -228,5 +253,142 @@ namespace ModernKeePassLib.Cryptography.Hash
|
|||||||
MemUtil.ZeroByteArray(pbHash);
|
MemUtil.ZeroByteArray(pbHash);
|
||||||
return pbShort;
|
return pbShort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(Stream inputStream)
|
||||||
|
{
|
||||||
|
if (m_bDisposed)
|
||||||
|
throw new ObjectDisposedException(null);
|
||||||
|
|
||||||
|
// Default the buffer size to 4K.
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
bytesRead = inputStream.Read(buffer, 0, 4096);
|
||||||
|
if (bytesRead > 0)
|
||||||
|
{
|
||||||
|
HashCore(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} while (bytesRead > 0);
|
||||||
|
|
||||||
|
HashValue = HashFinal();
|
||||||
|
byte[] Tmp = (byte[])HashValue.Clone();
|
||||||
|
Initialize();
|
||||||
|
return (Tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(byte[] buffer)
|
||||||
|
{
|
||||||
|
if (m_bDisposed)
|
||||||
|
throw new ObjectDisposedException(null);
|
||||||
|
|
||||||
|
// Do some validation
|
||||||
|
if (buffer == null) throw new ArgumentNullException("buffer");
|
||||||
|
|
||||||
|
HashCore(buffer, 0, buffer.Length);
|
||||||
|
HashValue = HashFinal();
|
||||||
|
byte[] Tmp = (byte[])HashValue.Clone();
|
||||||
|
Initialize();
|
||||||
|
return (Tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
// Do some validation
|
||||||
|
if (buffer == null)
|
||||||
|
throw new ArgumentNullException("buffer");
|
||||||
|
if (offset < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("offset", "ArgumentOutOfRange_NeedNonNegNum");
|
||||||
|
if (count < 0 || (count > buffer.Length))
|
||||||
|
throw new ArgumentException("Argument_InvalidValue");
|
||||||
|
if ((buffer.Length - count) < offset)
|
||||||
|
throw new ArgumentException("Argument_InvalidOffLen");
|
||||||
|
|
||||||
|
if (m_bDisposed)
|
||||||
|
throw new ObjectDisposedException(null);
|
||||||
|
|
||||||
|
HashCore(buffer, offset, count);
|
||||||
|
HashValue = HashFinal();
|
||||||
|
byte[] Tmp = (byte[])HashValue.Clone();
|
||||||
|
Initialize();
|
||||||
|
return (Tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||||
|
{
|
||||||
|
// Do some validation, we let BlockCopy do the destination array validation
|
||||||
|
if (inputBuffer == null)
|
||||||
|
throw new ArgumentNullException("inputBuffer");
|
||||||
|
if (inputOffset < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("inputOffset", "ArgumentOutOfRange_NeedNonNegNum");
|
||||||
|
if (inputCount < 0 || (inputCount > inputBuffer.Length))
|
||||||
|
throw new ArgumentException("Argument_InvalidValue");
|
||||||
|
if ((inputBuffer.Length - inputCount) < inputOffset)
|
||||||
|
throw new ArgumentException("Argument_InvalidOffLen");
|
||||||
|
|
||||||
|
if (m_bDisposed)
|
||||||
|
throw new ObjectDisposedException(null);
|
||||||
|
|
||||||
|
// Change the State value
|
||||||
|
State = 1;
|
||||||
|
HashCore(inputBuffer, inputOffset, inputCount);
|
||||||
|
if ((outputBuffer != null) && ((inputBuffer != outputBuffer) || (inputOffset != outputOffset)))
|
||||||
|
Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
|
||||||
|
return inputCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||||
|
{
|
||||||
|
// Do some validation
|
||||||
|
if (inputBuffer == null)
|
||||||
|
throw new ArgumentNullException("inputBuffer");
|
||||||
|
if (inputOffset < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("inputOffset", "ArgumentOutOfRange_NeedNonNegNum");
|
||||||
|
if (inputCount < 0 || (inputCount > inputBuffer.Length))
|
||||||
|
throw new ArgumentException("Argument_InvalidValue");
|
||||||
|
if ((inputBuffer.Length - inputCount) < inputOffset)
|
||||||
|
throw new ArgumentException("Argument_InvalidOffLen");
|
||||||
|
|
||||||
|
if (m_bDisposed)
|
||||||
|
throw new ObjectDisposedException(null);
|
||||||
|
|
||||||
|
HashCore(inputBuffer, inputOffset, inputCount);
|
||||||
|
HashValue = HashFinal();
|
||||||
|
byte[] outputBytes;
|
||||||
|
if (inputCount != 0)
|
||||||
|
{
|
||||||
|
outputBytes = new byte[inputCount];
|
||||||
|
Array.Copy(inputBuffer, inputOffset, outputBytes, 0, inputCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outputBytes = MemUtil.EmptyByteArray;
|
||||||
|
}
|
||||||
|
// reset the State value
|
||||||
|
State = 0;
|
||||||
|
return outputBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
(this as IDisposable).Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
if (HashValue != null)
|
||||||
|
Array.Clear(HashValue, 0, HashValue.Length);
|
||||||
|
HashValue = null;
|
||||||
|
m_bDisposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
62
ModernKeePassLib/Cryptography/Hash/HMAC.cs
Normal file
62
ModernKeePassLib/Cryptography/Hash/HMAC.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using Org.BouncyCastle.Crypto.Macs;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
|
{
|
||||||
|
public class HMAC : IDisposable
|
||||||
|
{
|
||||||
|
protected HMac Hmac;
|
||||||
|
|
||||||
|
public byte[] Hash
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var result = new byte[Hmac.GetMacSize()];
|
||||||
|
Hmac.DoFinal(result, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(byte[] value)
|
||||||
|
{
|
||||||
|
return ComputeHash(value, 0, value.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(byte[] value, int offset, int length)
|
||||||
|
{
|
||||||
|
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
byte[] resBuf = new byte[Hmac.GetMacSize()];
|
||||||
|
Hmac.BlockUpdate(value, offset, length);
|
||||||
|
Hmac.DoFinal(resBuf, offset);
|
||||||
|
|
||||||
|
return resBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||||
|
{
|
||||||
|
Hmac.BlockUpdate(inputBuffer, inputOffset, inputCount);
|
||||||
|
if ((outputBuffer != null) && ((inputBuffer != outputBuffer) || (inputOffset != outputOffset)))
|
||||||
|
Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||||
|
{
|
||||||
|
Hmac.BlockUpdate(inputBuffer, inputOffset, inputCount);
|
||||||
|
byte[] outputBytes = new byte[inputCount];
|
||||||
|
if (inputCount != 0)
|
||||||
|
Buffer.BlockCopy(inputBuffer, inputOffset, outputBytes, 0, inputCount);
|
||||||
|
return outputBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
Hmac.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Hmac.Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
ModernKeePassLib/Cryptography/Hash/HMACSHA1.cs
Normal file
10
ModernKeePassLib/Cryptography/Hash/HMACSHA1.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Windows.Security.Cryptography.Core;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
|
{
|
||||||
|
public class HMACSHA1: HashAlgorithm
|
||||||
|
{
|
||||||
|
public HMACSHA1(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1).CreateHash(key.AsBuffer())) {}
|
||||||
|
}
|
||||||
|
}
|
10
ModernKeePassLib/Cryptography/Hash/HMACSHA256.cs
Normal file
10
ModernKeePassLib/Cryptography/Hash/HMACSHA256.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Windows.Security.Cryptography.Core;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
|
{
|
||||||
|
public class HMACSHA256: HashAlgorithm
|
||||||
|
{
|
||||||
|
public HMACSHA256(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(key.AsBuffer())) {}
|
||||||
|
}
|
||||||
|
}
|
105
ModernKeePassLib/Cryptography/Hash/HashAlgorithm.cs
Normal file
105
ModernKeePassLib/Cryptography/Hash/HashAlgorithm.cs
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Windows.Security.Cryptography.Core;
|
||||||
|
using Validation;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
|
{
|
||||||
|
public abstract class HashAlgorithm: IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The platform-specific hash object.
|
||||||
|
/// </summary>
|
||||||
|
private readonly CryptographicHash _hash;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="HashAlgorithm"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hash">The platform hash.</param>
|
||||||
|
internal HashAlgorithm(CryptographicHash hash)
|
||||||
|
{
|
||||||
|
Requires.NotNull(hash, "Hash");
|
||||||
|
_hash = hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanReuseTransform => true;
|
||||||
|
public bool CanTransformMultipleBlocks => true;
|
||||||
|
|
||||||
|
public byte[] Hash => _hash.GetValueAndReset().ToArray();
|
||||||
|
|
||||||
|
public void Append(byte[] data)
|
||||||
|
{
|
||||||
|
_hash.Append(data.AsBuffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetValueAndReset()
|
||||||
|
{
|
||||||
|
return _hash.GetValueAndReset().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ICryptoTransform methods
|
||||||
|
|
||||||
|
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||||
|
{
|
||||||
|
byte[] buffer;
|
||||||
|
if (inputCount < inputBuffer.Length)
|
||||||
|
{
|
||||||
|
buffer = new byte[inputCount];
|
||||||
|
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer = inputBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
Append(buffer);
|
||||||
|
if (outputBuffer != null)
|
||||||
|
{
|
||||||
|
Array.Copy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||||
|
{
|
||||||
|
this.TransformBlock(inputBuffer, inputOffset, inputCount, null, 0);
|
||||||
|
if (inputCount == inputBuffer.Length)
|
||||||
|
{
|
||||||
|
return inputBuffer;
|
||||||
|
}
|
||||||
|
var buffer = new byte[inputCount];
|
||||||
|
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(byte[] value)
|
||||||
|
{
|
||||||
|
return ComputeHash(value, 0, value.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ComputeHash(byte[] value, int offset, int length)
|
||||||
|
{
|
||||||
|
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
TransformFinalBlock(value, offset, length);
|
||||||
|
var resBuf = GetValueAndReset();
|
||||||
|
|
||||||
|
return resBuf;
|
||||||
|
}
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
_hash.GetValueAndReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
9
ModernKeePassLib/Cryptography/Hash/SHA256Managed.cs
Normal file
9
ModernKeePassLib/Cryptography/Hash/SHA256Managed.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Windows.Security.Cryptography.Core;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
|
{
|
||||||
|
public class SHA256Managed : HashAlgorithm
|
||||||
|
{
|
||||||
|
public SHA256Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256).CreateHash()) {}
|
||||||
|
}
|
||||||
|
}
|
10
ModernKeePassLib/Cryptography/Hash/SHA512Managed.cs
Normal file
10
ModernKeePassLib/Cryptography/Hash/SHA512Managed.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using Windows.Security.Cryptography.Core;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography.Hash
|
||||||
|
{
|
||||||
|
public class SHA512Managed: HashAlgorithm
|
||||||
|
{
|
||||||
|
public SHA512Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512).CreateHash()) {}
|
||||||
|
}
|
||||||
|
}
|
@@ -22,8 +22,9 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
#if ModernKeePassLib
|
||||||
#if !KeePassUAP
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -21,8 +21,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
#if ModernKeePassLib
|
||||||
#if !KeePassUAP
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
using Org.BouncyCastle.Crypto;
|
using Org.BouncyCastle.Crypto;
|
||||||
using Org.BouncyCastle.Crypto.Engines;
|
using Org.BouncyCastle.Crypto.Engines;
|
||||||
using Org.BouncyCastle.Crypto.Parameters;
|
using Org.BouncyCastle.Crypto.Parameters;
|
||||||
@@ -122,6 +122,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if !ModernKeePassLib
|
#if !ModernKeePassLib
|
||||||
|
// Try to use the native library first
|
||||||
if(NativeLib.TransformKey256(pbNewKey, pbKeySeed32, uNumRounds))
|
if(NativeLib.TransformKey256(pbNewKey, pbKeySeed32, uNumRounds))
|
||||||
return CryptoUtil.HashSha256(pbNewKey);
|
return CryptoUtil.HashSha256(pbNewKey);
|
||||||
#endif
|
#endif
|
||||||
@@ -140,18 +141,16 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
public static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
public static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
||||||
ulong uNumRounds)
|
ulong uNumRounds)
|
||||||
{
|
{
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
KeyParameter kp = new KeyParameter(pbKeySeed32);
|
KeyParameter kp = new KeyParameter(pbKeySeed32);
|
||||||
AesEngine aes = new AesEngine();
|
AesEngine aes = new AesEngine();
|
||||||
aes.Init(true, kp);
|
aes.Init(true, kp);
|
||||||
|
|
||||||
for(ulong u = 0; u < uNumRounds; ++u)
|
for(ulong i = 0; i < uNumRounds; ++i)
|
||||||
{
|
{
|
||||||
aes.ProcessBlock(pbNewKey32, 0, pbNewKey32, 0);
|
aes.ProcessBlock(pbNewKey32, 0, pbNewKey32, 0);
|
||||||
aes.ProcessBlock(pbNewKey32, 16, pbNewKey32, 16);
|
aes.ProcessBlock(pbNewKey32, 16, pbNewKey32, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
aes.Reset();
|
|
||||||
#else
|
#else
|
||||||
byte[] pbIV = new byte[16];
|
byte[] pbIV = new byte[16];
|
||||||
|
|
||||||
@@ -213,7 +212,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
pbNewKey[i] = (byte)i;
|
pbNewKey[i] = (byte)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
KeyParameter kp = new KeyParameter(pbKey);
|
KeyParameter kp = new KeyParameter(pbKey);
|
||||||
AesEngine aes = new AesEngine();
|
AesEngine aes = new AesEngine();
|
||||||
aes.Init(true, kp);
|
aes.Init(true, kp);
|
||||||
@@ -248,7 +247,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
{
|
{
|
||||||
for(ulong j = 0; j < BenchStep; ++j)
|
for(ulong j = 0; j < BenchStep; ++j)
|
||||||
{
|
{
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
aes.ProcessBlock(pbNewKey, 0, pbNewKey, 0);
|
aes.ProcessBlock(pbNewKey, 0, pbNewKey, 0);
|
||||||
aes.ProcessBlock(pbNewKey, 16, pbNewKey, 16);
|
aes.ProcessBlock(pbNewKey, 16, pbNewKey, 16);
|
||||||
#else
|
#else
|
||||||
@@ -269,7 +268,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.SetUInt64(ParamRounds, uRounds);
|
p.SetUInt64(ParamRounds, uRounds);
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
aes.Reset();
|
aes.Reset();
|
||||||
#else
|
#else
|
||||||
}
|
}
|
||||||
|
@@ -21,11 +21,13 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
#if ModernKeePassLib
|
||||||
#if !KeePassUAP
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using ModernKeePassLib.Resources;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
@@ -163,5 +165,58 @@ namespace ModernKeePassLib.Cryptography.PasswordGenerator
|
|||||||
psOut = pwd;
|
psOut = pwd;
|
||||||
return PwgError.Success;
|
return PwgError.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string ErrorToString(PwgError e, bool bHeader)
|
||||||
|
{
|
||||||
|
if(e == PwgError.Success) { Debug.Assert(false); return string.Empty; }
|
||||||
|
if((e == PwgError.Unknown) && bHeader) return KLRes.PwGenFailed;
|
||||||
|
|
||||||
|
string str = KLRes.UnknownError;
|
||||||
|
switch(e)
|
||||||
|
{
|
||||||
|
// case PwgError.Success:
|
||||||
|
// break;
|
||||||
|
|
||||||
|
case PwgError.Unknown:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PwgError.TooFewCharacters:
|
||||||
|
str = KLRes.CharSetTooFewChars;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PwgError.UnknownAlgorithm:
|
||||||
|
str = KLRes.AlgorithmUnknown;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PwgError.InvalidCharSet:
|
||||||
|
str = KLRes.CharSetInvalid;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PwgError.InvalidPattern:
|
||||||
|
str = KLRes.PatternInvalid;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Debug.Assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bHeader)
|
||||||
|
str = KLRes.PwGenFailed + MessageService.NewParagraph + str;
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string ErrorToString(Exception ex, bool bHeader)
|
||||||
|
{
|
||||||
|
string str = KLRes.UnknownError;
|
||||||
|
if((ex != null) && !string.IsNullOrEmpty(ex.Message))
|
||||||
|
str = ex.Message;
|
||||||
|
|
||||||
|
if(bHeader)
|
||||||
|
str = KLRes.PwGenFailed + MessageService.NewParagraph + str;
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,14 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
if(vPassword.Length == 0) { uDictSize = 0; return false; }
|
if(vPassword.Length == 0) { uDictSize = 0; return false; }
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
#if ModernKeePassLib
|
||||||
|
foreach (var ch in vPassword)
|
||||||
|
{
|
||||||
|
Debug.Assert(ch == char.ToLower(ch));
|
||||||
|
}
|
||||||
|
#else
|
||||||
Array.ForEach(vPassword, ch => Debug.Assert(ch == char.ToLower(ch)));
|
Array.ForEach(vPassword, ch => Debug.Assert(ch == char.ToLower(ch)));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
try { return IsPopularPasswordPriv(vPassword, out uDictSize); }
|
try { return IsPopularPasswordPriv(vPassword, out uDictSize); }
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography
|
namespace ModernKeePassLib.Cryptography
|
||||||
|
17
ModernKeePassLib/Cryptography/RNGCryptoServiceProvider.cs
Normal file
17
ModernKeePassLib/Cryptography/RNGCryptoServiceProvider.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ModernKeePassLib.Cryptography
|
||||||
|
{
|
||||||
|
public class RNGCryptoServiceProvider: IDisposable
|
||||||
|
{
|
||||||
|
public void GetBytes(byte[] pb)
|
||||||
|
{
|
||||||
|
var random = new Random();
|
||||||
|
random.NextBytes(pb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -26,7 +26,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
using Org.BouncyCastle.Crypto;
|
using Org.BouncyCastle.Crypto;
|
||||||
using Org.BouncyCastle.Crypto.Engines;
|
using Org.BouncyCastle.Crypto.Engines;
|
||||||
using Org.BouncyCastle.Crypto.Parameters;
|
using Org.BouncyCastle.Crypto.Parameters;
|
||||||
@@ -105,7 +105,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
|
|
||||||
internal static void TestFipsComplianceProblems()
|
internal static void TestFipsComplianceProblems()
|
||||||
{
|
{
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib
|
||||||
try { using(RijndaelManaged r = new RijndaelManaged()) { } }
|
try { using(RijndaelManaged r = new RijndaelManaged()) { } }
|
||||||
catch(Exception exAes)
|
catch(Exception exAes)
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
|
0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
|
||||||
0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7 };
|
0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7 };
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
AesEngine aes = new AesEngine();
|
AesEngine aes = new AesEngine();
|
||||||
aes.Init(true, new KeyParameter(pbKey));
|
aes.Init(true, new KeyParameter(pbKey));
|
||||||
if(aes.GetBlockSize() != pbData.Length)
|
if(aes.GetBlockSize() != pbData.Length)
|
||||||
@@ -550,7 +550,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
// (test vector for Argon2d 1.3); also on
|
// (test vector for Argon2d 1.3); also on
|
||||||
// https://tools.ietf.org/html/draft-irtf-cfrg-argon2-00
|
// https://tools.ietf.org/html/draft-irtf-cfrg-argon2-00
|
||||||
|
|
||||||
KdfParameters p = kdf.GetDefaultParameters();
|
var p = kdf.GetDefaultParameters();
|
||||||
kdf.Randomize(p);
|
kdf.Randomize(p);
|
||||||
|
|
||||||
Debug.Assert(p.GetUInt32(Argon2Kdf.ParamVersion, 0) == 0x13U);
|
Debug.Assert(p.GetUInt32(Argon2Kdf.ParamVersion, 0) == 0x13U);
|
||||||
@@ -766,7 +766,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
pbMan = CryptoUtil.HashSha256(pbMan);
|
pbMan = CryptoUtil.HashSha256(pbMan);
|
||||||
|
|
||||||
AesKdf kdf = new AesKdf();
|
AesKdf kdf = new AesKdf();
|
||||||
KdfParameters p = kdf.GetDefaultParameters();
|
var p = kdf.GetDefaultParameters();
|
||||||
p.SetUInt64(AesKdf.ParamRounds, uRounds);
|
p.SetUInt64(AesKdf.ParamRounds, uRounds);
|
||||||
p.SetByteArray(AesKdf.ParamSeed, pbSeed);
|
p.SetByteArray(AesKdf.ParamSeed, pbSeed);
|
||||||
byte[] pbKdf = kdf.Transform(pbKey, p);
|
byte[] pbKdf = kdf.Transform(pbKey, p);
|
||||||
@@ -778,7 +778,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
|
|
||||||
private static void TestNativeKeyTransform(Random r)
|
private static void TestNativeKeyTransform(Random r)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if !ModernKeePassLib && DEBUG
|
||||||
byte[] pbOrgKey = CryptoRandom.Instance.GetRandomBytes(32);
|
byte[] pbOrgKey = CryptoRandom.Instance.GetRandomBytes(32);
|
||||||
byte[] pbSeed = CryptoRandom.Instance.GetRandomBytes(32);
|
byte[] pbSeed = CryptoRandom.Instance.GetRandomBytes(32);
|
||||||
ulong uRounds = (ulong)r.Next(1, 0x3FFF);
|
ulong uRounds = (ulong)r.Next(1, 0x3FFF);
|
||||||
@@ -915,7 +915,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
|
|
||||||
private static void TestNativeLib()
|
private static void TestNativeLib()
|
||||||
{
|
{
|
||||||
#if DEBUG && !ModernKeePassLib
|
#if DEBUG
|
||||||
if(NativeLib.IsUnix())
|
if(NativeLib.IsUnix())
|
||||||
{
|
{
|
||||||
if(NativeLib.EncodeDataToArgs("A\"B C\\D") !=
|
if(NativeLib.EncodeDataToArgs("A\"B C\\D") !=
|
||||||
@@ -973,31 +973,31 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
throw new InvalidOperationException("MemUtil-7");
|
throw new InvalidOperationException("MemUtil-7");
|
||||||
|
|
||||||
byte[] pbRes = MemUtil.ParseBase32("MY======");
|
byte[] pbRes = MemUtil.ParseBase32("MY======");
|
||||||
byte[] pbExp = Encoding.ASCII.GetBytes("f");
|
byte[] pbExp = Encoding.UTF8.GetBytes("f");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-1");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-1");
|
||||||
|
|
||||||
pbRes = MemUtil.ParseBase32("MZXQ====");
|
pbRes = MemUtil.ParseBase32("MZXQ====");
|
||||||
pbExp = Encoding.ASCII.GetBytes("fo");
|
pbExp = Encoding.UTF8.GetBytes("fo");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-2");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-2");
|
||||||
|
|
||||||
pbRes = MemUtil.ParseBase32("MZXW6===");
|
pbRes = MemUtil.ParseBase32("MZXW6===");
|
||||||
pbExp = Encoding.ASCII.GetBytes("foo");
|
pbExp = Encoding.UTF8.GetBytes("foo");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-3");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-3");
|
||||||
|
|
||||||
pbRes = MemUtil.ParseBase32("MZXW6YQ=");
|
pbRes = MemUtil.ParseBase32("MZXW6YQ=");
|
||||||
pbExp = Encoding.ASCII.GetBytes("foob");
|
pbExp = Encoding.UTF8.GetBytes("foob");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-4");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-4");
|
||||||
|
|
||||||
pbRes = MemUtil.ParseBase32("MZXW6YTB");
|
pbRes = MemUtil.ParseBase32("MZXW6YTB");
|
||||||
pbExp = Encoding.ASCII.GetBytes("fooba");
|
pbExp = Encoding.UTF8.GetBytes("fooba");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-5");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-5");
|
||||||
|
|
||||||
pbRes = MemUtil.ParseBase32("MZXW6YTBOI======");
|
pbRes = MemUtil.ParseBase32("MZXW6YTBOI======");
|
||||||
pbExp = Encoding.ASCII.GetBytes("foobar");
|
pbExp = Encoding.UTF8.GetBytes("foobar");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-6");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-6");
|
||||||
|
|
||||||
pbRes = MemUtil.ParseBase32("JNSXSIDQOJXXM2LEMVZCAYTBONSWIIDPNYQG63TFFV2GS3LFEBYGC43TO5XXEZDTFY======");
|
pbRes = MemUtil.ParseBase32("JNSXSIDQOJXXM2LEMVZCAYTBONSWIIDPNYQG63TFFV2GS3LFEBYGC43TO5XXEZDTFY======");
|
||||||
pbExp = Encoding.ASCII.GetBytes("Key provider based on one-time passwords.");
|
pbExp = Encoding.UTF8.GetBytes("Key provider based on one-time passwords.");
|
||||||
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-7");
|
if(!MemUtil.ArraysEqual(pbRes, pbExp)) throw new Exception("Base32-7");
|
||||||
|
|
||||||
int i = 0 - 0x10203040;
|
int i = 0 - 0x10203040;
|
||||||
@@ -1150,7 +1150,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
private static void TestUrlUtil()
|
private static void TestUrlUtil()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib && !KeePassUAP
|
||||||
Debug.Assert(Uri.UriSchemeHttp.Equals("http", StrUtil.CaseIgnoreCmp));
|
Debug.Assert(Uri.UriSchemeHttp.Equals("http", StrUtil.CaseIgnoreCmp));
|
||||||
Debug.Assert(Uri.UriSchemeHttps.Equals("https", StrUtil.CaseIgnoreCmp));
|
Debug.Assert(Uri.UriSchemeHttps.Equals("https", StrUtil.CaseIgnoreCmp));
|
||||||
#endif
|
#endif
|
||||||
|
@@ -26,7 +26,6 @@ using System.Threading;
|
|||||||
using ModernKeePassLib.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||||
using ModernKeePassLib.Interfaces;
|
using ModernKeePassLib.Interfaces;
|
||||||
using ModernKeePassLib.Native;
|
|
||||||
using ModernKeePassLib.Resources;
|
using ModernKeePassLib.Resources;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
@@ -122,7 +121,7 @@ namespace ModernKeePassLib.Keys
|
|||||||
{
|
{
|
||||||
if(pKey == null) { Debug.Assert(false); continue; }
|
if(pKey == null) { Debug.Assert(false); continue; }
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
if(pKey.GetType() == tUserKeyType)
|
if(pKey.GetType() == tUserKeyType)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@@ -149,7 +148,7 @@ namespace ModernKeePassLib.Keys
|
|||||||
{
|
{
|
||||||
if(pKey == null) { Debug.Assert(false); continue; }
|
if(pKey == null) { Debug.Assert(false); continue; }
|
||||||
|
|
||||||
#if KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
if(pKey.GetType() == tUserKeyType)
|
if(pKey.GetType() == tUserKeyType)
|
||||||
return pKey;
|
return pKey;
|
||||||
#else
|
#else
|
||||||
@@ -279,8 +278,10 @@ namespace ModernKeePassLib.Keys
|
|||||||
|
|
||||||
internal ProtectedBinary GenerateKey32Ex(KdfParameters p, IStatusLogger sl)
|
internal ProtectedBinary GenerateKey32Ex(KdfParameters p, IStatusLogger sl)
|
||||||
{
|
{
|
||||||
|
#if ModernKeePassLib
|
||||||
|
return GenerateKey32(p);
|
||||||
|
#else
|
||||||
if (sl == null) return GenerateKey32(p);
|
if (sl == null) return GenerateKey32(p);
|
||||||
|
|
||||||
CkGkTaskInfo ti = new CkGkTaskInfo();
|
CkGkTaskInfo ti = new CkGkTaskInfo();
|
||||||
|
|
||||||
ThreadStart f = delegate()
|
ThreadStart f = delegate()
|
||||||
@@ -319,6 +320,7 @@ namespace ModernKeePassLib.Keys
|
|||||||
|
|
||||||
Debug.Assert(ti.Key != null);
|
Debug.Assert(ti.Key != null);
|
||||||
return ti.Key;
|
return ti.Key;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateUserKeys()
|
private void ValidateUserKeys()
|
||||||
|
@@ -248,6 +248,33 @@ namespace ModernKeePassLib.Keys
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if ModernKeePassLib
|
||||||
|
|
||||||
|
var doc = XDocument.Load(ms);
|
||||||
|
|
||||||
|
var el = doc.Root;
|
||||||
|
|
||||||
|
if((el == null) || !el.Name.LocalName.Equals(RootElementName))
|
||||||
|
return null;
|
||||||
|
if(el.DescendantNodes().Count() < 2)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
foreach(var xmlChild in el.Descendants())
|
||||||
|
{
|
||||||
|
if(xmlChild.Name == MetaElementName) { } // Ignore Meta
|
||||||
|
else if(xmlChild.Name == KeyElementName)
|
||||||
|
{
|
||||||
|
foreach(var xmlKeyChild in xmlChild.Descendants())
|
||||||
|
{
|
||||||
|
if(xmlKeyChild.Name == KeyDataElementName)
|
||||||
|
{
|
||||||
|
if(pbKeyData == null)
|
||||||
|
pbKeyData = Convert.FromBase64String(xmlKeyChild.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
XmlDocument doc = XmlUtilEx.CreateXmlDocument();
|
XmlDocument doc = XmlUtilEx.CreateXmlDocument();
|
||||||
doc.Load(ms);
|
doc.Load(ms);
|
||||||
|
|
||||||
@@ -270,6 +297,7 @@ namespace ModernKeePassLib.Keys
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch(Exception) { pbKeyData = null; }
|
catch(Exception) { pbKeyData = null; }
|
||||||
finally { ms.Dispose(); }
|
finally { ms.Dispose(); }
|
||||||
|
@@ -99,8 +99,13 @@ namespace ModernKeePassLib.Keys
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if ModernKeePassLib
|
||||||
|
// TODO: find a way to implement this
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
string str = StrUtil.Utf8.GetString(pb);
|
string str = StrUtil.Utf8.GetString(pb);
|
||||||
return str.IsNormalized(NormalizationForm.FormC);
|
return str.IsNormalized(NormalizationForm.FormC);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
|
|
||||||
|
@@ -23,10 +23,12 @@ using System.IO;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
|
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
using System.Security.Cryptography;
|
using Windows.Storage;
|
||||||
|
using Windows.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
|
using ModernKeePassLib.Native;
|
||||||
using ModernKeePassLib.Resources;
|
using ModernKeePassLib.Resources;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
@@ -87,6 +89,8 @@ namespace ModernKeePassLib.Keys
|
|||||||
{
|
{
|
||||||
#if KeePassUAP
|
#if KeePassUAP
|
||||||
string strUserDir = EnvironmentExt.AppDataRoamingFolderPath;
|
string strUserDir = EnvironmentExt.AppDataRoamingFolderPath;
|
||||||
|
#elif ModernKeePassLib
|
||||||
|
string strUserDir = Windows.Storage.ApplicationData.Current.RoamingFolder.Path;
|
||||||
#else
|
#else
|
||||||
string strUserDir = Environment.GetFolderPath(
|
string strUserDir = Environment.GetFolderPath(
|
||||||
Environment.SpecialFolder.ApplicationData);
|
Environment.SpecialFolder.ApplicationData);
|
||||||
@@ -95,8 +99,11 @@ namespace ModernKeePassLib.Keys
|
|||||||
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
||||||
strUserDir += PwDefs.ShortProductName;
|
strUserDir += PwDefs.ShortProductName;
|
||||||
|
|
||||||
|
#if !ModernKeePassLib
|
||||||
|
|
||||||
if(bCreate && !Directory.Exists(strUserDir))
|
if(bCreate && !Directory.Exists(strUserDir))
|
||||||
Directory.CreateDirectory(strUserDir);
|
Directory.CreateDirectory(strUserDir);
|
||||||
|
#endif
|
||||||
|
|
||||||
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
||||||
return (strUserDir + UserKeyFileName);
|
return (strUserDir + UserKeyFileName);
|
||||||
@@ -110,7 +117,15 @@ namespace ModernKeePassLib.Keys
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string strFilePath = GetUserKeyFilePath(false);
|
string strFilePath = GetUserKeyFilePath(false);
|
||||||
|
|
||||||
|
#if ModernKeePassLib
|
||||||
|
var fileStream = StorageFile.GetFileFromPathAsync(strFilePath).GetAwaiter().GetResult().OpenStreamForReadAsync().GetAwaiter().GetResult();
|
||||||
|
var pbProtectedKey = new byte[(int)fileStream.Length];
|
||||||
|
fileStream.Read(pbProtectedKey, 0, (int)fileStream.Length);
|
||||||
|
fileStream.Dispose();
|
||||||
|
#else
|
||||||
byte[] pbProtectedKey = File.ReadAllBytes(strFilePath);
|
byte[] pbProtectedKey = File.ReadAllBytes(strFilePath);
|
||||||
|
#endif
|
||||||
|
|
||||||
pbKey = CryptoUtil.UnprotectData(pbProtectedKey, m_pbEntropy,
|
pbKey = CryptoUtil.UnprotectData(pbProtectedKey, m_pbEntropy,
|
||||||
DataProtectionScope.CurrentUser);
|
DataProtectionScope.CurrentUser);
|
||||||
@@ -135,8 +150,13 @@ namespace ModernKeePassLib.Keys
|
|||||||
byte[] pbRandomKey = CryptoRandom.Instance.GetRandomBytes(64);
|
byte[] pbRandomKey = CryptoRandom.Instance.GetRandomBytes(64);
|
||||||
byte[] pbProtectedKey = CryptoUtil.ProtectData(pbRandomKey,
|
byte[] pbProtectedKey = CryptoUtil.ProtectData(pbRandomKey,
|
||||||
m_pbEntropy, DataProtectionScope.CurrentUser);
|
m_pbEntropy, DataProtectionScope.CurrentUser);
|
||||||
|
#if ModernKeePassLib
|
||||||
|
var fileStream = StorageFile.GetFileFromPathAsync(strFilePath).GetAwaiter().GetResult().OpenStreamForWriteAsync().GetAwaiter().GetResult();
|
||||||
|
fileStream.Write(pbProtectedKey, 0, (int)fileStream.Length);
|
||||||
|
fileStream.Dispose();
|
||||||
|
#else
|
||||||
File.WriteAllBytes(strFilePath, pbProtectedKey);
|
File.WriteAllBytes(strFilePath, pbProtectedKey);
|
||||||
|
#endif
|
||||||
|
|
||||||
byte[] pbKey = LoadUserKey(true);
|
byte[] pbKey = LoadUserKey(true);
|
||||||
Debug.Assert(MemUtil.ArraysEqual(pbKey, pbRandomKey));
|
Debug.Assert(MemUtil.ArraysEqual(pbKey, pbRandomKey));
|
||||||
|
194
ModernKeePassLib/ModernKeePass.Lib.csproj
Normal file
194
ModernKeePassLib/ModernKeePass.Lib.csproj
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<ProjectGuid>{2E710089-9559-4967-846C-E763DD1F3ACB}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>ModernKeePassLib</RootNamespace>
|
||||||
|
<AssemblyName>ModernKeePassLib</AssemblyName>
|
||||||
|
<SignAssembly>false</SignAssembly>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>2.0</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation>
|
||||||
|
</UpgradeBackupLocation>
|
||||||
|
<TargetFrameworkProfile>
|
||||||
|
</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
|
||||||
|
<AssemblyOriginatorKeyFile>KeePassLib.pfx</AssemblyOriginatorKeyFile>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;ModernKeePassLib</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<DefineConstants>ModernKeePassLib</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Collections\AutoTypeConfig.cs" />
|
||||||
|
<Compile Include="Collections\ProtectedBinaryDictionary.cs" />
|
||||||
|
<Compile Include="Collections\ProtectedBinarySet.cs" />
|
||||||
|
<Compile Include="Collections\ProtectedStringDictionary.cs" />
|
||||||
|
<Compile Include="Collections\PwObjectList.cs" />
|
||||||
|
<Compile Include="Collections\PwObjectPool.cs" />
|
||||||
|
<Compile Include="Collections\StringDictionaryEx.cs" />
|
||||||
|
<Compile Include="Collections\VariantDictionary.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\ChaCha20Cipher.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\ChaCha20Engine.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\CipherPool.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\CryptoStreamMode.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\CtrBlockCipher.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\Salsa20Cipher.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\StandardAesEngine.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\StandardAesEngineExt.cs" />
|
||||||
|
<Compile Include="Cryptography\CryptoRandom.cs" />
|
||||||
|
<Compile Include="Cryptography\CryptoRandomStream.cs" />
|
||||||
|
<Compile Include="Cryptography\Cipher\ICipherEngine.cs" />
|
||||||
|
<Compile Include="Cryptography\CryptoStreamEx.cs" />
|
||||||
|
<Compile Include="Cryptography\CryptoUtil.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\Blake2b.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\HashAlgorithm.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\HMAC.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\HMACSHA1.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\HMACSHA256.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\SHA256Managed.cs" />
|
||||||
|
<Compile Include="Cryptography\Hash\SHA512Managed.cs" />
|
||||||
|
<Compile Include="Cryptography\HmacOtp.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\AesKdf.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\AesKdf.GCrypt.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\Argon2Kdf.Core.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\Argon2Kdf.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\KdfEngine.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\KdfParameters.cs" />
|
||||||
|
<Compile Include="Cryptography\KeyDerivation\KdfPool.cs" />
|
||||||
|
<Compile Include="Cryptography\PasswordGenerator\CharSetBasedGenerator.cs" />
|
||||||
|
<Compile Include="Cryptography\PasswordGenerator\CustomPwGenerator.cs" />
|
||||||
|
<Compile Include="Cryptography\PasswordGenerator\CustomPwGeneratorPool.cs" />
|
||||||
|
<Compile Include="Cryptography\PasswordGenerator\PatternBasedGenerator.cs" />
|
||||||
|
<Compile Include="Cryptography\PasswordGenerator\PwCharSet.cs" />
|
||||||
|
<Compile Include="Cryptography\PasswordGenerator\PwProfile.cs" />
|
||||||
|
<Compile Include="Cryptography\PopularPasswords.cs" />
|
||||||
|
<Compile Include="Cryptography\ProtectedData.cs" />
|
||||||
|
<Compile Include="Cryptography\QualityEstimation.cs" />
|
||||||
|
<Compile Include="Cryptography\RNGCryptoServiceProvider.cs" />
|
||||||
|
<Compile Include="Cryptography\SelfTest.cs" />
|
||||||
|
<Compile Include="Interfaces\IStructureItem.cs" />
|
||||||
|
<Compile Include="Interfaces\IUIOperations.cs" />
|
||||||
|
<Compile Include="Interfaces\IXmlSerializerEx.cs" />
|
||||||
|
<Compile Include="Keys\KcpCustomKey.cs" />
|
||||||
|
<Compile Include="Keys\KeyProvider.cs" />
|
||||||
|
<Compile Include="Keys\KeyProviderPool.cs" />
|
||||||
|
<Compile Include="Keys\KeyValidator.cs" />
|
||||||
|
<Compile Include="Keys\KeyValidatorPool.cs" />
|
||||||
|
<Compile Include="Keys\UserKeyType.cs" />
|
||||||
|
<Content Include="Native\SimpleStat.cs" />
|
||||||
|
<Compile Include="Native\SimpleStat.Standard.cs" />
|
||||||
|
<Compile Include="PwCustomIcon.cs" />
|
||||||
|
<Compile Include="Resources\KLRes.Generated.cs" />
|
||||||
|
<Compile Include="Resources\KSRes.Generated.cs" />
|
||||||
|
<Compile Include="Security\XorredBuffer.cs" />
|
||||||
|
<Compile Include="Delegates\Handlers.cs" />
|
||||||
|
<Compile Include="Interfaces\IDeepCloneable.cs" />
|
||||||
|
<Compile Include="Interfaces\IStatusLogger.cs" />
|
||||||
|
<Compile Include="Interfaces\ITimeLogger.cs" />
|
||||||
|
<Compile Include="Keys\KcpKeyFile.cs" />
|
||||||
|
<Compile Include="Keys\IUserKey.cs" />
|
||||||
|
<Compile Include="Keys\KcpPassword.cs" />
|
||||||
|
<Compile Include="PwDeletedObject.cs" />
|
||||||
|
<Compile Include="PwUuid.cs" />
|
||||||
|
<Compile Include="Security\ProtectedBinary.cs" />
|
||||||
|
<Compile Include="Security\ProtectedString.cs" />
|
||||||
|
<Compile Include="PwDefs.cs" />
|
||||||
|
<Compile Include="PwEntry.cs" />
|
||||||
|
<Compile Include="PwGroup.cs" />
|
||||||
|
<Compile Include="Keys\CompositeKey.cs" />
|
||||||
|
<Compile Include="PwDatabase.cs" />
|
||||||
|
<Compile Include="PwEnums.cs" />
|
||||||
|
<Compile Include="Serialization\BinaryReaderEx.cs" />
|
||||||
|
<Compile Include="Serialization\FileLock.cs" />
|
||||||
|
<Compile Include="Serialization\FileTransactionEx.cs" />
|
||||||
|
<Compile Include="Serialization\HashedBlockStream.cs" />
|
||||||
|
<Compile Include="Serialization\HmacBlockStream.cs" />
|
||||||
|
<Compile Include="Serialization\IOConnection.cs" />
|
||||||
|
<Compile Include="Serialization\IocProperties.cs" />
|
||||||
|
<Compile Include="Serialization\IocPropertyInfo.cs" />
|
||||||
|
<Compile Include="Serialization\IocPropertyInfoPool.cs" />
|
||||||
|
<Compile Include="Serialization\KdbxFile.cs" />
|
||||||
|
<Compile Include="Serialization\KdbxFile.Read.cs" />
|
||||||
|
<Compile Include="Serialization\KdbxFile.Read.Streamed.cs" />
|
||||||
|
<Compile Include="Serialization\KdbxFile.Write.cs" />
|
||||||
|
<Compile Include="Serialization\IOConnectionInfo.cs" />
|
||||||
|
<Compile Include="Serialization\OldFormatException.cs" />
|
||||||
|
<Compile Include="Utility\AppLogEx.cs" />
|
||||||
|
<Compile Include="Utility\TypeOverridePool.cs" />
|
||||||
|
<Compile Include="Utility\XmlUtilEx.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" />
|
||||||
|
<Compile Include="Utility\StrUtil.cs" />
|
||||||
|
<Compile Include="Utility\UrlUtil.cs" />
|
||||||
|
<Compile Include="Utility\TimeUtil.cs" />
|
||||||
|
<Compile Include="Cryptography\HashingStreamEx.cs" />
|
||||||
|
<Compile Include="Native\Native.Standard.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Utility\ColorTranslator.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="KeePassLib.pfx" />
|
||||||
|
<None Include="Libs\Windows.winmd" />
|
||||||
|
<None Include="ModernKeePassLib.nuspec" />
|
||||||
|
<None Include="project.json" />
|
||||||
|
<Compile Include="Utility\MessageService.cs" />
|
||||||
|
<None Include="Native\NativeLib.cs" />
|
||||||
|
<None Include="Native\NativeMethods.cs" />
|
||||||
|
<None Include="Native\NativeMethods.Unix.cs" />
|
||||||
|
<Compile Include="Keys\KcpUserAccount.cs" />
|
||||||
|
<None Include="Translation\KPControlCustomization.cs" />
|
||||||
|
<None Include="Translation\KPFormCustomization.cs" />
|
||||||
|
<None Include="Translation\KPStringTable.cs" />
|
||||||
|
<None Include="Translation\KPStringTableItem.cs" />
|
||||||
|
<None Include="Translation\KPTranslation.cs" />
|
||||||
|
<None Include="Translation\KPTranslationProperties.cs" />
|
||||||
|
<None Include="Utility\MonoWorkarounds.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
|
<ProjectExtensions>
|
||||||
|
<MonoDevelop>
|
||||||
|
<Properties>
|
||||||
|
<Policies>
|
||||||
|
<TextStylePolicy TabsToSpaces="False" EolMarker="Windows" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
|
||||||
|
<TextStylePolicy inheritsSet="null" scope="text/x-csharp" />
|
||||||
|
<CSharpFormattingPolicy IndentPreprocessorDirectives="False" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" BeforeDelegateDeclarationParentheses="False" AfterDelegateDeclarationParameterComma="True" NewParentheses="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
|
||||||
|
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
|
||||||
|
</Policies>
|
||||||
|
</Properties>
|
||||||
|
</MonoDevelop>
|
||||||
|
</ProjectExtensions>
|
||||||
|
<ItemGroup>
|
||||||
|
<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 />
|
||||||
|
</Project>
|
@@ -1,62 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
|
||||||
<Version>2.44.0</Version>
|
|
||||||
<Authors>Geoffroy Bonneville</Authors>
|
|
||||||
<PackageLicense>https://www.gnu.org/licenses/gpl-3.0.en.html</PackageLicense>
|
|
||||||
<PackageProjectUrl>https://github.com/wismna/ModernKeePassLib</PackageProjectUrl>
|
|
||||||
<Description>Portable KeePass Password Management Library that targets .Net Standard. Allows reading, editing and writing to KeePass 2.x databases.</Description>
|
|
||||||
<Company>wismna</Company>
|
|
||||||
<Product>ModernKeePassLib</Product>
|
|
||||||
<PackageReleaseNotes>Save corrections</PackageReleaseNotes>
|
|
||||||
<PackageTags>KeePass KeePassLib Portable PCL NetStandard ModernKeePass</PackageTags>
|
|
||||||
<Copyright>Copyright © 2020 Geoffroy Bonneville</Copyright>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<DefineConstants>TRACE;ModernKeePassLib</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<DefineConstants>TRACE;ModernKeePassLib</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="Native\ClipboardU.cs" />
|
|
||||||
<Compile Remove="Native\NativeLib.cs" />
|
|
||||||
<Compile Remove="Native\NativeMethods.cs" />
|
|
||||||
<Compile Remove="Native\NativeMethods.Unix.cs" />
|
|
||||||
<Compile Remove="Translation\KPControlCustomization.cs" />
|
|
||||||
<Compile Remove="Translation\KPFormCustomization.cs" />
|
|
||||||
<Compile Remove="Translation\KPStringTable.cs" />
|
|
||||||
<Compile Remove="Translation\KPStringTableItem.cs" />
|
|
||||||
<Compile Remove="Translation\KPTranslation.cs" />
|
|
||||||
<Compile Remove="Translation\KPTranslationProperties.cs" />
|
|
||||||
<Compile Remove="Utility\GfxUtil.cs" />
|
|
||||||
<Compile Remove="Utility\MonoWorkarounds.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Native\ClipboardU.cs" />
|
|
||||||
<None Include="Native\NativeLib.cs" />
|
|
||||||
<None Include="Native\NativeMethods.cs" />
|
|
||||||
<None Include="Native\NativeMethods.Unix.cs" />
|
|
||||||
<None Include="Translation\KPControlCustomization.cs" />
|
|
||||||
<None Include="Translation\KPFormCustomization.cs" />
|
|
||||||
<None Include="Translation\KPStringTable.cs" />
|
|
||||||
<None Include="Translation\KPStringTableItem.cs" />
|
|
||||||
<None Include="Translation\KPTranslation.cs" />
|
|
||||||
<None Include="Translation\KPTranslationProperties.cs" />
|
|
||||||
<None Include="Utility\GfxUtil.cs" />
|
|
||||||
<None Include="Utility\MonoWorkarounds.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0007" />
|
|
||||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
|
|
||||||
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
36
ModernKeePassLib/ModernKeePassLib.nuspec
Normal file
36
ModernKeePassLib/ModernKeePassLib.nuspec
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<package >
|
||||||
|
<metadata>
|
||||||
|
<id>ModernKeePassLib</id>
|
||||||
|
<version>2.39.1</version>
|
||||||
|
<title>ModernKeePassLib</title>
|
||||||
|
<authors>Geoffroy Bonneville</authors>
|
||||||
|
<owners>Geoffroy Bonneville</owners>
|
||||||
|
<licenseUrl>https://www.gnu.org/licenses/gpl-3.0.en.html</licenseUrl>
|
||||||
|
<projectUrl>https://github.com/wismna/ModernKeePass</projectUrl>
|
||||||
|
<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>
|
||||||
|
<releaseNotes>Implementation of KeePass library version 2.39.1</releaseNotes>
|
||||||
|
<copyright>Copyright © 2018 Geoffroy Bonneville</copyright>
|
||||||
|
<tags>KeePass KeePassLib Portable PCL NetStandard</tags>
|
||||||
|
<dependencies>
|
||||||
|
<group targetFramework=".NETStandard1.2">
|
||||||
|
<dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="NETStandard.Library" version="2.0.0" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="Portable.BouncyCastle" version="1.8.1.3" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="Splat" version="2.0.0" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="System.Net.Requests" version="4.3.0" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="System.Runtime.WindowsRuntime" version="4.3.0" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="System.Xml.XmlSerializer" version="4.3.0" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="Validation" version="2.4.15" exclude="Build,Analyzers" />
|
||||||
|
</group>
|
||||||
|
</dependencies>
|
||||||
|
</metadata>
|
||||||
|
<!-- DLLs and resources -->
|
||||||
|
<files>
|
||||||
|
<file src="bin\Release\ModernKeePassLib.dll" target="lib\netstandard1.2"/>
|
||||||
|
<!--<file src="bin\ARM\Release\ModernKeePassLib.dll" target="lib\ARM\netstandard1.2"/>
|
||||||
|
<file src="bin\x64\Release\ModernKeePassLib.dll" target="lib\x64\netstandard1.2"/>
|
||||||
|
<file src="bin\x86\Release\ModernKeePassLib.dll" target="lib\x86\netstandard1.2"/>-->
|
||||||
|
</files>
|
||||||
|
</package>
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
|
Copyright (C) 2003-2018 Dominik Reichl <dominik.reichl@t-online.de>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -13,31 +13,20 @@ namespace ModernKeePassLib.Native
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TransformKey256(byte[] pbNative, byte[] pbSeed, ulong uRounds)
|
public static string EncodeDataToArgs(string data)
|
||||||
{
|
{
|
||||||
return false;
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
public static string DecodeArgsToData(string strArgs)
|
||||||
public static System.PlatformID GetPlatformID()
|
|
||||||
{
|
|
||||||
return Environment.OSVersion.Platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string DecodeArgsToPath(string strApp)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(strApp)) return strApp;
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string EncodeDataToArgs(string v)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string DecodeArgsToData(string strApp)
|
internal static int GetPlatformID()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return Environment.CurrentManagedThreadId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class NativeMethods
|
internal static class NativeMethods
|
||||||
@@ -83,6 +72,12 @@ namespace ModernKeePassLib.Native
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DataProtectionScope
|
||||||
|
{
|
||||||
|
CurrentUser,
|
||||||
|
LocalMachine
|
||||||
|
}
|
||||||
|
|
||||||
internal enum MemoryProtectionScope
|
internal enum MemoryProtectionScope
|
||||||
{
|
{
|
||||||
CrossProcess,
|
CrossProcess,
|
||||||
@@ -103,4 +98,3 @@ namespace ModernKeePassLib.Native
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@@ -28,10 +28,8 @@ using System.Text.RegularExpressions;
|
|||||||
#if !KeePassUAP
|
#if !KeePassUAP
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#if !ModernKeePassLib
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
@@ -288,7 +286,6 @@ namespace ModernKeePassLib.Native
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !ModernKeePassLib
|
|
||||||
if((f & AppRunFlags.DoEvents) != AppRunFlags.None)
|
if((f & AppRunFlags.DoEvents) != AppRunFlags.None)
|
||||||
{
|
{
|
||||||
List<Form> lDisabledForms = new List<Form>();
|
List<Form> lDisabledForms = new List<Form>();
|
||||||
@@ -318,7 +315,7 @@ namespace ModernKeePassLib.Native
|
|||||||
|
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return fnRun();
|
return fnRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +364,7 @@ namespace ModernKeePassLib.Native
|
|||||||
public static bool TransformKey256(byte[] pBuf256, byte[] pKey256,
|
public static bool TransformKey256(byte[] pBuf256, byte[] pKey256,
|
||||||
ulong uRounds)
|
ulong uRounds)
|
||||||
{
|
{
|
||||||
#if KeePassUAP || ModernKeePassLib
|
#if KeePassUAP
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if(!m_bAllowNative) return false;
|
if(!m_bAllowNative) return false;
|
||||||
@@ -398,7 +395,7 @@ namespace ModernKeePassLib.Native
|
|||||||
{
|
{
|
||||||
puRounds = 0;
|
puRounds = 0;
|
||||||
|
|
||||||
#if KeePassUAP || ModernKeePassLib
|
#if KeePassUAP
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if(!m_bAllowNative) return false;
|
if(!m_bAllowNative) return false;
|
||||||
|
7
ModernKeePassLib/Native/SimpleStat.Standard.cs
Normal file
7
ModernKeePassLib/Native/SimpleStat.Standard.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace ModernKeePassLib.Native
|
||||||
|
{
|
||||||
|
internal sealed class SimpleStat
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
44
ModernKeePassLib/Properties/AssemblyInfo.cs
Normal file
44
ModernKeePassLib/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
|
Copyright (C) 2003-2020 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
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General assembly properties
|
||||||
|
[assembly: AssemblyTitle("ModernKeePassLib")]
|
||||||
|
[assembly: AssemblyDescription("KeePass Password Management Library for .Net Standard")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("wismna")]
|
||||||
|
[assembly: AssemblyProduct("ModernKeePassLib")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020 Geoffroy Bonneville")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// COM settings
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
#if !ModernKeePassLib
|
||||||
|
// Assembly GUID
|
||||||
|
[assembly: Guid("395f6eec-a1e0-4438-aa82-b75099348134")]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Assembly version information
|
||||||
|
[assembly: AssemblyVersion("2.44.1.*")]
|
||||||
|
[assembly: AssemblyFileVersion("2.44.1.0")]
|
@@ -49,8 +49,6 @@ namespace ModernKeePassLib
|
|||||||
internal const int DefaultHistoryMaxItems = 10; // -1 = unlimited
|
internal const int DefaultHistoryMaxItems = 10; // -1 = unlimited
|
||||||
internal const long DefaultHistoryMaxSize = 6 * 1024 * 1024; // -1 = unlimited
|
internal const long DefaultHistoryMaxSize = 6 * 1024 * 1024; // -1 = unlimited
|
||||||
|
|
||||||
private static bool m_bPrimaryCreated = false;
|
|
||||||
|
|
||||||
// Initializations: see Clear()
|
// Initializations: see Clear()
|
||||||
private PwGroup m_pgRootGroup = null;
|
private PwGroup m_pgRootGroup = null;
|
||||||
private PwObjectList<PwDeletedObject> m_vDeletedObjects = new PwObjectList<PwDeletedObject>();
|
private PwObjectList<PwDeletedObject> m_vDeletedObjects = new PwObjectList<PwDeletedObject>();
|
||||||
|
@@ -55,20 +55,20 @@ namespace ModernKeePassLib
|
|||||||
/// e.g. 2.19 = 0x02130000.
|
/// e.g. 2.19 = 0x02130000.
|
||||||
/// It is highly recommended to use <c>FileVersion64</c> instead.
|
/// It is highly recommended to use <c>FileVersion64</c> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly uint Version32 = 0x022A0100;
|
public static readonly uint Version32 = 0x022C0000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version, encoded as 64-bit unsigned integer
|
/// Version, encoded as 64-bit unsigned integer
|
||||||
/// (component-wise, 16 bits per component).
|
/// (component-wise, 16 bits per component).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ulong FileVersion64 = 0x0002002A00010000UL;
|
public static readonly ulong FileVersion64 = 0x0002002C00000000UL;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version, encoded as string.
|
/// Version, encoded as string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string VersionString = "2.42.1";
|
public static readonly string VersionString = "2.44";
|
||||||
|
|
||||||
public static readonly string Copyright = @"Copyright © 2003-2019 Dominik Reichl";
|
public static readonly string Copyright = @"Copyright © 2003-2020 Dominik Reichl";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Product website URL. Terminated by a forward slash.
|
/// Product website URL. Terminated by a forward slash.
|
||||||
|
@@ -21,7 +21,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
#if !KeePassUAP
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
using ModernKeePassLib.Interfaces;
|
using ModernKeePassLib.Interfaces;
|
||||||
@@ -936,7 +938,7 @@ namespace ModernKeePassLib
|
|||||||
|
|
||||||
if(m_bCompareNaturally) return StrUtil.CompareNaturally(strA, strB);
|
if(m_bCompareNaturally) return StrUtil.CompareNaturally(strA, strB);
|
||||||
|
|
||||||
#if ModernKeePassLib || KeePassRT
|
#if ModernKeePassLib
|
||||||
return string.Compare(strA, strB, m_bCaseInsensitive ?
|
return string.Compare(strA, strB, m_bCaseInsensitive ?
|
||||||
StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture);
|
StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture);
|
||||||
#else
|
#else
|
||||||
|
@@ -21,10 +21,6 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
#if !KeePassUAP
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
using ModernKeePassLib.Cryptography.Cipher;
|
using ModernKeePassLib.Cryptography.Cipher;
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
|
@@ -394,8 +394,8 @@ namespace ModernKeePassLib.Security
|
|||||||
if(a == null) throw new ArgumentNullException("a");
|
if(a == null) throw new ArgumentNullException("a");
|
||||||
if(b == null) throw new ArgumentNullException("b");
|
if(b == null) throw new ArgumentNullException("b");
|
||||||
|
|
||||||
if(b.IsEmpty) return a;
|
if(b.IsEmpty) return a.WithProtection(a.IsProtected || b.IsProtected);
|
||||||
if(a.IsEmpty) return b;
|
if(a.IsEmpty) return b.WithProtection(a.IsProtected || b.IsProtected);
|
||||||
if(!a.IsProtected && !b.IsProtected)
|
if(!a.IsProtected && !b.IsProtected)
|
||||||
return new ProtectedString(false, a.ReadString() + b.ReadString());
|
return new ProtectedString(false, a.ReadString() + b.ReadString());
|
||||||
|
|
||||||
|
@@ -23,7 +23,8 @@ using System.ComponentModel;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
#if (!ModernKeePassLib && !KeePassUAP)
|
|
||||||
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -220,15 +221,15 @@ namespace ModernKeePassLib.Serialization
|
|||||||
// FileAttributes faBase = FileAttributes.Normal;
|
// FileAttributes faBase = FileAttributes.Normal;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if !ModernKeePassLib
|
#if !(ModernKeePassLib || KeePassUAP)
|
||||||
FileAttributes faBase = File.GetAttributes(m_iocBase.Path);
|
FileAttributes faBase = File.GetAttributes(m_iocBase.Path);
|
||||||
bEfsEncrypted = ((long)(faBase & FileAttributes.Encrypted) != 0);
|
bEfsEncrypted = ((long)(faBase & FileAttributes.Encrypted) != 0);
|
||||||
try { if(bEfsEncrypted) File.Decrypt(m_iocBase.Path); } // For TxF
|
try { if(bEfsEncrypted) File.Decrypt(m_iocBase.Path); } // For TxF
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
#endif
|
|
||||||
otCreation = File.GetCreationTimeUtc(m_iocBase.Path);
|
otCreation = File.GetCreationTimeUtc(m_iocBase.Path);
|
||||||
sStat = SimpleStat.Get(m_iocBase.Path);
|
sStat = SimpleStat.Get(m_iocBase.Path);
|
||||||
#if !ModernKeePassLib
|
|
||||||
// May throw with Mono
|
// May throw with Mono
|
||||||
FileSecurity sec = File.GetAccessControl(m_iocBase.Path, acs);
|
FileSecurity sec = File.GetAccessControl(m_iocBase.Path, acs);
|
||||||
if(sec != null) pbSec = sec.GetSecurityDescriptorBinaryForm();
|
if(sec != null) pbSec = sec.GetSecurityDescriptorBinaryForm();
|
||||||
@@ -522,7 +523,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#if !ModernKeePassLib
|
||||||
internal static void ClearOld()
|
internal static void ClearOld()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -545,5 +546,6 @@ namespace ModernKeePassLib.Serialization
|
|||||||
}
|
}
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,9 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if ModernKeePassLib
|
||||||
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
|
#elif !KeePassUAP
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
private Stream m_sBase;
|
private Stream m_sBase;
|
||||||
private readonly bool m_bWriting;
|
private readonly bool m_bWriting;
|
||||||
private readonly bool m_bVerify;
|
private readonly bool m_bVerify;
|
||||||
private byte[] m_pbKey;
|
private readonly byte[] m_pbKey;
|
||||||
|
|
||||||
private bool m_bEos = false;
|
private bool m_bEos = false;
|
||||||
private byte[] m_pbBuffer;
|
private byte[] m_pbBuffer;
|
||||||
|
@@ -24,6 +24,7 @@ using System.IO;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassUAP)
|
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassUAP)
|
||||||
using System.Net.Cache;
|
using System.Net.Cache;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
@@ -33,12 +34,16 @@ using System.Net.Security;
|
|||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ModernKeePassLib
|
||||||
|
using Windows.Storage;
|
||||||
|
using Windows.Storage.Streams;
|
||||||
|
#endif
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
namespace ModernKeePassLib.Serialization
|
namespace ModernKeePassLib.Serialization
|
||||||
{
|
{
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
internal sealed class IOWebClient : WebClient
|
internal sealed class IOWebClient : WebClient
|
||||||
{
|
{
|
||||||
private IOConnectionInfo m_ioc;
|
private IOConnectionInfo m_ioc;
|
||||||
@@ -240,7 +245,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
|
|
||||||
public static class IOConnection
|
public static class IOConnection
|
||||||
{
|
{
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
private static ProxyServerType m_pstProxyType = ProxyServerType.System;
|
private static ProxyServerType m_pstProxyType = ProxyServerType.System;
|
||||||
private static string m_strProxyAddr = string.Empty;
|
private static string m_strProxyAddr = string.Empty;
|
||||||
private static string m_strProxyPort = string.Empty;
|
private static string m_strProxyPort = string.Empty;
|
||||||
@@ -269,7 +274,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
|
|
||||||
public static event EventHandler<IOAccessEventArgs> IOAccessPre;
|
public static event EventHandler<IOAccessEventArgs> IOAccessPre;
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
// Allow self-signed certificates, expired certificates, etc.
|
// Allow self-signed certificates, expired certificates, etc.
|
||||||
private static bool AcceptCertificate(object sender,
|
private static bool AcceptCertificate(object sender,
|
||||||
X509Certificate certificate, X509Chain chain,
|
X509Certificate certificate, X509Chain chain,
|
||||||
@@ -603,7 +608,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
public static Stream OpenWrite(IOConnectionInfo ioc)
|
public static Stream OpenWrite(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
if(ioc == null) { Debug.Assert(false); return null; }
|
if(ioc == null) { Debug.Assert(false); return null; }
|
||||||
@@ -802,7 +807,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
private static bool SendCommand(IOConnectionInfo ioc, string strMethod)
|
private static bool SendCommand(IOConnectionInfo ioc, string strMethod)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -910,6 +915,6 @@ namespace ModernKeePassLib.Serialization
|
|||||||
return (wr is FileWebRequest);
|
return (wr is FileWebRequest);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // ModernKeePass
|
#endif // ModernKeePassLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
|
Copyright (C) 2003-2018 Dominik Reichl <dominik.reichl@t-online.de>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -30,14 +30,13 @@ using System.Drawing;
|
|||||||
|
|
||||||
using ModernKeePassLib;
|
using ModernKeePassLib;
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
|
using ModernKeePassLib.Cryptography;
|
||||||
|
using ModernKeePassLib.Cryptography.Cipher;
|
||||||
using ModernKeePassLib.Interfaces;
|
using ModernKeePassLib.Interfaces;
|
||||||
using ModernKeePassLib.Resources;
|
using ModernKeePassLib.Resources;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography;
|
|
||||||
using ModernKeePassLib.Cryptography.Cipher;
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Serialization
|
namespace ModernKeePassLib.Serialization
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -758,13 +757,21 @@ namespace ModernKeePassLib.Serialization
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_bReadNextNode = false; // ReadElementString skips end tag
|
m_bReadNextNode = false; // ReadElementString skips end tag
|
||||||
|
#if ModernKeePassLib
|
||||||
|
return xr.ReadElementContentAsString();
|
||||||
|
#else
|
||||||
return xr.ReadElementString();
|
return xr.ReadElementString();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ReadStringRaw(XmlReader xr)
|
private string ReadStringRaw(XmlReader xr)
|
||||||
{
|
{
|
||||||
m_bReadNextNode = false; // ReadElementString skips end tag
|
m_bReadNextNode = false; // ReadElementString skips end tag
|
||||||
|
#if ModernKeePassLib
|
||||||
|
return xr.ReadElementContentAsString();
|
||||||
|
#else
|
||||||
return xr.ReadElementString();
|
return xr.ReadElementString();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] ReadBase64(XmlReader xr, bool bRaw)
|
private byte[] ReadBase64(XmlReader xr, bool bRaw)
|
||||||
|
@@ -26,7 +26,7 @@ using System.Security;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if !ModernKeePassLib && !KeePassUAP
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
@@ -204,7 +204,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
throw new ArgumentOutOfRangeException("fmt");
|
throw new ArgumentOutOfRangeException("fmt");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_xmlWriter = XmlUtilEx.CreateXmlWriter(sXml);
|
m_xmlWriter = XmlUtilEx.CreateXmlWriter(sXml, m_uFileVersion >= FileVersion32_4);
|
||||||
|
|
||||||
WriteDocument(pgRoot);
|
WriteDocument(pgRoot);
|
||||||
|
|
||||||
|
@@ -26,8 +26,9 @@ using System.Security;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
#if !KeePassUAP
|
#if ModernKeePassLib
|
||||||
using System.Security.Cryptography;
|
using Windows.Storage;
|
||||||
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
@@ -511,11 +512,33 @@ namespace ModernKeePassLib.Serialization
|
|||||||
|
|
||||||
++iTry;
|
++iTry;
|
||||||
}
|
}
|
||||||
|
#if ModernKeePassLib
|
||||||
|
while (StorageFile.GetFileFromPathAsync(strPath).GetResults() != null);
|
||||||
|
#else
|
||||||
while(File.Exists(strPath));
|
while(File.Exists(strPath));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ModernKeePassLib
|
||||||
|
byte[] pbData = pb.ReadData();
|
||||||
|
/*var file = FileSystem.Current.GetFileFromPathAsync(strPath).Result;
|
||||||
|
using (var stream = file.OpenAsync(FileAccess.ReadAndWrite).Result) {*/
|
||||||
|
var file = StorageFile.GetFileFromPathAsync(strPath).GetAwaiter().GetResult();
|
||||||
|
using (var stream = file.OpenAsync(FileAccessMode.ReadWrite).GetAwaiter().GetResult().AsStream())
|
||||||
|
{
|
||||||
|
stream.Write (pbData, 0, pbData.Length);
|
||||||
|
}
|
||||||
|
MemUtil.ZeroByteArray(pbData);
|
||||||
|
#elif !KeePassLibSD
|
||||||
|
byte[] pbData = pb.ReadData();
|
||||||
|
File.WriteAllBytes(strPath, pbData);
|
||||||
|
MemUtil.ZeroByteArray(pbData);
|
||||||
|
#else
|
||||||
|
FileStream fs = new FileStream(strPath, FileMode.Create,
|
||||||
|
FileAccess.Write, FileShare.None);
|
||||||
byte[] pbData = pb.ReadData();
|
byte[] pbData = pb.ReadData();
|
||||||
try { File.WriteAllBytes(strPath, pbData); }
|
try { File.WriteAllBytes(strPath, pbData); }
|
||||||
finally { if(pb.IsProtected) MemUtil.ZeroByteArray(pbData); }
|
finally { if(pb.IsProtected) MemUtil.ZeroByteArray(pbData); }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -174,7 +174,7 @@ namespace ModernKeePassLib.Translation
|
|||||||
return new Dictionary<string, string>();
|
return new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (!KeePassLibSD && !KeePassUAP)
|
#if (!KeePassLibSD && !KeePassUAP !&&ModernKeePassLib)
|
||||||
public void ApplyTo(Form form)
|
public void ApplyTo(Form form)
|
||||||
{
|
{
|
||||||
if(form == null) throw new ArgumentNullException("form");
|
if(form == null) throw new ArgumentNullException("form");
|
||||||
|
@@ -180,7 +180,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
internal static DialogResult SafeShowMessageBox(string strText, string strTitle,
|
internal static DialogResult SafeShowMessageBox(string strText, string strTitle,
|
||||||
MessageBoxButtons mb, MessageBoxIcon mi, MessageBoxDefaultButton mdb)
|
MessageBoxButtons mb, MessageBoxIcon mi, MessageBoxDefaultButton mdb)
|
||||||
{
|
{
|
||||||
#if (KeePassLibSD || KeePassRT)
|
#if KeePassLibSD
|
||||||
return MessageBox.Show(strText, strTitle, mb, mi, mdb);
|
return MessageBox.Show(strText, strTitle, mb, mi, mdb);
|
||||||
#else
|
#else
|
||||||
IWin32Window wnd = null;
|
IWin32Window wnd = null;
|
||||||
@@ -215,7 +215,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (!KeePassLibSD && !KeePassRT)
|
#if !KeePassLibSD
|
||||||
internal delegate DialogResult SafeShowMessageBoxInternalDelegate(IWin32Window iParent,
|
internal delegate DialogResult SafeShowMessageBoxInternalDelegate(IWin32Window iParent,
|
||||||
string strText, string strTitle, MessageBoxButtons mb, MessageBoxIcon mi,
|
string strText, string strTitle, MessageBoxButtons mb, MessageBoxIcon mi,
|
||||||
MessageBoxDefaultButton mdb);
|
MessageBoxDefaultButton mdb);
|
||||||
|
@@ -340,7 +340,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
if(!MonoWorkarounds.IsRequired()) return;
|
if(!MonoWorkarounds.IsRequired()) return;
|
||||||
if(f == null) { Debug.Assert(false); return; }
|
if(f == null) { Debug.Assert(false); return; }
|
||||||
|
|
||||||
#if (!KeePassLibSD && !KeePassRT)
|
#if !KeePassLibSD
|
||||||
f.HandleCreated += MonoWorkarounds.OnFormHandleCreated;
|
f.HandleCreated += MonoWorkarounds.OnFormHandleCreated;
|
||||||
SetWmClass(f);
|
SetWmClass(f);
|
||||||
|
|
||||||
@@ -353,14 +353,14 @@ namespace ModernKeePassLib.Utility
|
|||||||
if(!MonoWorkarounds.IsRequired()) return;
|
if(!MonoWorkarounds.IsRequired()) return;
|
||||||
if(f == null) { Debug.Assert(false); return; }
|
if(f == null) { Debug.Assert(false); return; }
|
||||||
|
|
||||||
#if (!KeePassLibSD && !KeePassRT)
|
#if !KeePassLibSD
|
||||||
f.HandleCreated -= MonoWorkarounds.OnFormHandleCreated;
|
f.HandleCreated -= MonoWorkarounds.OnFormHandleCreated;
|
||||||
|
|
||||||
ApplyToControlsRec(f.Controls, f, MonoWorkarounds.ReleaseControl);
|
ApplyToControlsRec(f.Controls, f, MonoWorkarounds.ReleaseControl);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (!KeePassLibSD && !KeePassRT)
|
#if !KeePassLibSD
|
||||||
private delegate void MwaControlHandler(Control c, Form fContext);
|
private delegate void MwaControlHandler(Control c, Form fContext);
|
||||||
|
|
||||||
private static void ApplyToControlsRec(Control.ControlCollection cc,
|
private static void ApplyToControlsRec(Control.ControlCollection cc,
|
||||||
|
@@ -25,13 +25,14 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if !KeePassUAP
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
#if ModernKeePassLib
|
||||||
|
using ModernKeePassLib.Cryptography;
|
||||||
|
#else
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
using ModernKeePassLib.Cryptography;
|
|
||||||
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
@@ -224,7 +225,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
Encoding.Default,
|
Encoding.Default,
|
||||||
(uint)Encoding.Default.GetBytes("a").Length, null));
|
(uint)Encoding.Default.GetBytes("a").Length, null));
|
||||||
#endif
|
#endif
|
||||||
#if !ModernKeePassLib && !KeePassRT
|
#if !ModernKeePassLib
|
||||||
l.Add(new StrEncodingInfo(StrEncodingType.Ascii,
|
l.Add(new StrEncodingInfo(StrEncodingType.Ascii,
|
||||||
"ASCII", Encoding.ASCII, 1, null));
|
"ASCII", Encoding.ASCII, 1, null));
|
||||||
l.Add(new StrEncodingInfo(StrEncodingType.Utf7,
|
l.Add(new StrEncodingInfo(StrEncodingType.Utf7,
|
||||||
@@ -238,7 +239,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
l.Add(new StrEncodingInfo(StrEncodingType.Utf16BE,
|
l.Add(new StrEncodingInfo(StrEncodingType.Utf16BE,
|
||||||
"Unicode (UTF-16 BE)", new UnicodeEncoding(true, false),
|
"Unicode (UTF-16 BE)", new UnicodeEncoding(true, false),
|
||||||
2, new byte[] { 0xFE, 0xFF }));
|
2, new byte[] { 0xFE, 0xFF }));
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
l.Add(new StrEncodingInfo(StrEncodingType.Utf32LE,
|
l.Add(new StrEncodingInfo(StrEncodingType.Utf32LE,
|
||||||
"Unicode (UTF-32 LE)", new UTF32Encoding(false, false),
|
"Unicode (UTF-32 LE)", new UTF32Encoding(false, false),
|
||||||
4, new byte[] { 0xFF, 0xFE, 0x0, 0x0 }));
|
4, new byte[] { 0xFF, 0xFE, 0x0, 0x0 }));
|
||||||
@@ -849,10 +850,8 @@ namespace ModernKeePassLib.Utility
|
|||||||
Debug.Assert(strY != null);
|
Debug.Assert(strY != null);
|
||||||
if(strY == null) throw new ArgumentNullException("strY");
|
if(strY == null) throw new ArgumentNullException("strY");
|
||||||
|
|
||||||
#if !ModernKeePassLib
|
|
||||||
if(NativeMethods.SupportsStrCmpNaturally)
|
if(NativeMethods.SupportsStrCmpNaturally)
|
||||||
return NativeMethods.StrCmpNaturally(strX, strY);
|
return NativeMethods.StrCmpNaturally(strX, strY);
|
||||||
#endif
|
|
||||||
|
|
||||||
int cX = strX.Length;
|
int cX = strX.Length;
|
||||||
int cY = strY.Length;
|
int cY = strY.Length;
|
||||||
@@ -1376,7 +1375,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
byte[] pbEnc = CryptoUtil.ProtectData(pbPlain, m_pbOptEnt,
|
byte[] pbEnc = CryptoUtil.ProtectData(pbPlain, m_pbOptEnt,
|
||||||
DataProtectionScope.CurrentUser);
|
DataProtectionScope.CurrentUser);
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
return Convert.ToBase64String(pbEnc, Base64FormattingOptions.None);
|
return Convert.ToBase64String(pbEnc, Base64FormattingOptions.None);
|
||||||
#else
|
#else
|
||||||
return Convert.ToBase64String(pbEnc);
|
return Convert.ToBase64String(pbEnc);
|
||||||
@@ -1489,7 +1488,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
Array.Reverse(pb);
|
Array.Reverse(pb);
|
||||||
for(int i = 0; i < pb.Length; ++i) pb[i] = (byte)(pb[i] ^ 0x65);
|
for(int i = 0; i < pb.Length; ++i) pb[i] = (byte)(pb[i] ^ 0x65);
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
return Convert.ToBase64String(pb, Base64FormattingOptions.None);
|
return Convert.ToBase64String(pb, Base64FormattingOptions.None);
|
||||||
#else
|
#else
|
||||||
return Convert.ToBase64String(pb);
|
return Convert.ToBase64String(pb);
|
||||||
@@ -1649,7 +1648,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
if(strMediaType == null) strMediaType = "application/octet-stream";
|
if(strMediaType == null) strMediaType = "application/octet-stream";
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
return ("data:" + strMediaType + ";base64," + Convert.ToBase64String(
|
return ("data:" + strMediaType + ";base64," + Convert.ToBase64String(
|
||||||
pbData, Base64FormattingOptions.None));
|
pbData, Base64FormattingOptions.None));
|
||||||
#else
|
#else
|
||||||
@@ -1680,7 +1679,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
|
|
||||||
#if ModernKeePassLib || KeePassRT
|
#if ModernKeePassLib
|
||||||
Encoding enc = StrUtil.Utf8;
|
Encoding enc = StrUtil.Utf8;
|
||||||
#else
|
#else
|
||||||
Encoding enc = Encoding.ASCII;
|
Encoding enc = Encoding.ASCII;
|
||||||
|
17
ModernKeePassLib/Utility/StreamExtensions.cs
Normal file
17
ModernKeePassLib/Utility/StreamExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.IO;
|
||||||
|
using Windows.Storage.Streams;
|
||||||
|
|
||||||
|
namespace ModernKeePassLibPCL.Utility
|
||||||
|
{
|
||||||
|
public static class StreamExtensions
|
||||||
|
{
|
||||||
|
public static Stream AsStream(this IRandomAccessStream inputStream)
|
||||||
|
{
|
||||||
|
var reader = new DataReader(inputStream.GetInputStreamAt(0));
|
||||||
|
var bytes = new byte[inputStream.Size];
|
||||||
|
reader.LoadAsync((uint)inputStream.Size).GetResults();
|
||||||
|
reader.ReadBytes(bytes);
|
||||||
|
return new MemoryStream(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -25,6 +25,10 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
#if ModernKeePassLib
|
||||||
|
using Windows.Storage;
|
||||||
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
|
|
||||||
namespace ModernKeePassLib.Utility
|
namespace ModernKeePassLib.Utility
|
||||||
@@ -40,7 +44,11 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
public static char LocalDirSepChar
|
public static char LocalDirSepChar
|
||||||
{
|
{
|
||||||
|
#if ModernKeePassLib
|
||||||
|
get { return '\\'; }
|
||||||
|
#else
|
||||||
get { return Path.DirectorySeparatorChar; }
|
get { return Path.DirectorySeparatorChar; }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static char[] g_vDirSepChars = null;
|
private static char[] g_vDirSepChars = null;
|
||||||
@@ -58,7 +66,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
if(!l.Contains(UrlUtil.LocalDirSepChar))
|
if(!l.Contains(UrlUtil.LocalDirSepChar))
|
||||||
{
|
{
|
||||||
//Debug.Assert(false);
|
Debug.Assert(false);
|
||||||
l.Add(UrlUtil.LocalDirSepChar);
|
l.Add(UrlUtil.LocalDirSepChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,12 +286,13 @@ namespace ModernKeePassLib.Utility
|
|||||||
if(strUrl == null) { Debug.Assert(false); throw new ArgumentNullException("strUrl"); }
|
if(strUrl == null) { Debug.Assert(false); throw new ArgumentNullException("strUrl"); }
|
||||||
if(strUrl.Length == 0) { Debug.Assert(false); return string.Empty; }
|
if(strUrl.Length == 0) { Debug.Assert(false); return string.Empty; }
|
||||||
|
|
||||||
|
#if !ModernKeePassLib
|
||||||
if(!strUrl.StartsWith(Uri.UriSchemeFile + ":", StrUtil.CaseIgnoreCmp))
|
if(!strUrl.StartsWith(Uri.UriSchemeFile + ":", StrUtil.CaseIgnoreCmp))
|
||||||
{
|
{
|
||||||
Debug.Assert(false);
|
Debug.Assert(false);
|
||||||
return strUrl;
|
return strUrl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Uri uri = new Uri(strUrl);
|
Uri uri = new Uri(strUrl);
|
||||||
@@ -298,7 +307,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
public static bool UnhideFile(string strFile)
|
public static bool UnhideFile(string strFile)
|
||||||
{
|
{
|
||||||
#if (ModernKeePassLib || KeePassLibSD)
|
#if ModernKeePassLib || KeePassLibSD
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if(strFile == null) throw new ArgumentNullException("strFile");
|
if(strFile == null) throw new ArgumentNullException("strFile");
|
||||||
@@ -318,7 +327,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
public static bool HideFile(string strFile, bool bHide)
|
public static bool HideFile(string strFile, bool bHide)
|
||||||
{
|
{
|
||||||
#if (ModernKeePassLib || KeePassLibSD)
|
#if ModernKeePassLib || KeePassLibSD
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if(strFile == null) throw new ArgumentNullException("strFile");
|
if(strFile == null) throw new ArgumentNullException("strFile");
|
||||||
@@ -484,7 +493,16 @@ namespace ModernKeePassLib.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
string str;
|
string str;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#if ModernKeePassLib
|
||||||
|
var dirT = StorageFolder.GetFolderFromPathAsync(
|
||||||
|
strPath).GetResults();
|
||||||
|
str = dirT.Path;
|
||||||
|
#else
|
||||||
try { str = Path.GetFullPath(strPath); }
|
try { str = Path.GetFullPath(strPath); }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
catch(Exception) { Debug.Assert(false); return strPath; }
|
catch(Exception) { Debug.Assert(false); return strPath; }
|
||||||
|
|
||||||
Debug.Assert((str.IndexOf("\\..\\") < 0) || NativeLib.IsUnix());
|
Debug.Assert((str.IndexOf("\\..\\") < 0) || NativeLib.IsUnix());
|
||||||
@@ -692,11 +710,10 @@ namespace ModernKeePassLib.Utility
|
|||||||
string strDir;
|
string strDir;
|
||||||
if(NativeLib.IsUnix())
|
if(NativeLib.IsUnix())
|
||||||
strDir = NativeMethods.GetUserRuntimeDir();
|
strDir = NativeMethods.GetUserRuntimeDir();
|
||||||
#if KeePassUAP
|
#if KeePassUAP || ModernKeePassLib
|
||||||
else strDir = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
|
else strDir = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
|
||||||
#else
|
#else
|
||||||
else strDir = Path.GetTempPath();
|
else strDir = Path.GetTempPath();
|
||||||
#endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -704,10 +721,11 @@ namespace ModernKeePassLib.Utility
|
|||||||
}
|
}
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
|
|
||||||
|
#endif
|
||||||
return strDir;
|
return strDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !KeePassLibSD
|
#if !ModernKeePassLib && !KeePassLibSD
|
||||||
// Structurally mostly equivalent to UrlUtil.GetFileInfos
|
// Structurally mostly equivalent to UrlUtil.GetFileInfos
|
||||||
public static List<string> GetFilePaths(string strDir, string strPattern,
|
public static List<string> GetFilePaths(string strDir, string strPattern,
|
||||||
SearchOption opt)
|
SearchOption opt)
|
||||||
|
@@ -24,6 +24,7 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using Windows.Data.Xml.Dom;
|
||||||
|
|
||||||
namespace ModernKeePassLib.Utility
|
namespace ModernKeePassLib.Utility
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,9 @@ namespace ModernKeePassLib.Utility
|
|||||||
// .NET 4.5.2 and newer do not resolve external XML resources
|
// .NET 4.5.2 and newer do not resolve external XML resources
|
||||||
// by default; for older .NET versions, we explicitly
|
// by default; for older .NET versions, we explicitly
|
||||||
// prevent resolving
|
// prevent resolving
|
||||||
|
#if !ModernKeePassLib
|
||||||
d.XmlResolver = null; // Default in old .NET: XmlUrlResolver object
|
d.XmlResolver = null; // Default in old .NET: XmlUrlResolver object
|
||||||
|
#endif
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@@ -56,11 +59,11 @@ namespace ModernKeePassLib.Utility
|
|||||||
// Also see PrepMonoDev.sh script
|
// Also see PrepMonoDev.sh script
|
||||||
xrs.ProhibitDtd = true; // Obsolete in .NET 4, but still there
|
xrs.ProhibitDtd = true; // Obsolete in .NET 4, but still there
|
||||||
// xrs.DtdProcessing = DtdProcessing.Prohibit; // .NET 4 only
|
// xrs.DtdProcessing = DtdProcessing.Prohibit; // .NET 4 only
|
||||||
#endif
|
|
||||||
|
|
||||||
xrs.ValidationType = ValidationType.None;
|
xrs.ValidationType = ValidationType.None;
|
||||||
xrs.XmlResolver = null;
|
xrs.XmlResolver = null;
|
||||||
|
|
||||||
|
#endif
|
||||||
return xrs;
|
return xrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,24 +74,28 @@ namespace ModernKeePassLib.Utility
|
|||||||
return XmlReader.Create(s, CreateXmlReaderSettings());
|
return XmlReader.Create(s, CreateXmlReaderSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlWriterSettings CreateXmlWriterSettings()
|
public static XmlWriterSettings CreateXmlWriterSettings(bool isVersionGreaterThan4 = false)
|
||||||
{
|
{
|
||||||
XmlWriterSettings xws = new XmlWriterSettings();
|
XmlWriterSettings xws = new XmlWriterSettings();
|
||||||
|
|
||||||
xws.CloseOutput = false;
|
xws.CloseOutput = isVersionGreaterThan4;
|
||||||
xws.Encoding = StrUtil.Utf8;
|
xws.Encoding = StrUtil.Utf8;
|
||||||
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;
|
||||||
|
#endif
|
||||||
|
|
||||||
return xws;
|
return xws;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlWriter CreateXmlWriter(Stream s)
|
public static XmlWriter CreateXmlWriter(Stream s, bool isVersionGreaterThan4 = false)
|
||||||
{
|
{
|
||||||
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
||||||
|
|
||||||
return XmlWriter.Create(s, CreateXmlWriterSettings());
|
return XmlWriter.Create(s, CreateXmlWriterSettings(isVersionGreaterThan4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Serialize<T>(Stream s, T t)
|
public static void Serialize<T>(Stream s, T t)
|
||||||
|
139
ModernKeePassLib/app.config
Normal file
139
ModernKeePassLib/app.config
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.WindowsRuntime" publicKeyToken="B77A5C561934E089" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Xml.XmlSerializer" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.InteropServices.WindowsRuntime" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Linq" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Text.Encoding.Extensions" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Collections" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Resources.ResourceManager" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Diagnostics.Tracing" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Reflection.Primitives" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.IO" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.ObjectModel" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.IO.Compression" publicKeyToken="B77A5C561934E089" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Text.Encoding" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Linq.Expressions" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Collections.Concurrent" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Reflection" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Text.RegularExpressions" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading.Timer" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Globalization" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Diagnostics.Debug" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Net.Primitives" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Reflection.Extensions" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Diagnostics.Tools" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Xml.XDocument" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.Numerics" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Validation" publicKeyToken="2fc06f0d701809a7" culture="neutral"/>
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
17
ModernKeePassLib/project.json
Normal file
17
ModernKeePassLib/project.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"supports": {},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.Portable.Compatibility": "1.0.2",
|
||||||
|
"NETStandard.Library": "2.0.3",
|
||||||
|
"Portable.BouncyCastle": "1.8.2",
|
||||||
|
"SixLabors.ImageSharp": "1.0.0-beta0005",
|
||||||
|
"Splat": "3.0.0",
|
||||||
|
"System.Runtime.WindowsRuntime": "4.3.0",
|
||||||
|
"System.Xml.ReaderWriter": "4.3.1",
|
||||||
|
"System.Xml.XmlSerializer": "4.3.0",
|
||||||
|
"Validation": "2.4.18"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.2": {}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user