mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
WIP - Implementing HMAC with BouncyCastle
This commit is contained in:

committed by
BONNEVILLE Geoffroy

parent
c82d6d001d
commit
84e7afc819
@@ -32,13 +32,13 @@ using System.IO.Compression;
|
||||
#endif
|
||||
|
||||
#if ModernKeePassLib
|
||||
//using PCLStorage;
|
||||
using Windows.Storage;
|
||||
#endif
|
||||
|
||||
using ModernKeePassLib.Collections;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.Cipher;
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
using ModernKeePassLib.Delegates;
|
||||
using ModernKeePassLib.Interfaces;
|
||||
@@ -459,15 +459,10 @@ namespace ModernKeePassLib.Serialization
|
||||
byte[] pbHeaderHmac;
|
||||
byte[] pbBlockKey = HmacBlockStream.GetHmacKey64(
|
||||
pbKey, ulong.MaxValue);
|
||||
#if ModernKeePassLib
|
||||
var h = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(CryptographicBuffer.CreateFromByteArray(pbHeader));
|
||||
CryptographicBuffer.CopyToByteArray(h.GetValueAndReset(), out pbHeaderHmac);
|
||||
#else
|
||||
using (HMACSHA256 h = new HMACSHA256(pbBlockKey))
|
||||
{
|
||||
pbHeaderHmac = h.ComputeHash(pbHeader);
|
||||
}
|
||||
#endif
|
||||
MemUtil.ZeroByteArray(pbBlockKey);
|
||||
|
||||
return pbHeaderHmac;
|
||||
|
Reference in New Issue
Block a user