WIP 2.37 - ter

This commit is contained in:
bg45
2017-10-22 16:44:17 -04:00
committed by BONNEVILLE Geoffroy
parent 84e7afc819
commit e95e62f184
8 changed files with 134 additions and 54 deletions

View File

@@ -687,7 +687,7 @@ namespace ModernKeePassLib.Cryptography
private static void HmacEval(byte[] pbKey, byte[] pbMsg,
byte[] pbExpc, string strID)
{
#if ModernKeePassLib
/*#if ModernKeePassLib
// WinRT
var h = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(CryptographicBuffer.CreateFromByteArray(pbKey));
h.Append(CryptographicBuffer.CreateFromByteArray(pbMsg));
@@ -701,19 +701,19 @@ namespace ModernKeePassLib.Cryptography
throw new SecurityException("HMAC-SHA-256-" + strID + "-R");
// BouncyCastle
/*var h = new HMac(new Sha256Digest());
h.BlockUpdate(pbMsg, 0, pbMsg.Length);
byte[] pbHash = MemUtil.EmptyByteArray;
h.DoFinal(pbHash, 0);
if (!MemUtil.ArraysEqual(pbHash, pbExpc))
throw new SecurityException("HMAC-SHA-256-" + strID);
// var h = new HMac(new Sha256Digest());
//h.BlockUpdate(pbMsg, 0, pbMsg.Length);
//byte[] pbHash = MemUtil.EmptyByteArray;
//h.DoFinal(pbHash, 0);
//if (!MemUtil.ArraysEqual(pbHash, pbExpc))
// throw new SecurityException("HMAC-SHA-256-" + strID);
h.Reset();
h.BlockUpdate(pbMsg, 0, pbMsg.Length);
h.DoFinal(pbHash, 0);
if (!MemUtil.ArraysEqual(pbHash, pbExpc))
throw new SecurityException("HMAC-SHA-256-" + strID + "-R");*/
#else
// h.Reset();
//h.BlockUpdate(pbMsg, 0, pbMsg.Length);
//h.DoFinal(pbHash, 0);
//if (!MemUtil.ArraysEqual(pbHash, pbExpc))
// throw new SecurityException("HMAC-SHA-256-" + strID + "-R");
#else*/
// Original
using(HMACSHA256 h = new HMACSHA256(pbKey))
{
@@ -733,7 +733,7 @@ namespace ModernKeePassLib.Cryptography
if(!MemUtil.ArraysEqual(pbHash, pbExpc))
throw new SecurityException("HMAC-SHA-256-" + strID + "-R");
}
#endif
//#endif
}
#endif