diff --git a/ModernKeePassLib.Test/Cryptography/Cipher/StandardAesEngineTests.cs b/ModernKeePassLib.Test/Cryptography/Cipher/StandardAesEngineTests.cs
index c449de6..baad1d2 100644
--- a/ModernKeePassLib.Test/Cryptography/Cipher/StandardAesEngineTests.cs
+++ b/ModernKeePassLib.Test/Cryptography/Cipher/StandardAesEngineTests.cs
@@ -13,10 +13,12 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
public class StandardAesEngineTests
{
// Test vector (official ECB test vector #356)
- private byte[] pbReferenceCT = new byte[16] {
- 0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
- 0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7
- };
+ private byte[] pbReferenceCT = new byte[16]
+ {
+ 0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
+ 0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7
+ };
+
[TestMethod]
public void TestEncryptStream()
{
@@ -29,7 +31,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aes = new StandardAesEngine();
var inStream = aes.EncryptStream(outStream, pbTestKey, pbIV);
new BinaryWriter(inStream).Write(pbTestData);
- Assert.AreEqual(outStream.Position, 16);
+ Assert.AreEqual(16, outStream.Position);
outStream.Position = 0;
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbReferenceCT));
diff --git a/ModernKeePassLib.Test/Keys/KcpKeyFileTests.cs b/ModernKeePassLib.Test/Keys/KcpKeyFileTests.cs
index 89e020d..5a363c4 100644
--- a/ModernKeePassLib.Test/Keys/KcpKeyFileTests.cs
+++ b/ModernKeePassLib.Test/Keys/KcpKeyFileTests.cs
@@ -36,7 +36,7 @@ namespace ModernKeePassLib.Test.Keys
0x31, 0xAA, 0x14, 0x3D, 0x95, 0xBF, 0x63, 0xFF
};
- var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
+ //var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
var file = ApplicationData.Current.TemporaryFolder.CreateFileAsync(TestCreateFile).GetAwaiter().GetResult();
using (var fs = file.OpenStreamForWriteAsync().GetAwaiter().GetResult())
{
@@ -50,7 +50,7 @@ namespace ModernKeePassLib.Test.Keys
try
{
- var keyFile = new KcpKeyFile(fullPath);
+ var keyFile = new KcpKeyFile(file);
var keyData = keyFile.KeyData.ReadData();
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedKeyData));
}
@@ -63,9 +63,9 @@ namespace ModernKeePassLib.Test.Keys
[TestMethod]
public void TestCreate()
{
- var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
+ //var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
var file = ApplicationData.Current.TemporaryFolder.CreateFileAsync(TestCreateFile).GetAwaiter().GetResult();
- KcpKeyFile.Create(fullPath, null);
+ KcpKeyFile.Create(file, null);
try
{
var fileContents = FileIO.ReadTextAsync(file).GetAwaiter().GetResult();
diff --git a/ModernKeePassLib.Test/ModernKeePassLib.Test.csproj b/ModernKeePassLib.Test/ModernKeePassLib.Test.csproj
index 975102f..a2e2976 100644
--- a/ModernKeePassLib.Test/ModernKeePassLib.Test.csproj
+++ b/ModernKeePassLib.Test/ModernKeePassLib.Test.csproj
@@ -152,10 +152,6 @@
..\packages\Portable.BouncyCastle.1.8.1.3\lib\netstandard1.0\BouncyCastle.Crypto.dll
True
-
- ..\packages\ModernKeePassLib.2.37.6000\lib\netstandard1.2\ModernKeePassLib.dll
- True
-
..\packages\Splat.2.0.0\lib\Portable-Win81+Wpa81\Splat.dll
True
@@ -183,6 +179,12 @@
PreserveNewest
+
+
+ {2e710089-9559-4967-846c-e763dd1f3acb}
+ ModernKeePassLib
+
+
14.0
diff --git a/ModernKeePassLib/Cryptography/SelfTest.cs b/ModernKeePassLib/Cryptography/SelfTest.cs
index 4e7f627..f975244 100644
--- a/ModernKeePassLib/Cryptography/SelfTest.cs
+++ b/ModernKeePassLib/Cryptography/SelfTest.cs
@@ -118,7 +118,7 @@ namespace ModernKeePassLib.Cryptography
for(i = 0; i < 16; ++i) pbTestData[i] = 0;
pbTestData[0] = 0x04;
-#if ModernKeePassLib
+#if ModernKeePassLib || KeePassUAP
AesEngine r = new AesEngine();
r.Init(true, new KeyParameter(pbTestKey));
if(r.GetBlockSize() != pbTestData.Length)
@@ -1032,7 +1032,7 @@ namespace ModernKeePassLib.Cryptography
private static void TestUrlUtil()
{
#if DEBUG
-#if !ModernKeePassLib
+#if !ModernKeePassLib && !KeePassUAP
Debug.Assert(Uri.UriSchemeHttp.Equals("http", StrUtil.CaseIgnoreCmp));
Debug.Assert(Uri.UriSchemeHttps.Equals("https", StrUtil.CaseIgnoreCmp));
#endif
diff --git a/ModernKeePassLib/Keys/KcpKeyFile.cs b/ModernKeePassLib/Keys/KcpKeyFile.cs
index a1fc32d..d10ccbb 100644
--- a/ModernKeePassLib/Keys/KcpKeyFile.cs
+++ b/ModernKeePassLib/Keys/KcpKeyFile.cs
@@ -23,13 +23,13 @@ using System.IO;
using System.Security;
using System.Text;
using System.Xml;
-
#if ModernKeePassLib
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
+using Windows.Storage;
#else
using System.Security.Cryptography;
#endif
@@ -68,6 +68,13 @@ namespace ModernKeePassLib.Keys
get { return m_pbKeyData; }
}
+#if ModernKeePassLib
+ public KcpKeyFile(StorageFile strKeyFile)
+ {
+ Construct(IOConnectionInfo.FromFile(strKeyFile), false);
+ }
+#endif
+
public KcpKeyFile(string strKeyFile)
{
Construct(IOConnectionInfo.FromPath(strKeyFile), false);
@@ -185,7 +192,11 @@ namespace ModernKeePassLib.Keys
/// the random key. May be null (in this case only the KeePass-internal
/// random number generator is used).
/// Returns a FileSaveResult error code.
+#if ModernKeePassLib
+ public static void Create(StorageFile strFilePath, byte[] pbAdditionalEntropy)
+#else
public static void Create(string strFilePath, byte[] pbAdditionalEntropy)
+#endif
{
byte[] pbKey32 = CryptoRandom.Instance.GetRandomBytes(32);
if(pbKey32 == null) throw new SecurityException();
@@ -293,18 +304,25 @@ namespace ModernKeePassLib.Keys
return pbKeyData;
}
-
+#if ModernKeePassLib
+ private static void CreateXmlKeyFile(StorageFile strFile, byte[] pbKeyData)
+#else
private static void CreateXmlKeyFile(string strFile, byte[] pbKeyData)
+#endif
{
Debug.Assert(strFile != null);
if(strFile == null) throw new ArgumentNullException("strFile");
Debug.Assert(pbKeyData != null);
if(pbKeyData == null) throw new ArgumentNullException("pbKeyData");
+#if ModernKeePassLib
+ IOConnectionInfo ioc = IOConnectionInfo.FromFile(strFile);
+#else
IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile);
+#endif
Stream sOut = IOConnection.OpenWrite(ioc);
-#if ModernKeePassLib
+#if ModernKeePassLib || KeePassUAP
XmlWriterSettings xws = new XmlWriterSettings();
xws.Encoding = StrUtil.Utf8;
xws.Indent = false;
diff --git a/ModernKeePassLib/ModernKeePassLib.nuspec b/ModernKeePassLib/ModernKeePassLib.nuspec
index fb5f5c0..d4fabc9 100644
--- a/ModernKeePassLib/ModernKeePassLib.nuspec
+++ b/ModernKeePassLib/ModernKeePassLib.nuspec
@@ -2,7 +2,7 @@
ModernKeePassLib
- 2.37.6000
+ 2.37.7000
ModernKeePassLib
Geoffroy Bonneville
Geoffroy Bonneville
@@ -10,7 +10,7 @@
https://github.com/wismna/ModernKeePass
false
Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.
- TBD
+ Can now create key files
Copyright © 2017 Geoffroy Bonneville
KeePass KeePassLib Portable PCL NetStandard