mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-05 00:20:16 -04:00
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:
@@ -27,8 +27,8 @@ namespace ModernKeePassLib.Cryptography.Hash
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
|
||||
byte[] resBuf = new byte[Hmac.GetMacSize()];
|
||||
Hmac.BlockUpdate(value, 0, length);
|
||||
Hmac.DoFinal(resBuf, 0);
|
||||
Hmac.BlockUpdate(value, offset, length);
|
||||
Hmac.DoFinal(resBuf, offset);
|
||||
|
||||
return resBuf;
|
||||
}
|
||||
|
@@ -1,15 +1,10 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto.Macs;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class HMACSHA1: HMAC
|
||||
public class HMACSHA1: HashAlgorithm
|
||||
{
|
||||
public HMACSHA1(byte[] key)
|
||||
{
|
||||
Hmac = new HMac(new Sha1Digest());
|
||||
Hmac.Init(new KeyParameter(key));
|
||||
}
|
||||
public HMACSHA1(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1).CreateHash(key.AsBuffer())) {}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,10 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto.Macs;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class HMACSHA256: HMAC
|
||||
public class HMACSHA256: HashAlgorithm
|
||||
{
|
||||
public HMACSHA256(byte[] key)
|
||||
{
|
||||
Hmac = new HMac(new Sha256Digest());
|
||||
Hmac.Init(new KeyParameter(key));
|
||||
}
|
||||
public HMACSHA256(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(key.AsBuffer())) {}
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,78 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
using Validation;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public abstract class HashAlgorithm: IDisposable
|
||||
{
|
||||
protected IDigest Digest;
|
||||
/// <summary>
|
||||
/// The platform-specific hash object.
|
||||
/// </summary>
|
||||
private readonly CryptographicHash _hash;
|
||||
|
||||
public byte[] Hash
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HashAlgorithm"/> class.
|
||||
/// </summary>
|
||||
/// <param name="hash">The platform hash.</param>
|
||||
internal HashAlgorithm(CryptographicHash hash)
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = new byte[Digest.GetDigestSize()];
|
||||
Digest.DoFinal(result, 0);
|
||||
return result;
|
||||
}
|
||||
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);
|
||||
@@ -29,33 +82,19 @@ namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
|
||||
byte[] resBuf = new byte[Digest.GetDigestSize()];
|
||||
Digest.BlockUpdate(value, 0, length);
|
||||
Digest.DoFinal(resBuf, 0);
|
||||
TransformFinalBlock(value, offset, length);
|
||||
var resBuf = GetValueAndReset();
|
||||
|
||||
return resBuf;
|
||||
}
|
||||
|
||||
|
||||
public void TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
public void Initialize()
|
||||
{
|
||||
Digest.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)
|
||||
{
|
||||
Digest.BlockUpdate(inputBuffer, inputOffset, inputCount);
|
||||
byte[] outputBytes = new byte[inputCount];
|
||||
if (inputCount != 0)
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, outputBytes, 0, inputCount);
|
||||
return outputBytes;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Digest.Reset();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,9 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class SHA256Managed : HashAlgorithm
|
||||
{
|
||||
public SHA256Managed()
|
||||
{
|
||||
Digest = new Sha256Digest();
|
||||
}
|
||||
public SHA256Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256).CreateHash()) {}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,9 @@
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Windows.Security.Cryptography.Core;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Hash
|
||||
{
|
||||
public class SHA512Managed: HashAlgorithm
|
||||
{
|
||||
public SHA512Managed()
|
||||
{
|
||||
Digest = new Sha512Digest();
|
||||
}
|
||||
public SHA512Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512).CreateHash()) {}
|
||||
}
|
||||
}
|
||||
|
@@ -268,7 +268,6 @@ namespace ModernKeePassLib.Keys
|
||||
doc.Load(ms);
|
||||
|
||||
XmlElement el = doc.DocumentElement;
|
||||
|
||||
if((el == null) || !el.Name.Equals(RootElementName)) return null;
|
||||
if(el.ChildNodes.Count < 2) return null;
|
||||
|
||||
|
@@ -4,6 +4,6 @@
|
||||
<NuGetPackageRoot>$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
</PropertyGroup>
|
||||
<ImportGroup>
|
||||
<Import Project="$(NuGetPackageRoot)\NETStandard.Library\2.0.0\build\NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)\NETStandard.Library\2.0.0\build\NETStandard.Library.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)\NETStandard.Library\2.0.1\build\NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)\NETStandard.Library\2.0.1\build\NETStandard.Library.targets')" />
|
||||
</ImportGroup>
|
||||
</Project>
|
@@ -20,17 +20,11 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#if ModernKeePassLib
|
||||
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Native;
|
||||
using ModernKeePassLib.Utility;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
#else
|
||||
using KeePassLib.Cryptography;
|
||||
using KeePassLib.Native;
|
||||
using KeePassLib.Utility;
|
||||
#endif
|
||||
|
||||
#if KeePassLibSD
|
||||
using KeePassLibSD;
|
||||
|
@@ -19,16 +19,18 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Serialization;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Translation
|
||||
@@ -112,7 +114,7 @@ namespace ModernKeePassLib.Translation
|
||||
else { Debug.Assert(false); }
|
||||
}
|
||||
|
||||
#if (!KeePassLibSD && !KeePassRT)
|
||||
#if (!KeePassLibSD && !KeePassUAP)
|
||||
internal void ApplyTo(Control c)
|
||||
{
|
||||
Debug.Assert(c != null); if(c == null) return;
|
||||
@@ -267,7 +269,7 @@ namespace ModernKeePassLib.Translation
|
||||
return m_strMemberName.CompareTo(kpOther.Name);
|
||||
}
|
||||
|
||||
#if (!KeePassLibSD && !KeePassRT)
|
||||
#if (!KeePassLibSD && !KeePassUAP)
|
||||
private static readonly Type[] m_vTextControls = new Type[] {
|
||||
typeof(MenuStrip), typeof(PictureBox), typeof(ListView),
|
||||
typeof(TreeView), typeof(ToolStrip), typeof(WebBrowser),
|
||||
|
@@ -21,10 +21,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Serialization;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Translation
|
||||
{
|
||||
@@ -67,7 +68,7 @@ namespace ModernKeePassLib.Translation
|
||||
}
|
||||
}
|
||||
|
||||
#if (!KeePassLibSD && !KeePassRT)
|
||||
#if (!KeePassLibSD && !KeePassUAP)
|
||||
private Form m_formEnglish = null;
|
||||
[XmlIgnore]
|
||||
public Form FormEnglish
|
||||
|
@@ -19,10 +19,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Windows.Forms;
|
||||
using System.Diagnostics;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Translation
|
||||
{
|
||||
@@ -66,7 +69,7 @@ namespace ModernKeePassLib.Translation
|
||||
return dict;
|
||||
}
|
||||
|
||||
#if (!KeePassLibSD && !KeePassRT)
|
||||
#if (!KeePassLibSD && !KeePassUAP)
|
||||
public void ApplyTo(ToolStripItemCollection tsic)
|
||||
{
|
||||
if(tsic == null) throw new ArgumentNullException("tsic");
|
||||
|
@@ -19,24 +19,27 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
|
||||
#if KeePassLibSD
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
#else
|
||||
using System.IO.Compression;
|
||||
#endif
|
||||
|
||||
using ModernKeePassLib.Interfaces;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
#if !KeePassLibSD
|
||||
using System.IO.Compression;
|
||||
#else
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Translation
|
||||
{
|
||||
[XmlRoot("Translation")]
|
||||
|
@@ -2,13 +2,13 @@
|
||||
"supports": {},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
|
||||
"NETStandard.Library": "2.0.0",
|
||||
"NETStandard.Library": "2.0.1",
|
||||
"Portable.BouncyCastle": "1.8.1.3",
|
||||
"Splat": "2.0.0",
|
||||
"System.Runtime.WindowsRuntime": "4.3.0",
|
||||
"System.Xml.ReaderWriter": "4.3.0",
|
||||
"System.Xml.XmlSerializer": "4.3.0",
|
||||
"Validation": "2.4.15"
|
||||
"Validation": "2.4.18"
|
||||
},
|
||||
"frameworks": {
|
||||
"netstandard1.2": {}
|
||||
|
Reference in New Issue
Block a user