WIP sqving - removed some useless async await

This commit is contained in:
bg45
2017-09-19 02:53:29 -04:00
parent 25d1564a8d
commit 5d271d4133
8 changed files with 19 additions and 20 deletions

View File

@@ -159,8 +159,8 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ModernKeePassLib, Version=2.19.0.26356, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ModernKeePassLib, Version=2.19.0.5083, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ModernKeePassLib.2.19.0.26356\lib\netstandard1.2\ModernKeePassLib.dll</HintPath> <HintPath>..\packages\ModernKeePassLib.2.19.0.5083\lib\netstandard1.2\ModernKeePassLib.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">

View File

@@ -2,7 +2,7 @@
<packages> <packages>
<package id="Microsoft.NETCore.Platforms" version="2.0.0" targetFramework="win81" /> <package id="Microsoft.NETCore.Platforms" version="2.0.0" targetFramework="win81" />
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" /> <package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.2" targetFramework="win81" />
<package id="ModernKeePassLib" version="2.19.0.26356" targetFramework="win81" /> <package id="ModernKeePassLib" version="2.19.0.5083" targetFramework="win81" />
<package id="NETStandard.Library" version="2.0.0" targetFramework="win81" /> <package id="NETStandard.Library" version="2.0.0" targetFramework="win81" />
<package id="System.Net.Requests" version="4.3.0" targetFramework="win81" /> <package id="System.Net.Requests" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="win81" /> <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="win81" />

View File

@@ -162,7 +162,7 @@ namespace ModernKeePassLib.Keys
/// Creates the composite key from the supplied user key sources (password, /// Creates the composite key from the supplied user key sources (password,
/// key file, user account, computer ID, etc.). /// key file, user account, computer ID, etc.).
/// </summary> /// </summary>
private async Task<byte[]> CreateRawCompositeKey32() private byte[] CreateRawCompositeKey32()
{ {
ValidateUserKeys(); ValidateUserKeys();
@@ -185,12 +185,12 @@ namespace ModernKeePassLib.Keys
} }
public async Task<bool> EqualsValue(CompositeKey ckOther) public bool EqualsValue(CompositeKey ckOther)
{ {
if(ckOther == null) throw new ArgumentNullException("ckOther"); if(ckOther == null) throw new ArgumentNullException("ckOther");
byte[] pbThis = await CreateRawCompositeKey32(); byte[] pbThis = CreateRawCompositeKey32();
byte[] pbOther = await ckOther.CreateRawCompositeKey32(); byte[] pbOther = ckOther.CreateRawCompositeKey32();
bool bResult = MemUtil.ArraysEqual(pbThis, pbOther); bool bResult = MemUtil.ArraysEqual(pbThis, pbOther);
Array.Clear(pbOther, 0, pbOther.Length); Array.Clear(pbOther, 0, pbOther.Length);
Array.Clear(pbThis, 0, pbThis.Length); Array.Clear(pbThis, 0, pbThis.Length);
@@ -207,14 +207,14 @@ namespace ModernKeePassLib.Keys
/// <param name="uNumRounds">Number of key transformation rounds.</param> /// <param name="uNumRounds">Number of key transformation rounds.</param>
/// <returns>Returns a protected binary object that contains the /// <returns>Returns a protected binary object that contains the
/// resulting 32-bit wide key.</returns> /// resulting 32-bit wide key.</returns>
public async Task<ProtectedBinary> GenerateKey32(byte[] pbKeySeed32, ulong uNumRounds) public ProtectedBinary GenerateKey32(byte[] pbKeySeed32, ulong uNumRounds)
{ {
Debug.Assert(pbKeySeed32 != null); Debug.Assert(pbKeySeed32 != null);
if(pbKeySeed32 == null) throw new ArgumentNullException("pbKeySeed32"); if(pbKeySeed32 == null) throw new ArgumentNullException("pbKeySeed32");
Debug.Assert(pbKeySeed32.Length == 32); Debug.Assert(pbKeySeed32.Length == 32);
if(pbKeySeed32.Length != 32) throw new ArgumentException("pbKeySeed32"); if(pbKeySeed32.Length != 32) throw new ArgumentException("pbKeySeed32");
byte[] pbRaw32 = await CreateRawCompositeKey32(); byte[] pbRaw32 = CreateRawCompositeKey32();
if((pbRaw32 == null) || (pbRaw32.Length != 32)) if((pbRaw32 == null) || (pbRaw32.Length != 32))
{ Debug.Assert(false); return null; } { Debug.Assert(false); return null; }

View File

@@ -587,7 +587,7 @@ namespace ModernKeePassLib
IOConnection ioc = new IOConnection(); IOConnection ioc = new IOConnection();
Stream s = await ioc.OpenRead(ioSource); Stream s = await ioc.OpenRead(ioSource);
await kdb4.Load(s, Kdb4Format.Default, slLogger); kdb4.Load(s, Kdb4Format.Default, slLogger);
s.Dispose(); s.Dispose();

View File

@@ -57,7 +57,7 @@ namespace ModernKeePassLib.Serialization
IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFilePath); IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFilePath);
IOConnection ioConnection = new IOConnection(); IOConnection ioConnection = new IOConnection();
Stream abc = await ioConnection.OpenRead(ioc); Stream abc = await ioConnection.OpenRead(ioc);
await Load(abc, kdbFormat, slLogger); Load(abc, kdbFormat, slLogger);
} }
/// <summary> /// <summary>
@@ -67,7 +67,7 @@ namespace ModernKeePassLib.Serialization
/// a KDB4 stream.</param> /// a KDB4 stream.</param>
/// <param name="kdbFormat">Format specifier.</param> /// <param name="kdbFormat">Format specifier.</param>
/// <param name="slLogger">Status logger (optional).</param> /// <param name="slLogger">Status logger (optional).</param>
public async Task Load(Stream sSource, Kdb4Format kdbFormat, IStatusLogger slLogger) public void Load(Stream sSource, Kdb4Format kdbFormat, IStatusLogger slLogger)
{ {
Debug.Assert(sSource != null); Debug.Assert(sSource != null);
@@ -90,7 +90,7 @@ namespace ModernKeePassLib.Serialization
br = new BinaryReaderEx(hashedStream, encNoBom, KLRes.FileCorrupted); br = new BinaryReaderEx(hashedStream, encNoBom, KLRes.FileCorrupted);
ReadHeader(br); ReadHeader(br);
Stream sDecrypted = await AttachStreamDecryptor(hashedStream); Stream sDecrypted = AttachStreamDecryptor(hashedStream);
if((sDecrypted == null) || (sDecrypted == hashedStream)) if((sDecrypted == null) || (sDecrypted == hashedStream))
throw new SecurityException(KLRes.CryptoStreamFailed); throw new SecurityException(KLRes.CryptoStreamFailed);
@@ -312,7 +312,7 @@ namespace ModernKeePassLib.Serialization
m_craInnerRandomStream = (CrsAlgorithm)uID; m_craInnerRandomStream = (CrsAlgorithm)uID;
} }
private async Task<Stream> AttachStreamDecryptor(Stream s) private Stream AttachStreamDecryptor(Stream s)
{ {
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
@@ -321,7 +321,7 @@ namespace ModernKeePassLib.Serialization
throw new FormatException(KLRes.MasterSeedLengthInvalid); throw new FormatException(KLRes.MasterSeedLengthInvalid);
ms.Write(m_pbMasterSeed, 0, 32); ms.Write(m_pbMasterSeed, 0, 32);
Security.ProtectedBinary pb = await m_pwDatabase.MasterKey.GenerateKey32(m_pbTransformSeed, Security.ProtectedBinary pb = m_pwDatabase.MasterKey.GenerateKey32(m_pbTransformSeed,
m_pwDatabase.KeyEncryptionRounds); m_pwDatabase.KeyEncryptionRounds);
byte[] pKey32 = pb.ReadData(); byte[] pKey32 = pb.ReadData();

View File

@@ -71,7 +71,7 @@ namespace ModernKeePassLib.Serialization
/// be written.</param> /// be written.</param>
/// <param name="format">Format of the file to create.</param> /// <param name="format">Format of the file to create.</param>
/// <param name="slLogger">Logger that recieves status information.</param> /// <param name="slLogger">Logger that recieves status information.</param>
public async void Save(Stream sSaveTo, PwGroup pgDataSource, Kdb4Format format, public void Save(Stream sSaveTo, PwGroup pgDataSource, Kdb4Format format,
IStatusLogger slLogger) IStatusLogger slLogger)
{ {
Debug.Assert(sSaveTo != null); Debug.Assert(sSaveTo != null);
@@ -105,7 +105,7 @@ namespace ModernKeePassLib.Serialization
bw = new BinaryWriter(hashedStream, encNoBom); bw = new BinaryWriter(hashedStream, encNoBom);
WriteHeader(bw); // Also flushes bw WriteHeader(bw); // Also flushes bw
Stream sEncrypted = await AttachStreamEncryptor(hashedStream); Stream sEncrypted = AttachStreamEncryptor(hashedStream);
if((sEncrypted == null) || (sEncrypted == hashedStream)) if((sEncrypted == null) || (sEncrypted == hashedStream))
throw new SecurityException(KLRes.CryptoStreamFailed); throw new SecurityException(KLRes.CryptoStreamFailed);
@@ -193,18 +193,17 @@ namespace ModernKeePassLib.Serialization
else bwOut.Write((ushort)0); else bwOut.Write((ushort)0);
} }
private async Task<Stream> AttachStreamEncryptor(Stream s) private Stream AttachStreamEncryptor(Stream s)
{ {
using (MemoryStream ms = new MemoryStream()) using (MemoryStream ms = new MemoryStream())
{ {
Debug.Assert(m_pbMasterSeed != null); Debug.Assert(m_pbMasterSeed != null);
Debug.Assert(m_pbMasterSeed.Length == 32); Debug.Assert(m_pbMasterSeed.Length == 32);
ms.Write(m_pbMasterSeed, 0, 32); ms.Write(m_pbMasterSeed, 0, 32);
Debug.Assert(m_pwDatabase != null); Debug.Assert(m_pwDatabase != null);
Debug.Assert(m_pwDatabase.MasterKey != null); Debug.Assert(m_pwDatabase.MasterKey != null);
ProtectedBinary pbinKey = await m_pwDatabase.MasterKey.GenerateKey32( ProtectedBinary pbinKey = m_pwDatabase.MasterKey.GenerateKey32(
m_pbTransformSeed, m_pwDatabase.KeyEncryptionRounds); m_pbTransformSeed, m_pwDatabase.KeyEncryptionRounds);
Debug.Assert(pbinKey != null); Debug.Assert(pbinKey != null);
if (pbinKey == null) if (pbinKey == null)