mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 08:00:16 -04:00
Correct implementation of SHA512 with WinRT in KeepassLib
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@@ -40,15 +41,15 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
|||||||
"\t<Meta>\r\n" +
|
"\t<Meta>\r\n" +
|
||||||
"\t\t<Generator>" + testLocalizedAppName + "</Generator>\r\n" +
|
"\t\t<Generator>" + testLocalizedAppName + "</Generator>\r\n" +
|
||||||
"\t\t<DatabaseName>" + testDatabaseName + "</DatabaseName>\r\n" +
|
"\t\t<DatabaseName>" + testDatabaseName + "</DatabaseName>\r\n" +
|
||||||
"\t\t<DatabaseNameChanged>2015-03-14T03:15:26Z</DatabaseNameChanged>\r\n" +
|
"\t\t<DatabaseNameChanged>2017-10-23T08:03:55Z</DatabaseNameChanged>\r\n" +
|
||||||
"\t\t<DatabaseDescription>" + testDatabaseDescription + "</DatabaseDescription>\r\n" +
|
"\t\t<DatabaseDescription>" + testDatabaseDescription + "</DatabaseDescription>\r\n" +
|
||||||
"\t\t<DatabaseDescriptionChanged>2015-03-14T03:15:26Z</DatabaseDescriptionChanged>\r\n" +
|
"\t\t<DatabaseDescriptionChanged>2017-10-23T08:03:55Z</DatabaseDescriptionChanged>\r\n" +
|
||||||
"\t\t<DefaultUserName>" + testDefaultUserName + "</DefaultUserName>\r\n" +
|
"\t\t<DefaultUserName>" + testDefaultUserName + "</DefaultUserName>\r\n" +
|
||||||
"\t\t<DefaultUserNameChanged>2015-03-14T03:15:26Z</DefaultUserNameChanged>\r\n" +
|
"\t\t<DefaultUserNameChanged>2017-10-23T08:03:55Z</DefaultUserNameChanged>\r\n" +
|
||||||
"\t\t<MaintenanceHistoryDays>365</MaintenanceHistoryDays>\r\n" +
|
"\t\t<MaintenanceHistoryDays>365</MaintenanceHistoryDays>\r\n" +
|
||||||
//"\t\t<Color>" + testColor + "</Color>\r\n" +
|
//"\t\t<Color>" + testColor + "</Color>\r\n" +
|
||||||
"\t\t<Color></Color>\r\n" +
|
"\t\t<Color></Color>\r\n" +
|
||||||
"\t\t<MasterKeyChanged>2015-03-14T03:15:26Z</MasterKeyChanged>\r\n" +
|
"\t\t<MasterKeyChanged>2017-10-23T08:03:55Z</MasterKeyChanged>\r\n" +
|
||||||
"\t\t<MasterKeyChangeRec>-1</MasterKeyChangeRec>\r\n" +
|
"\t\t<MasterKeyChangeRec>-1</MasterKeyChangeRec>\r\n" +
|
||||||
"\t\t<MasterKeyChangeForce>-1</MasterKeyChangeForce>\r\n" +
|
"\t\t<MasterKeyChangeForce>-1</MasterKeyChangeForce>\r\n" +
|
||||||
"\t\t<MemoryProtection>\r\n" +
|
"\t\t<MemoryProtection>\r\n" +
|
||||||
@@ -60,9 +61,9 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
|||||||
"\t\t</MemoryProtection>\r\n" +
|
"\t\t</MemoryProtection>\r\n" +
|
||||||
"\t\t<RecycleBinEnabled>True</RecycleBinEnabled>\r\n" +
|
"\t\t<RecycleBinEnabled>True</RecycleBinEnabled>\r\n" +
|
||||||
"\t\t<RecycleBinUUID>AAAAAAAAAAAAAAAAAAAAAA==</RecycleBinUUID>\r\n" +
|
"\t\t<RecycleBinUUID>AAAAAAAAAAAAAAAAAAAAAA==</RecycleBinUUID>\r\n" +
|
||||||
"\t\t<RecycleBinChanged>2015-03-14T03:15:26Z</RecycleBinChanged>\r\n" +
|
"\t\t<RecycleBinChanged>2017-10-23T08:03:55Z</RecycleBinChanged>\r\n" +
|
||||||
"\t\t<EntryTemplatesGroup>AAAAAAAAAAAAAAAAAAAAAA==</EntryTemplatesGroup>\r\n" +
|
"\t\t<EntryTemplatesGroup>AAAAAAAAAAAAAAAAAAAAAA==</EntryTemplatesGroup>\r\n" +
|
||||||
"\t\t<EntryTemplatesGroupChanged>2015-03-14T03:15:26Z</EntryTemplatesGroupChanged>\r\n" +
|
"\t\t<EntryTemplatesGroupChanged>2017-10-23T08:03:55Z</EntryTemplatesGroupChanged>\r\n" +
|
||||||
"\t\t<HistoryMaxItems>10</HistoryMaxItems>\r\n" +
|
"\t\t<HistoryMaxItems>10</HistoryMaxItems>\r\n" +
|
||||||
"\t\t<HistoryMaxSize>6291456</HistoryMaxSize>\r\n" +
|
"\t\t<HistoryMaxSize>6291456</HistoryMaxSize>\r\n" +
|
||||||
"\t\t<LastSelectedGroup>AAAAAAAAAAAAAAAAAAAAAA==</LastSelectedGroup>\r\n" +
|
"\t\t<LastSelectedGroup>AAAAAAAAAAAAAAAAAAAAAA==</LastSelectedGroup>\r\n" +
|
||||||
@@ -77,13 +78,13 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
|||||||
"\t\t\t<Notes>" + testRootGroupNotes + "</Notes>\r\n" +
|
"\t\t\t<Notes>" + testRootGroupNotes + "</Notes>\r\n" +
|
||||||
"\t\t\t<IconID>49</IconID>\r\n" +
|
"\t\t\t<IconID>49</IconID>\r\n" +
|
||||||
"\t\t\t<Times>\r\n" +
|
"\t\t\t<Times>\r\n" +
|
||||||
"\t\t\t\t<CreationTime>2015-03-14T03:15:26Z</CreationTime>\r\n" +
|
"\t\t\t\t<CreationTime>2017-10-23T08:03:55Z</CreationTime>\r\n" +
|
||||||
"\t\t\t\t<LastModificationTime>2015-03-14T03:15:26Z</LastModificationTime>\r\n" +
|
"\t\t\t\t<LastModificationTime>2017-10-23T08:03:55Z</LastModificationTime>\r\n" +
|
||||||
"\t\t\t\t<LastAccessTime>2015-03-14T03:15:26Z</LastAccessTime>\r\n" +
|
"\t\t\t\t<LastAccessTime>2017-10-23T08:03:55Z</LastAccessTime>\r\n" +
|
||||||
"\t\t\t\t<ExpiryTime>2015-03-14T03:15:26Z</ExpiryTime>\r\n" +
|
"\t\t\t\t<ExpiryTime>2017-10-23T08:03:55Z</ExpiryTime>\r\n" +
|
||||||
"\t\t\t\t<Expires>False</Expires>\r\n" +
|
"\t\t\t\t<Expires>False</Expires>\r\n" +
|
||||||
"\t\t\t\t<UsageCount>0</UsageCount>\r\n" +
|
"\t\t\t\t<UsageCount>0</UsageCount>\r\n" +
|
||||||
"\t\t\t\t<LocationChanged>2015-03-14T03:15:26Z</LocationChanged>\r\n" +
|
"\t\t\t\t<LocationChanged>2017-10-23T08:03:55Z</LocationChanged>\r\n" +
|
||||||
"\t\t\t</Times>\r\n" +
|
"\t\t\t</Times>\r\n" +
|
||||||
"\t\t\t<IsExpanded>True</IsExpanded>\r\n" +
|
"\t\t\t<IsExpanded>True</IsExpanded>\r\n" +
|
||||||
"\t\t\t<DefaultAutoTypeSequence>" + testRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
|
"\t\t\t<DefaultAutoTypeSequence>" + testRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
|
||||||
@@ -95,7 +96,7 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
|||||||
"\t</Root>\r\n" +
|
"\t</Root>\r\n" +
|
||||||
"</KeePassFile>";
|
"</KeePassFile>";
|
||||||
|
|
||||||
const string testDate = "2015-03-14T03:15:26Z";
|
const string testDate = "2017-10-23T08:03:55Z";
|
||||||
|
|
||||||
[Test()]
|
[Test()]
|
||||||
public void TestLoad()
|
public void TestLoad()
|
||||||
@@ -120,7 +121,8 @@ namespace ModernKeePassLib.Test.Shared.Serialization
|
|||||||
{
|
{
|
||||||
var database = new PwDatabase();
|
var database = new PwDatabase();
|
||||||
database.New(new IOConnectionInfo(), new CompositeKey());
|
database.New(new IOConnectionInfo(), new CompositeKey());
|
||||||
var date = DateTime.Parse(testDate);
|
var date = DateTime.Parse(testDate, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);
|
||||||
|
//var date = DateTime.UtcNow;
|
||||||
PwDatabase.LocalizedAppName = testLocalizedAppName;
|
PwDatabase.LocalizedAppName = testLocalizedAppName;
|
||||||
database.Name = testDatabaseName;
|
database.Name = testDatabaseName;
|
||||||
database.NameChanged = date;
|
database.NameChanged = date;
|
||||||
|
@@ -39,6 +39,11 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class StandardAesEngine : ICipherEngine
|
public sealed class StandardAesEngine : ICipherEngine
|
||||||
{
|
{
|
||||||
|
#if !ModernKeePassLib && !KeePassUAP
|
||||||
|
private const CipherMode m_rCipherMode = CipherMode.CBC;
|
||||||
|
private const PaddingMode m_rCipherPadding = PaddingMode.PKCS7;
|
||||||
|
#endif
|
||||||
|
|
||||||
private static PwUuid g_uuidAes = null;
|
private static PwUuid g_uuidAes = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -115,6 +120,8 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
|||||||
|
|
||||||
byte[] pbLocalKey = new byte[32];
|
byte[] pbLocalKey = new byte[32];
|
||||||
Array.Copy(pbKey, pbLocalKey, 32);
|
Array.Copy(pbKey, pbLocalKey, 32);
|
||||||
|
|
||||||
|
#if ModernKeePassLib
|
||||||
AesEngine aes = new AesEngine();
|
AesEngine aes = new AesEngine();
|
||||||
CbcBlockCipher cbc = new CbcBlockCipher(aes);
|
CbcBlockCipher cbc = new CbcBlockCipher(aes);
|
||||||
PaddedBufferedBlockCipher bc = new PaddedBufferedBlockCipher(cbc,
|
PaddedBufferedBlockCipher bc = new PaddedBufferedBlockCipher(cbc,
|
||||||
@@ -126,6 +133,29 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
|||||||
IBufferedCipher cpRead = (bEncrypt ? null : bc);
|
IBufferedCipher cpRead = (bEncrypt ? null : bc);
|
||||||
IBufferedCipher cpWrite = (bEncrypt ? bc : null);
|
IBufferedCipher cpWrite = (bEncrypt ? bc : null);
|
||||||
return new CipherStream(s, cpRead, cpWrite);
|
return new CipherStream(s, cpRead, cpWrite);
|
||||||
|
#elif KeePassUAP
|
||||||
|
return StandardAesEngineExt.CreateStream(s, bEncrypt, pbLocalKey, pbLocalIV);
|
||||||
|
#else
|
||||||
|
SymmetricAlgorithm a = CryptoUtil.CreateAes();
|
||||||
|
if(a.BlockSize != 128) // AES block size
|
||||||
|
{
|
||||||
|
Debug.Assert(false);
|
||||||
|
a.BlockSize = 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.IV = pbLocalIV;
|
||||||
|
a.KeySize = 256;
|
||||||
|
a.Key = pbLocalKey;
|
||||||
|
a.Mode = m_rCipherMode;
|
||||||
|
a.Padding = m_rCipherPadding;
|
||||||
|
|
||||||
|
ICryptoTransform iTransform = (bEncrypt ? a.CreateEncryptor() : a.CreateDecryptor());
|
||||||
|
Debug.Assert(iTransform != null);
|
||||||
|
if(iTransform == null) throw new SecurityException("Unable to create AES transform!");
|
||||||
|
|
||||||
|
return new CryptoStream(s, iTransform, bEncrypt ? CryptoStreamMode.Write :
|
||||||
|
CryptoStreamMode.Read);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream EncryptStream(Stream sPlainText, byte[] pbKey, byte[] pbIV)
|
public Stream EncryptStream(Stream sPlainText, byte[] pbKey, byte[] pbIV)
|
||||||
|
@@ -120,9 +120,9 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
{
|
{
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
|
|
||||||
var sha256 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256)
|
||||||
var buffer = sha256.HashData(CryptographicBuffer.CreateFromByteArray(pbEntropy));
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbEntropy));
|
||||||
CryptographicBuffer.CopyToByteArray(buffer, out pbNewData);
|
CryptographicBuffer.CopyToByteArray(h, out pbNewData);
|
||||||
#else
|
#else
|
||||||
#if KeePassLibSD
|
#if KeePassLibSD
|
||||||
using(SHA256Managed shaNew = new SHA256Managed())
|
using(SHA256Managed shaNew = new SHA256Managed())
|
||||||
@@ -147,9 +147,9 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
MemUtil.ZeroByteArray(m_pbEntropyPool);
|
MemUtil.ZeroByteArray(m_pbEntropyPool);
|
||||||
|
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var sha256 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256)
|
||||||
var buffer = sha256.HashData(CryptographicBuffer.CreateFromByteArray(pbCmp));
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbCmp));
|
||||||
CryptographicBuffer.CopyToByteArray(buffer, out m_pbEntropyPool);
|
CryptographicBuffer.CopyToByteArray(h, out m_pbEntropyPool);
|
||||||
#else
|
#else
|
||||||
#if KeePassLibSD
|
#if KeePassLibSD
|
||||||
using(SHA256Managed shaPool = new SHA256Managed())
|
using(SHA256Managed shaPool = new SHA256Managed())
|
||||||
|
@@ -98,10 +98,10 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
byte[] pbKey32 = new byte[32];
|
byte[] pbKey32 = new byte[32];
|
||||||
byte[] pbIV12 = new byte[12];
|
byte[] pbIV12 = new byte[12];
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var sha256 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512)
|
||||||
var buffer = sha256.HashData(CryptographicBuffer.CreateFromByteArray(pbKey));
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbKey));
|
||||||
byte[] pbHash;
|
byte[] pbHash;
|
||||||
CryptographicBuffer.CopyToByteArray(buffer, out pbHash);
|
CryptographicBuffer.CopyToByteArray(h, out pbHash);
|
||||||
|
|
||||||
Array.Copy(pbHash, pbKey32, 32);
|
Array.Copy(pbHash, pbKey32, 32);
|
||||||
Array.Copy(pbHash, 32, pbIV12, 0, 12);
|
Array.Copy(pbHash, 32, pbIV12, 0, 12);
|
||||||
|
@@ -52,15 +52,16 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
|
|
||||||
byte[] pbHash;
|
byte[] pbHash;
|
||||||
|
|
||||||
/*#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256).CreateHash();
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256)
|
||||||
CryptographicBuffer.CopyToByteArray(h.GetValueAndReset(), out pbHash);
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbData));
|
||||||
#else*/
|
CryptographicBuffer.CopyToByteArray(h, out pbHash);
|
||||||
|
#else
|
||||||
using(SHA256Managed h = new SHA256Managed())
|
using(SHA256Managed h = new SHA256Managed())
|
||||||
{
|
{
|
||||||
pbHash = h.ComputeHash(pbData, iOffset, cbCount);
|
pbHash = h.ComputeHash(pbData, iOffset, cbCount);
|
||||||
}
|
}
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// Ensure the data has not been modified
|
// Ensure the data has not been modified
|
||||||
@@ -90,15 +91,16 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
if(cbOut <= 32) pbHash = HashSha256(pbIn, iInOffset, cbIn);
|
if(cbOut <= 32) pbHash = HashSha256(pbIn, iInOffset, cbIn);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512).CreateHash();
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512)
|
||||||
CryptographicBuffer.CopyToByteArray(h.GetValueAndReset(), out pbHash);
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbIn));
|
||||||
#else*/
|
CryptographicBuffer.CopyToByteArray(h, out pbHash);
|
||||||
|
#else
|
||||||
using(SHA512Managed h = new SHA512Managed())
|
using(SHA512Managed h = new SHA512Managed())
|
||||||
{
|
{
|
||||||
pbHash = h.ComputeHash(pbIn, iInOffset, cbIn);
|
pbHash = h.ComputeHash(pbIn, iInOffset, cbIn);
|
||||||
}
|
}
|
||||||
//#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cbOut == pbHash.Length) return pbHash;
|
if(cbOut == pbHash.Length) return pbHash;
|
||||||
|
@@ -270,11 +270,15 @@ namespace ModernKeePassLib.Cryptography.Hash
|
|||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal byte[] ComputeHash(byte[] pbOutBuffer)
|
internal byte[] ComputeHash(byte[] value)
|
||||||
{
|
{
|
||||||
byte[] result = new byte[pbOutBuffer.Length];
|
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||||
DoFinal(result, 0);
|
|
||||||
return result;
|
byte[] resBuf = new byte[m_cbHashLength];
|
||||||
|
BlockUpdate(value, 0, value.Length);
|
||||||
|
DoFinal(resBuf, 0);
|
||||||
|
|
||||||
|
return resBuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Org.BouncyCastle.Crypto;
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography.Hash
|
|
||||||
{
|
|
||||||
public abstract class DigestManaged : IDisposable
|
|
||||||
{
|
|
||||||
protected IDigest _hash;
|
|
||||||
|
|
||||||
public byte[] ComputeHash(byte[] value, int offset, int length)
|
|
||||||
{
|
|
||||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
|
||||||
|
|
||||||
byte[] resBuf = new byte[_hash.GetDigestSize()];
|
|
||||||
_hash.BlockUpdate(value, offset, length);
|
|
||||||
_hash.DoFinal(resBuf, 0);
|
|
||||||
|
|
||||||
return resBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_hash.Reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Org.BouncyCastle.Crypto.Digests;
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography.Hash
|
|
||||||
{
|
|
||||||
public class SHA256Managed : DigestManaged
|
|
||||||
{
|
|
||||||
public SHA256Managed()
|
|
||||||
{
|
|
||||||
_hash = new Sha256Digest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Org.BouncyCastle.Crypto.Digests;
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Cryptography.Hash
|
|
||||||
{
|
|
||||||
public class SHA512Managed : DigestManaged
|
|
||||||
{
|
|
||||||
public SHA512Managed()
|
|
||||||
{
|
|
||||||
_hash = new Sha512Digest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -83,10 +83,10 @@ namespace ModernKeePassLib.Cryptography.PasswordGenerator
|
|||||||
if((pbAdditionalEntropy != null) && (pbAdditionalEntropy.Length > 0))
|
if((pbAdditionalEntropy != null) && (pbAdditionalEntropy.Length > 0))
|
||||||
{
|
{
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var sha256 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512)
|
||||||
var buffer = sha256.HashData(CryptographicBuffer.CreateFromByteArray(pbAdditionalEntropy));
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbAdditionalEntropy));
|
||||||
byte[] pbHash;
|
byte[] pbHash;
|
||||||
CryptographicBuffer.CopyToByteArray(buffer, out pbHash);
|
CryptographicBuffer.CopyToByteArray(h, out pbHash);
|
||||||
MemUtil.XorArray(pbHash, 0, pbKey, 0, pbHash.Length);
|
MemUtil.XorArray(pbHash, 0, pbKey, 0, pbHash.Length);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@@ -61,10 +61,7 @@
|
|||||||
<Compile Include="Cryptography\Cipher\ICipherEngine.cs" />
|
<Compile Include="Cryptography\Cipher\ICipherEngine.cs" />
|
||||||
<Compile Include="Cryptography\CryptoUtil.cs" />
|
<Compile Include="Cryptography\CryptoUtil.cs" />
|
||||||
<Compile Include="Cryptography\Hash\Blake2b.cs" />
|
<Compile Include="Cryptography\Hash\Blake2b.cs" />
|
||||||
<Compile Include="Cryptography\Hash\DigestManaged.cs" />
|
|
||||||
<Compile Include="Cryptography\Hash\HMACSHA256.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\HmacOtp.cs" />
|
||||||
<Compile Include="Cryptography\KeyDerivation\AesKdf.cs" />
|
<Compile Include="Cryptography\KeyDerivation\AesKdf.cs" />
|
||||||
<Compile Include="Cryptography\KeyDerivation\AesKdf.GCrypt.cs" />
|
<Compile Include="Cryptography\KeyDerivation\AesKdf.GCrypt.cs" />
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>ModernKeePassLib</id>
|
<id>ModernKeePassLib</id>
|
||||||
<version>2.37.1000</version>
|
<version>2.37.2000</version>
|
||||||
<title>ModernKeePassLib</title>
|
<title>ModernKeePassLib</title>
|
||||||
<authors>Geoffroy Bonneville</authors>
|
<authors>Geoffroy Bonneville</authors>
|
||||||
<owners>Geoffroy Bonneville</owners>
|
<owners>Geoffroy Bonneville</owners>
|
||||||
|
@@ -40,5 +40,5 @@ using System.Runtime.InteropServices;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Assembly version information
|
// Assembly version information
|
||||||
[assembly: AssemblyVersion("2.37.0.1000")]
|
[assembly: AssemblyVersion("2.37.0.2000")]
|
||||||
[assembly: AssemblyFileVersion("2.37.0.1000")]
|
[assembly: AssemblyFileVersion("2.37.0.2000")]
|
||||||
|
@@ -18,20 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
#if ModernKeePassLib
|
|
||||||
using System.Linq;
|
|
||||||
using Windows.Security.Cryptography;
|
|
||||||
#else
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
#endif
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
#if ModernKeePassLib
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
using Windows.Security.Cryptography.Core;
|
|
||||||
using ModernKeePassLib.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
|
#else
|
||||||
|
using KeePassLib.Cryptography;
|
||||||
|
using KeePassLib.Native;
|
||||||
|
using KeePassLib.Utility;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if KeePassLibSD
|
#if KeePassLibSD
|
||||||
using KeePassLibSD;
|
using KeePassLibSD;
|
||||||
|
@@ -399,9 +399,9 @@ namespace ModernKeePassLib.Serialization
|
|||||||
|
|
||||||
pbCmp[64] = 1;
|
pbCmp[64] = 1;
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var sha256 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
|
var h = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512)
|
||||||
var buffer = sha256.HashData(CryptographicBuffer.CreateFromByteArray(pbCmp));
|
.HashData(CryptographicBuffer.CreateFromByteArray(pbCmp));
|
||||||
CryptographicBuffer.CopyToByteArray(buffer, out pbHmacKey64);
|
CryptographicBuffer.CopyToByteArray(h, out pbHmacKey64);
|
||||||
#else
|
#else
|
||||||
using(SHA512Managed h = new SHA512Managed())
|
using(SHA512Managed h = new SHA512Managed())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user