WIP KeePassLibPCL

This commit is contained in:
bg45
2017-09-23 09:42:48 -04:00
parent 668afbe817
commit 9d78d59a15
108 changed files with 3283 additions and 181 deletions

View File

@@ -21,13 +21,14 @@ using System;
using System.Text;
using System.Diagnostics;
#if ModernKeePassLibPCL
using PCLCrypto;
using Windows.Security.Cryptography;
#else
using System.Security.Cryptography;
#endif
using ModernKeePassLibPCL.Security;
using ModernKeePassLibPCL.Utility;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLibPCL.Keys
{
@@ -73,14 +74,18 @@ namespace ModernKeePassLibPCL.Keys
if(pbPasswordUtf8 == null) throw new ArgumentNullException("pbPasswordUtf8");
#if ModernKeePassLibPCL
var sha256 = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithm.Sha256);
var pbRaw = sha256.HashData(pbPasswordUtf8);
/*var sha256 = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithm.Sha256);
var pbRaw = sha256.HashData(pbPasswordUtf8);*/
var sha256 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
var buffer = sha256.HashData(CryptographicBuffer.CreateFromByteArray(pbPasswordUtf8));
byte[] pbRaw;
CryptographicBuffer.CopyToByteArray(buffer, out pbRaw);
#else
SHA256Managed sha256 = new SHA256Managed();
byte[] pbRaw = sha256.ComputeHash(pbPasswordUtf8);
#endif
m_psPassword = new ProtectedString(true, pbPasswordUtf8);
m_psPassword = new ProtectedString(true, pbPasswordUtf8);
m_pbKeyData = new ProtectedBinary(true, pbRaw);
}