Changed test project type to WIndows 8.1

Changed test project framework from Nunit to MSTest
Changed HashAlgorithm from BouncyCastle to WinRT crypto
WIP progress bar in opendatabaseusercontrol
TextBox with button made generic
WIP implement copy on button click in Entry Page
This commit is contained in:
2017-11-06 19:01:01 +01:00
committed by BONNEVILLE Geoffroy
parent 53a54252e3
commit 8e690747e2
85 changed files with 2836 additions and 672 deletions

View File

@@ -1,22 +1,15 @@
using System;
using System.IO;
using System.Security;
using System.IO;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Serialization;
using ModernKeePassLib.Utility;
#if KeePassLib
using KeePassLib.Cryptography.Cipher;
#else
using ModernKeePassLib.Cryptography.Cipher;
#endif
using NUnit.Framework;
using ModernKeePassLib.Utility;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace ModernKeePassLib.Test.Cryptography.Cipher
{
[TestFixture()]
[TestClass()]
public class StandardAesEngineTests
{
// Test vector (official ECB test vector #356)
@@ -24,7 +17,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7
};
[Test]
[TestMethod]
public void TestEncryptStream()
{
byte[] pbIV = new byte[16];
@@ -36,13 +29,13 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aes = new StandardAesEngine();
var inStream = aes.EncryptStream(outStream, pbTestKey, pbIV);
new BinaryWriter(inStream).Write(pbTestData);
//Assert.That(outStream.Position, Is.EqualTo(16));
Assert.AreEqual(outStream.Position, 16);
outStream.Position = 0;
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.That(outBytes, Is.EqualTo(pbReferenceCT));
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbReferenceCT));
}
[Test]
[TestMethod]
public void TestDecryptStream()
{
byte[] pbIV = new byte[16];
@@ -57,10 +50,10 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aes = new StandardAesEngine();
var outStream = aes.DecryptStream(inStream, pbTestKey, pbIV);
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.That(outBytes, Is.EqualTo(pbTestData));
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbTestData));
}
[Test]
[TestMethod]
public void TestBouncyCastleAes()
{
byte[] pbIV = new byte[16];
@@ -75,10 +68,9 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aesEngine = new AesEngine();
//var parametersWithIv = new ParametersWithIV(new KeyParameter(pbTestKey), pbIV);
aesEngine.Init(true, new KeyParameter(pbTestKey));
Assert.That(aesEngine.GetBlockSize(), Is.EqualTo(pbTestData.Length));
Assert.AreEqual(aesEngine.GetBlockSize(), pbTestData.Length);
aesEngine.ProcessBlock(pbTestData, 0, pbTestData, 0);
//Assert.That(MemUtil.ArraysEqual(pbTestData, pbReferenceCT), Is.False);
Assert.That(pbTestData, Is.EqualTo(pbReferenceCT));
Assert.IsTrue(MemUtil.ArraysEqual(pbTestData, pbReferenceCT));
}
}
}