Added more tests

Code cleanup in Lib
WIP new VM for OpendatabaseControl
WIP KDBX4 file save - still not working
This commit is contained in:
bg45
2017-11-04 12:11:30 -04:00
committed by BONNEVILLE Geoffroy
parent 278b2759d5
commit 53a54252e3
23 changed files with 103 additions and 134 deletions

View File

@@ -128,7 +128,7 @@ namespace ModernKeePass.Common
public void Save() public void Save()
{ {
// TODO: Save is disabled for now for Argon2Kdf because it corrupts DB (read works) // TODO: Save is disabled for now for Argon2Kdf because it corrupts DB (read works)
if (_pwDatabase == null || !_pwDatabase.IsOpen || KdfPool.Get(KeyDerivation.KdfUuid) is Argon2Kdf) return; if (_pwDatabase == null || !_pwDatabase.IsOpen/* || KdfPool.Get(KeyDerivation.KdfUuid) is Argon2Kdf*/) return;
_pwDatabase.Save(new NullStatusLogger()); _pwDatabase.Save(new NullStatusLogger());
} }

View File

@@ -7,11 +7,15 @@
xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core" xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:actions="using:ModernKeePass.Actions" xmlns:actions="using:ModernKeePass.Actions"
xmlns:converters="using:ModernKeePass.Converters"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="120" d:DesignHeight="120"
d:DesignWidth="550" > d:DesignWidth="550" >
<UserControl.Resources> <UserControl.Resources>
<SolidColorBrush x:Key="ErrorColorBrush" Color="Red"/> <SolidColorBrush x:Key="ErrorColorBrush" Color="Red"/>
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
<converters:DoubleToForegroungBrushComplexityConverter x:Key="DoubleToForegroungBrushComplexityConverter"/>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -19,7 +23,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="40" /> <RowDefinition Height="45" />
<RowDefinition Height="40" /> <RowDefinition Height="40" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@@ -31,6 +35,7 @@
</core:DataTriggerBehavior> </core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>
</PasswordBox> </PasswordBox>
<ProgressBar Grid.Row="0" Grid.Column="1" Value="{Binding PasswordComplexityIndicator, ElementName=UserControl, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="500" VerticalAlignment="Bottom" Foreground="{Binding PasswordComplexityIndicator, ElementName=UserControl, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" Visibility="{Binding CreateNew, ElementName=UserControl, Converter={StaticResource BooleanToVisibilityConverter}}" />
<CheckBox x:Name="KeyFileCheckBox" Grid.Row="1" Grid.Column="0" /> <CheckBox x:Name="KeyFileCheckBox" Grid.Row="1" Grid.Column="0" />
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0" Content="Select key file from disk..." IsEnabled="{Binding IsChecked, ElementName=KeyFileCheckBox}" Click="KeyFileButton_Click" /> <HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0" Content="Select key file from disk..." IsEnabled="{Binding IsChecked, ElementName=KeyFileCheckBox}" Click="KeyFileButton_Click" />
<Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" Background="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" /> <Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" Background="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" />

View File

@@ -5,6 +5,7 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Input;
using ModernKeePass.Common; using ModernKeePass.Common;
using ModernKeePass.Events; using ModernKeePass.Events;
using ModernKeePassLib.Cryptography;
// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236 // Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236

View File

@@ -161,6 +161,7 @@
<DependentUpon>WelcomePage.xaml</DependentUpon> <DependentUpon>WelcomePage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ViewModels\AboutVm.cs" /> <Compile Include="ViewModels\AboutVm.cs" />
<Compile Include="ViewModels\Controls\OpenDatabaseUserControlVM.cs" />
<Compile Include="ViewModels\Items\ListMenuItemVm.cs" /> <Compile Include="ViewModels\Items\ListMenuItemVm.cs" />
<Compile Include="ViewModels\Items\MainMenuItemVm.cs" /> <Compile Include="ViewModels\Items\MainMenuItemVm.cs" />
<Compile Include="ViewModels\Items\RecentItemVm.cs" /> <Compile Include="ViewModels\Items\RecentItemVm.cs" />

View File

@@ -7,12 +7,11 @@
xmlns:local="using:ModernKeePass.Controls" xmlns:local="using:ModernKeePass.Controls"
xmlns:converters="using:ModernKeePass.Converters" xmlns:converters="using:ModernKeePass.Converters"
xmlns:viewModels="using:ModernKeePass.ViewModels" xmlns:viewModels="using:ModernKeePass.ViewModels"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core" xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d"> mc:Ignorable="d">
<Page.Resources> <Page.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
<converters:DoubleToForegroungBrushComplexityConverter x:Key="DoubleToForegroungBrushComplexityConverter"/>
</Page.Resources> </Page.Resources>
<Page.DataContext> <Page.DataContext>
<viewModels:NewVm /> <viewModels:NewVm />
@@ -26,14 +25,13 @@
<TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding Name}" />
<local:OpenDatabaseUserControl Password="{Binding Password, Mode=TwoWay}" CreateNew="True" > <local:OpenDatabaseUserControl Password="{Binding Password, Mode=TwoWay}" CreateNew="True" >
<interactivity:Interaction.Behaviors> <interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="ValidationChecked"> <core:EventTriggerBehavior EventName="ValidationChecked">
<Core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" /> <core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
</Core:EventTriggerBehavior> </core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors> </interactivity:Interaction.Behaviors>
</local:OpenDatabaseUserControl> </local:OpenDatabaseUserControl>
<TextBlock >Password complexity</TextBlock>
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="500" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" />
</StackPanel> </StackPanel>
</Border> </Border>
</StackPanel> </StackPanel>
</Page> </Page>

View File

@@ -0,0 +1,11 @@
using ModernKeePass.Common;
using ModernKeePassLib.Cryptography;
namespace ModernKeePass.ViewModels
{
public class OpenDatabaseUserControlVm: NotifyPropertyChangedBase
{
//public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
}
}

View File

@@ -1,21 +1,7 @@
using ModernKeePassLib.Cryptography; namespace ModernKeePass.ViewModels
namespace ModernKeePass.ViewModels
{ {
public class NewVm : OpenVm public class NewVm : OpenVm
{ {
private string _password = string.Empty; public string Password { get; set; }
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
public string Password
{
get { return _password; }
set
{
_password = value;
NotifyPropertyChanged("PasswordComplexityIndicator");
}
}
} }
} }

View File

@@ -68,7 +68,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
} }
} }
public static string ByteToString(byte[] buff) private static string ByteToString(byte[] buff)
{ {
string sbinary = ""; string sbinary = "";

View File

@@ -0,0 +1,42 @@
using ModernKeePassLib.Cryptography.Hash;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Hash
{
[TestFixture]
public class SHAManagedTests
{
[Test]
public void TestSha256ComputeHash()
{
var expectedHash = "B822F1CD2DCFC685B47E83E3980289FD5D8E3FF3A82DEF24D7D1D68BB272EB32";
var message = StrUtil.Utf8.GetBytes("testing123");
using (var result = new SHA256Managed())
{
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
}
}
[Test]
public void TestSha512ComputeHash()
{
var expectedHash = "4120117B3190BA5E24044732B0B09AA9ED50EB1567705ABCBFA78431A4E0A96B1152ED7F4925966B1C82325E186A8100E692E6D2FCB6702572765820D25C7E9E";
var message = StrUtil.Utf8.GetBytes("testing123");
using (var result = new SHA512Managed())
{
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
}
}
private static string ByteToString(byte[] buff)
{
string sbinary = "";
for (int i = 0; i < buff.Length; i++)
{
sbinary += buff[i].ToString("X2"); // hex format
}
return (sbinary);
}
}
}

View File

@@ -1,13 +1,7 @@
using NUnit.Framework; using System.IO;
using System; using NUnit.Framework;
using System.IO;
using System.Text;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using ModernKeePassLib.Cryptography; using ModernKeePassLib.Cryptography;
#endif
namespace ModernKeePassLib.Test.Cryptography namespace ModernKeePassLib.Test.Cryptography
{ {

View File

@@ -54,6 +54,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Cryptography\Hash\SHAManagedTests.cs" />
<Compile Include="Cryptography\KeyDerivation\Argon2Tests.cs" /> <Compile Include="Cryptography\KeyDerivation\Argon2Tests.cs" />
<Compile Include="Cryptography\Hash\Blake2bTests.cs" /> <Compile Include="Cryptography\Hash\Blake2bTests.cs" />
<Compile Include="Cryptography\Cipher\Chacha20Tests.cs" /> <Compile Include="Cryptography\Cipher\Chacha20Tests.cs" />

View File

@@ -165,7 +165,7 @@ namespace ModernKeePassLib.Cryptography
pb = MemUtil.Int64ToBytes(DateTime.UtcNow.ToBinary()); pb = MemUtil.Int64ToBytes(DateTime.UtcNow.ToBinary());
MemUtil.Write(ms, pb); MemUtil.Write(ms, pb);
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT) #if (!ModernKeePassLib && !KeePassLibSD)
// In try-catch for systems without GUI; // In try-catch for systems without GUI;
// https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/ // https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/
try try

View File

@@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLib.Cryptography
{
public static class CryptographicHashExtensions
{
public static int TransformBlock(this CryptographicHash hash, byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
{
byte[] buffer;
if (inputCount < inputBuffer.Length)
{
buffer = new byte[inputCount];
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
}
else
{
buffer = inputBuffer;
}
hash.Append(buffer.AsBuffer());
if (outputBuffer != null)
{
Array.Copy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
}
return inputCount;
}
public static byte[] TransformFinalBlock(this CryptographicHash hash, byte[] inputBuffer, int inputOffset, int inputCount)
{
hash.TransformBlock(inputBuffer, inputOffset, inputCount, null, 0);
if (inputCount == inputBuffer.Length)
{
return inputBuffer;
}
else
{
var buffer = new byte[inputCount];
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
return buffer;
}
}
}
}

View File

@@ -40,9 +40,13 @@ namespace ModernKeePassLib.Cryptography.Hash
Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount); Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
} }
public void TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{ {
Hmac.BlockUpdate(inputBuffer, inputOffset, inputCount); Hmac.BlockUpdate(inputBuffer, inputOffset, inputCount);
byte[] outputBytes = new byte[inputCount];
if (inputCount != 0)
Buffer.BlockCopy(inputBuffer, inputOffset, outputBytes, 0, inputCount);
return outputBytes;
} }
public void Initialize() public void Initialize()

View File

@@ -3,7 +3,7 @@ using Org.BouncyCastle.Crypto;
namespace ModernKeePassLib.Cryptography.Hash namespace ModernKeePassLib.Cryptography.Hash
{ {
public abstract class DigestManaged: IDisposable public abstract class HashAlgorithm: IDisposable
{ {
protected IDigest Digest; protected IDigest Digest;
@@ -17,6 +17,9 @@ namespace ModernKeePassLib.Cryptography.Hash
} }
} }
public bool CanReuseTransform => true;
public bool CanTransformMultipleBlocks => true;
public byte[] ComputeHash(byte[] value) public byte[] ComputeHash(byte[] value)
{ {
return ComputeHash(value, 0, value.Length); return ComputeHash(value, 0, value.Length);
@@ -41,9 +44,13 @@ namespace ModernKeePassLib.Cryptography.Hash
Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount); Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
} }
public void TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{ {
Digest.BlockUpdate(inputBuffer, inputOffset, inputCount); Digest.BlockUpdate(inputBuffer, inputOffset, inputCount);
byte[] outputBytes = new byte[inputCount];
if (inputCount != 0)
Buffer.BlockCopy(inputBuffer, inputOffset, outputBytes, 0, inputCount);
return outputBytes;
} }
public void Dispose() public void Dispose()

View File

@@ -2,7 +2,7 @@
namespace ModernKeePassLib.Cryptography.Hash namespace ModernKeePassLib.Cryptography.Hash
{ {
public class SHA256Managed : DigestManaged public class SHA256Managed : HashAlgorithm
{ {
public SHA256Managed() public SHA256Managed()
{ {

View File

@@ -2,7 +2,7 @@
namespace ModernKeePassLib.Cryptography.Hash namespace ModernKeePassLib.Cryptography.Hash
{ {
public class SHA512Managed: DigestManaged public class SHA512Managed: HashAlgorithm
{ {
public SHA512Managed() public SHA512Managed()
{ {

View File

@@ -22,13 +22,8 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
#if ModernKeePassLib #if ModernKeePassLib
using Windows.Security.Cryptography; using ModernKeePassLib.Cryptography.Hash;
using Windows.Security.Cryptography.Core;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Tls;
#elif !KeePassUAP #elif !KeePassUAP
using System.Security.Cryptography; using System.Security.Cryptography;
#endif #endif
@@ -41,11 +36,7 @@ namespace ModernKeePassLib.Cryptography
{ {
private readonly Stream m_sBaseStream; private readonly Stream m_sBaseStream;
private readonly bool m_bWriting; private readonly bool m_bWriting;
#if ModernKeePassLib
private IDigest m_hash;
#else
private HashAlgorithm m_hash; private HashAlgorithm m_hash;
#endif
private byte[] m_pbFinalHash = null; private byte[] m_pbFinalHash = null;
@@ -80,19 +71,14 @@ namespace ModernKeePassLib.Cryptography
set { Debug.Assert(false); throw new NotSupportedException(); } set { Debug.Assert(false); throw new NotSupportedException(); }
} }
#if ModernKeePassLib
public HashingStreamEx(Stream sBaseStream, bool bWriting, IDigest hashAlgorithm)
#else
public HashingStreamEx(Stream sBaseStream, bool bWriting, HashAlgorithm hashAlgorithm) public HashingStreamEx(Stream sBaseStream, bool bWriting, HashAlgorithm hashAlgorithm)
#endif
{ {
if(sBaseStream == null) throw new ArgumentNullException("sBaseStream"); if(sBaseStream == null) throw new ArgumentNullException("sBaseStream");
m_sBaseStream = sBaseStream; m_sBaseStream = sBaseStream;
m_bWriting = bWriting; m_bWriting = bWriting;
#if ModernKeePassLib
m_hash = hashAlgorithm ?? new Sha256Digest(); #if !KeePassLibSD
#elif !KeePassLibSD
m_hash = (hashAlgorithm ?? new SHA256Managed()); m_hash = (hashAlgorithm ?? new SHA256Managed());
#else // KeePassLibSD #else // KeePassLibSD
m_hash = null; m_hash = null;
@@ -105,14 +91,11 @@ namespace ModernKeePassLib.Cryptography
if(m_hash == null) { Debug.Assert(false); return; } if(m_hash == null) { Debug.Assert(false); return; }
// Validate hash algorithm // Validate hash algorithm
#if ModernKeePassLib
#else
if(!m_hash.CanReuseTransform || !m_hash.CanTransformMultipleBlocks) if(!m_hash.CanReuseTransform || !m_hash.CanTransformMultipleBlocks)
{ {
Debug.Assert(false); Debug.Assert(false);
m_hash = null; m_hash = null;
} }
#endif
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@@ -123,15 +106,9 @@ namespace ModernKeePassLib.Cryptography
{ {
try try
{ {
#if ModernKeePassLib
m_pbFinalHash = new byte[32];
m_hash.DoFinal(m_pbFinalHash, 0);
m_hash.Reset();
#else
m_hash.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0); m_hash.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
m_pbFinalHash = m_hash.Hash; m_pbFinalHash = m_hash.Hash;
#endif
} }
catch(Exception) { Debug.Assert(false); } catch(Exception) { Debug.Assert(false); }
@@ -178,11 +155,7 @@ namespace ModernKeePassLib.Cryptography
#endif #endif
if((m_hash != null) && (nRead > 0)) if((m_hash != null) && (nRead > 0))
#if ModernKeePassLib
m_hash.BlockUpdate(pbBuffer, nOffset, nRead);
#else
m_hash.TransformBlock(pbBuffer, nOffset, nRead, pbBuffer, nOffset); m_hash.TransformBlock(pbBuffer, nOffset, nRead, pbBuffer, nOffset);
#endif
#if DEBUG #if DEBUG
Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg)); Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg));
@@ -201,11 +174,7 @@ namespace ModernKeePassLib.Cryptography
#endif #endif
if((m_hash != null) && (nCount > 0)) if((m_hash != null) && (nCount > 0))
#if ModernKeePassLib
m_hash.BlockUpdate(pbBuffer, nOffset, nCount);
#else
m_hash.TransformBlock(pbBuffer, nOffset, nCount, pbBuffer, nOffset); m_hash.TransformBlock(pbBuffer, nOffset, nCount, pbBuffer, nOffset);
#endif
#if DEBUG #if DEBUG
Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg)); Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg));

View File

@@ -55,13 +55,12 @@
<Compile Include="Cryptography\Cipher\CtrBlockCipher.cs" /> <Compile Include="Cryptography\Cipher\CtrBlockCipher.cs" />
<Compile Include="Cryptography\Cipher\Salsa20Cipher.cs" /> <Compile Include="Cryptography\Cipher\Salsa20Cipher.cs" />
<Compile Include="Cryptography\Cipher\StandardAesEngine.cs" /> <Compile Include="Cryptography\Cipher\StandardAesEngine.cs" />
<Compile Include="Cryptography\CryptographicHashExtensions.cs" />
<Compile Include="Cryptography\CryptoRandom.cs" /> <Compile Include="Cryptography\CryptoRandom.cs" />
<Compile Include="Cryptography\CryptoRandomStream.cs" /> <Compile Include="Cryptography\CryptoRandomStream.cs" />
<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\HashAlgorithm.cs" />
<Compile Include="Cryptography\Hash\HMAC.cs" /> <Compile Include="Cryptography\Hash\HMAC.cs" />
<Compile Include="Cryptography\Hash\HMACSHA1.cs" /> <Compile Include="Cryptography\Hash\HMACSHA1.cs" />
<Compile Include="Cryptography\Hash\HMACSHA256.cs" /> <Compile Include="Cryptography\Hash\HMACSHA256.cs" />

View File

@@ -75,7 +75,7 @@ namespace ModernKeePassLib.Serialization
if(m_sCopyTo != null) m_sCopyTo.Write(pb, 0, pb.Length); if(m_sCopyTo != null) m_sCopyTo.Write(pb, 0, pb.Length);
return pb; return pb;
} }
catch(Exception ex) catch(Exception)
{ {
if(!string.IsNullOrEmpty(m_strReadExcp)) if(!string.IsNullOrEmpty(m_strReadExcp))
throw new IOException(m_strReadExcp); throw new IOException(m_strReadExcp);

View File

@@ -147,7 +147,7 @@ namespace ModernKeePassLib.Serialization
{ {
bool bMadeUnhidden = UrlUtil.UnhideFile(m_iocBase.Path); bool bMadeUnhidden = UrlUtil.UnhideFile(m_iocBase.Path);
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT) #if (!ModernKeePassLib && !KeePassLibSD)
FileSecurity bkSecurity = null; FileSecurity bkSecurity = null;
bool bEfsEncrypted = false; bool bEfsEncrypted = false;
#endif #endif
@@ -161,7 +161,7 @@ namespace ModernKeePassLib.Serialization
if(IOConnection.FileExists(m_iocBase)) if(IOConnection.FileExists(m_iocBase))
{ {
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT) #if (!ModernKeePassLib && !KeePassLibSD)
if(m_iocBase.IsLocalFile()) if(m_iocBase.IsLocalFile())
{ {
try try
@@ -183,7 +183,7 @@ namespace ModernKeePassLib.Serialization
IOConnection.RenameFile(m_iocTemp, m_iocBase); IOConnection.RenameFile(m_iocTemp, m_iocBase);
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT) #if (!ModernKeePassLib && !KeePassLibSD)
if(m_iocBase.IsLocalFile()) if(m_iocBase.IsLocalFile())
{ {
try try

View File

@@ -283,7 +283,7 @@ namespace ModernKeePassLib.Serialization
if(m_nBufferPos > 0) if(m_nBufferPos > 0)
{ {
byte[] pbHash = CryptoUtil.HashSha256(m_pbBuffer.Where((x, i) => i < m_nBufferPos).ToArray(), 0, m_nBufferPos); byte[] pbHash = CryptoUtil.HashSha256(m_pbBuffer, 0, m_nBufferPos);
// For KeePassLibSD: // For KeePassLibSD:
// SHA256Managed sha256 = new SHA256Managed(); // SHA256Managed sha256 = new SHA256Managed();

View File

@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
#if ModernKeePassLib #if ModernKeePassLib