Changed test project type to WIndows 8.1

Changed test project framework from Nunit to MSTest
Changed HashAlgorithm from BouncyCastle to WinRT crypto
WIP progress bar in opendatabaseusercontrol
TextBox with button made generic
WIP implement copy on button click in Entry Page
This commit is contained in:
2017-11-06 19:01:01 +01:00
committed by BONNEVILLE Geoffroy
parent 53a54252e3
commit 8e690747e2
85 changed files with 2836 additions and 672 deletions

View File

@@ -7,11 +7,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePass", "ModernKeeP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib", "ModernKeePassLib\ModernKeePassLib.csproj", "{2E710089-9559-4967-846C-E763DD1F3ACB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{067456C0-086C-46A8-B37F-1405717B7BFC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib.Test.old", "ModernKeePassLib.Test\ModernKeePassLib.Test.old.csproj", "{067456C0-086C-46A8-B37F-1405717B7BFC}"
ProjectSection(ProjectDependencies) = postProject
{2E710089-9559-4967-846C-E763DD1F3ACB} = {2E710089-9559-4967-846C-E763DD1F3ACB}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{0A4279CF-2A67-4868-9906-052E50C25F3B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -80,6 +82,30 @@ Global
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x64.Build.0 = Release|Any CPU
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x86.ActiveCfg = Release|Any CPU
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x86.Build.0 = Release|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|ARM.ActiveCfg = Debug|ARM
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|ARM.Build.0 = Debug|ARM
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|ARM.Deploy.0 = Debug|ARM
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x64.ActiveCfg = Debug|x64
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x64.Build.0 = Debug|x64
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x64.Deploy.0 = Debug|x64
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x86.ActiveCfg = Debug|x86
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x86.Build.0 = Debug|x86
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Debug|x86.Deploy.0 = Debug|x86
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|Any CPU.Build.0 = Release|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|Any CPU.Deploy.0 = Release|Any CPU
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|ARM.ActiveCfg = Release|ARM
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|ARM.Build.0 = Release|ARM
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|ARM.Deploy.0 = Release|ARM
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x64.ActiveCfg = Release|x64
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x64.Build.0 = Release|x64
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x64.Deploy.0 = Release|x64
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.ActiveCfg = Release|x86
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.Build.0 = Release|x86
{0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -8,6 +8,8 @@
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:actions="using:ModernKeePass.Actions"
xmlns:converters="using:ModernKeePass.Converters"
xmlns:local="using:ModernKeePass.Controls"
xmlns:viewModels="using:ModernKeePass.ViewModels"
mc:Ignorable="d"
d:DesignHeight="120"
d:DesignWidth="550" >
@@ -16,7 +18,13 @@
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter"/>
<converters:DoubleToForegroungBrushComplexityConverter x:Key="DoubleToForegroungBrushComplexityConverter"/>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<Style TargetType="local:OpenDatabaseUserControl">
<Setter Property="Password" Value="{Binding Password, Mode=TwoWay}"/>
</Style>
</UserControl.Resources>
<!--<UserControl.DataContext>
<viewModels:OpenDatabaseUserControlVm />
</UserControl.DataContext>-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
@@ -35,7 +43,11 @@
</core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors>
</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}}" />
<ProgressBar x:Name="progressBar" Grid.Row="0" Grid.Column="1"
Maximum="128" Width="500" VerticalAlignment="Bottom"
Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}"
Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}"
Visibility="{Binding CreateNew, ElementName=UserControl, Converter={StaticResource BooleanToVisibilityConverter}}" />
<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" />
<Button Grid.Column="0" Grid.Row="2" Content="OK" Click="OpenButton_OnClick" Background="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" Foreground="{ThemeResource TextBoxBackgroundThemeBrush}" />

View File

@@ -5,7 +5,6 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
using ModernKeePass.Common;
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

View File

@@ -6,15 +6,38 @@ namespace ModernKeePass.Controls
{
public class TextBoxWithButton : TextBox
{
public event EventHandler<RoutedEventArgs> GotoClick;
/*public Symbol ButtonSymbol
{
get { return (Symbol)GetValue(ButtonSymbolProperty); }
set { SetValue(ButtonSymbolProperty, value); }
}
public static readonly DependencyProperty ButtonSymbolProperty =
DependencyProperty.Register(
"ButtonSymbol",
typeof(Symbol),
typeof(TextBoxWithButton),
new PropertyMetadata(Symbol.Delete, (o, args) => { }));*/
public string ButtonSymbol
{
get { return (string)GetValue(ButtonSymbolProperty); }
set { SetValue(ButtonSymbolProperty, value); }
}
public static readonly DependencyProperty ButtonSymbolProperty =
DependencyProperty.Register(
"ButtonSymbol",
typeof(string),
typeof(TextBoxWithButton),
new PropertyMetadata("&#xE107;", (o, args) => { }));
public event EventHandler<RoutedEventArgs> ButtonClick;
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
var extraButton = GetTemplateChild("GotoButton") as Button;
if (extraButton != null)
var actionButton = GetTemplateChild("ActionButton") as Button;
if (actionButton != null)
{
extraButton.Click += (sender, e) => GotoClick?.Invoke(sender, e);
actionButton.Click += (sender, e) => ButtonClick?.Invoke(sender, e);
}
}
}

View File

@@ -161,7 +161,7 @@
<DependentUpon>WelcomePage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\AboutVm.cs" />
<Compile Include="ViewModels\Controls\OpenDatabaseUserControlVM.cs" />
<Compile Include="ViewModels\Controls\OpenDatabaseUserControlVm.cs" />
<Compile Include="ViewModels\Items\ListMenuItemVm.cs" />
<Compile Include="ViewModels\Items\MainMenuItemVm.cs" />
<Compile Include="ViewModels\Items\RecentItemVm.cs" />
@@ -296,7 +296,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
<HintPath>..\packages\Validation.2.4.15\lib\portable-net45+win8+wp8+wpa81\Validation.dll</HintPath>
<HintPath>..\packages\Validation.2.4.18\lib\portable-net45+win8+wp8+wpa81\Validation.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>

View File

@@ -428,14 +428,14 @@
</Style>
</StackPanel.Resources>
<TextBlock TextWrapping="Wrap" Text="User name or login" FontSize="18"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding UserName, Mode=TwoWay}" Width="350" Height="32" />
<local:TextBoxWithButton HorizontalAlignment="Left" Text="{Binding UserName, Mode=TwoWay}" Width="350" Height="32" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="&#xE16F;" />
<TextBlock TextWrapping="Wrap" Text="Password" FontSize="18"/>
<PasswordBox HorizontalAlignment="Left" Password="{Binding Password, Mode=TwoWay}" Width="350" Height="32" IsPasswordRevealButtonEnabled="True" Visibility="{Binding IsRevealPassword, Converter={StaticResource InverseBooleanToVisibilityConverter}}" Style="{StaticResource PasswordBoxWithButtonStyle}" />
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Password, Mode=TwoWay}" Width="350" Height="32" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" />
<local:TextBoxWithButton HorizontalAlignment="Left" Text="{Binding Password, Mode=TwoWay}" Width="350" Height="32" Visibility="{Binding IsRevealPassword, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource TextBoxWithButtonStyle}" ButtonSymbol="&#xE16F;" />
<ProgressBar Value="{Binding PasswordComplexityIndicator, ConverterParameter=0\,128, Converter={StaticResource ProgressBarLegalValuesConverter}}" Maximum="128" Width="350" HorizontalAlignment="Left" Foreground="{Binding PasswordComplexityIndicator, ConverterParameter=128, Converter={StaticResource DoubleToForegroungBrushComplexityConverter}}" />
<CheckBox HorizontalAlignment="Left" Margin="-3,0,0,0" Content="Show password" IsChecked="{Binding IsRevealPassword, Mode=TwoWay}" IsEnabled="{Binding IsRevealPasswordEnabled}" />
<TextBlock TextWrapping="Wrap" Text="URL" FontSize="18"/>
<local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" GotoClick="UrlButton_Click" />
<local:TextBoxWithButton x:Name="UrlTextBox" HorizontalAlignment="Left" Text="{Binding Url, Mode=TwoWay}" Height="32" Width="350" MaxLength="256" Style="{StaticResource TextBoxWithButtonStyle}" ButtonClick="UrlButton_Click" ButtonSymbol="&#xE111;" />
<TextBlock TextWrapping="Wrap" Text="Notes" FontSize="18"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Notes, Mode=TwoWay}" Width="350" Height="200" AcceptsReturn="True" IsSpellCheckEnabled="True" />
<CheckBox FontSize="18" IsChecked="{Binding HasExpirationDate, Mode=TwoWay}" Content="Expiration date"/>

View File

@@ -6,7 +6,8 @@
xmlns:viewModels="using:ModernKeePass.ViewModels"
xmlns:local="using:ModernKeePass.Controls"
xmlns:converters="using:ModernKeePass.Converters"
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"
x:Class="ModernKeePass.Pages.RecentDatabasesPage"
mc:Ignorable="d">
<Page.Resources>
@@ -35,9 +36,9 @@
<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />
<local:OpenDatabaseUserControl Grid.Row="2" x:Name="DatabaseUserControl" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecking="OpenDatabaseUserControl_OnValidationChecking" >
<interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="ValidationChecked">
<Core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
</Core:EventTriggerBehavior>
<core:EventTriggerBehavior EventName="ValidationChecked">
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</local:OpenDatabaseUserControl>
</Grid>

View File

@@ -1,8 +1,9 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:ModernKeePass.Controls">
<Style TargetType="TextBox" x:Name="TextBoxWithButtonStyle">
<Style TargetType="controls:TextBoxWithButton" x:Name="TextBoxWithButtonStyle">
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
<Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}" />
@@ -18,10 +19,10 @@
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<ControlTemplate TargetType="controls:TextBoxWithButton">
<Grid>
<Grid.Resources>
<Style x:Name="GotoButtonStyle" TargetType="Button">
<Style x:Name="ActionButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
@@ -87,7 +88,7 @@
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontStyle="Normal"
Text="&#xE111;"
Text="{TemplateBinding Content}"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
AutomationProperties.AccessibilityView="Raw"/>
</Border>
@@ -148,7 +149,7 @@
<VisualStateGroup x:Name="ButtonStates">
<VisualState x:Name="ButtonVisible">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GotoButton"
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ActionButton"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
@@ -212,14 +213,15 @@
Grid.ColumnSpan="2"
Content="{TemplateBinding PlaceholderText}"
IsHitTestVisible="False"/>
<Button x:Name="GotoButton"
<Button x:Name="ActionButton"
Grid.Row="1"
Style="{StaticResource GotoButtonStyle}"
Style="{StaticResource ActionButtonStyle}"
BorderThickness="{TemplateBinding BorderThickness}"
IsTabStop="False"
Grid.Column="1"
Visibility="Collapsed"
FontSize="{TemplateBinding FontSize}"
Content="{TemplateBinding ButtonSymbol}"
VerticalAlignment="Stretch"/>
</Grid>
</ControlTemplate>

View File

@@ -5,7 +5,18 @@ namespace ModernKeePass.ViewModels
{
public class OpenDatabaseUserControlVm: NotifyPropertyChangedBase
{
private string _password;
//public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
public string Password
{
get { return _password; }
set
{
_password = value;
OnPropertyChanged("PasswordComplexityIndicator");
}
}
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
}
}

View File

@@ -25,7 +25,7 @@ namespace ModernKeePass.ViewModels
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password.ToCharArray());
public bool IsFirstItem => _pwEntry == null;
public double PasswordLength { get; set; } = 25;
public bool UpperCasePatternSelected { get; set; } = true;
public bool LowerCasePatternSelected { get; set; } = true;
public bool DigitsPatternSelected { get; set; } = true;
@@ -37,6 +37,15 @@ namespace ModernKeePass.ViewModels
public string CustomChars { get; set; } = string.Empty;
public PwUuid IdUuid => _pwEntry?.Uuid;
public double PasswordLength
{
get { return _passwordLength; }
set
{
_passwordLength = value;
NotifyPropertyChanged("PasswordLength");
}
}
public string Name
{
get
@@ -54,6 +63,7 @@ namespace ModernKeePass.ViewModels
get { return GetEntryValue(PwDefs.UserNameField); }
set { SetEntryValue(PwDefs.UserNameField, value); }
}
public string Password
{
get { return GetEntryValue(PwDefs.PasswordField); }
@@ -91,6 +101,7 @@ namespace ModernKeePass.ViewModels
get { return new DateTimeOffset(_pwEntry.ExpiryTime.Date); }
set { if (HasExpirationDate) _pwEntry.ExpiryTime = value.DateTime; }
}
public TimeSpan ExpiryTime
{
get { return _pwEntry.ExpiryTime.TimeOfDay; }
@@ -142,6 +153,7 @@ namespace ModernKeePass.ViewModels
private readonly App _app = (App)Application.Current;
private bool _isEditMode;
private bool _isRevealPassword;
private double _passwordLength = 25;
private void NotifyPropertyChanged(string propertyName)
{

View File

@@ -24,5 +24,5 @@
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="win81" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="win81" />
<package id="System.Xml.XmlSerializer" version="4.3.0" targetFramework="win81" />
<package id="Validation" version="2.4.15" targetFramework="win81" />
<package id="Validation" version="2.4.18" targetFramework="win81" />
</packages>

View File

@@ -0,0 +1,204 @@
using System;
using System.Diagnostics;
using System.IO;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Cipher;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Cipher
{
[TestFixture]
public class Chacha20Tests
{
[Test]
public void TestChacha20()
{
// ======================================================
// Test vector from RFC 7539, section 2.3.2
byte[] pbKey = new byte[32];
for (int i = 0; i < 32; ++i) pbKey[i] = (byte)i;
byte[] pbIV = new byte[12];
pbIV[3] = 0x09;
pbIV[7] = 0x4A;
byte[] pbExpc = new byte[64] {
0x10, 0xF1, 0xE7, 0xE4, 0xD1, 0x3B, 0x59, 0x15,
0x50, 0x0F, 0xDD, 0x1F, 0xA3, 0x20, 0x71, 0xC4,
0xC7, 0xD1, 0xF4, 0xC7, 0x33, 0xC0, 0x68, 0x03,
0x04, 0x22, 0xAA, 0x9A, 0xC3, 0xD4, 0x6C, 0x4E,
0xD2, 0x82, 0x64, 0x46, 0x07, 0x9F, 0xAA, 0x09,
0x14, 0xC2, 0xD7, 0x05, 0xD9, 0x8B, 0x02, 0xA2,
0xB5, 0x12, 0x9C, 0xD1, 0xDE, 0x16, 0x4E, 0xB9,
0xCB, 0xD0, 0x83, 0xE8, 0xA2, 0x50, 0x3C, 0x4E
};
byte[] pb = new byte[64];
using (ChaCha20Cipher c = new ChaCha20Cipher(pbKey, pbIV))
{
c.Seek(64, SeekOrigin.Begin); // Skip first block
c.Encrypt(pb, 0, pb.Length);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
}
#if DEBUG
// ======================================================
// Test vector from RFC 7539, section 2.4.2
pbIV[3] = 0;
pb = StrUtil.Utf8.GetBytes("Ladies and Gentlemen of the clas" +
@"s of '99: If I could offer you only one tip for " +
@"the future, sunscreen would be it.");
pbExpc = new byte[] {
0x6E, 0x2E, 0x35, 0x9A, 0x25, 0x68, 0xF9, 0x80,
0x41, 0xBA, 0x07, 0x28, 0xDD, 0x0D, 0x69, 0x81,
0xE9, 0x7E, 0x7A, 0xEC, 0x1D, 0x43, 0x60, 0xC2,
0x0A, 0x27, 0xAF, 0xCC, 0xFD, 0x9F, 0xAE, 0x0B,
0xF9, 0x1B, 0x65, 0xC5, 0x52, 0x47, 0x33, 0xAB,
0x8F, 0x59, 0x3D, 0xAB, 0xCD, 0x62, 0xB3, 0x57,
0x16, 0x39, 0xD6, 0x24, 0xE6, 0x51, 0x52, 0xAB,
0x8F, 0x53, 0x0C, 0x35, 0x9F, 0x08, 0x61, 0xD8,
0x07, 0xCA, 0x0D, 0xBF, 0x50, 0x0D, 0x6A, 0x61,
0x56, 0xA3, 0x8E, 0x08, 0x8A, 0x22, 0xB6, 0x5E,
0x52, 0xBC, 0x51, 0x4D, 0x16, 0xCC, 0xF8, 0x06,
0x81, 0x8C, 0xE9, 0x1A, 0xB7, 0x79, 0x37, 0x36,
0x5A, 0xF9, 0x0B, 0xBF, 0x74, 0xA3, 0x5B, 0xE6,
0xB4, 0x0B, 0x8E, 0xED, 0xF2, 0x78, 0x5E, 0x42,
0x87, 0x4D
};
byte[] pb64 = new byte[64];
using (ChaCha20Cipher c = new ChaCha20Cipher(pbKey, pbIV))
{
c.Encrypt(pb64, 0, pb64.Length); // Skip first block
c.Encrypt(pb, 0, pb.Length);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
}
// ======================================================
// Test vector from RFC 7539, appendix A.2 #2
Array.Clear(pbKey, 0, pbKey.Length);
pbKey[31] = 1;
Array.Clear(pbIV, 0, pbIV.Length);
pbIV[11] = 2;
pb = StrUtil.Utf8.GetBytes("Any submission to the IETF inten" +
"ded by the Contributor for publication as all or" +
" part of an IETF Internet-Draft or RFC and any s" +
"tatement made within the context of an IETF acti" +
"vity is considered an \"IETF Contribution\". Such " +
"statements include oral statements in IETF sessi" +
"ons, as well as written and electronic communica" +
"tions made at any time or place, which are addressed to");
pbExpc = MemUtil.HexStringToByteArray(
"A3FBF07DF3FA2FDE4F376CA23E82737041605D9F4F4F57BD8CFF2C1D4B7955EC" +
"2A97948BD3722915C8F3D337F7D370050E9E96D647B7C39F56E031CA5EB6250D" +
"4042E02785ECECFA4B4BB5E8EAD0440E20B6E8DB09D881A7C6132F420E527950" +
"42BDFA7773D8A9051447B3291CE1411C680465552AA6C405B7764D5E87BEA85A" +
"D00F8449ED8F72D0D662AB052691CA66424BC86D2DF80EA41F43ABF937D3259D" +
"C4B2D0DFB48A6C9139DDD7F76966E928E635553BA76C5C879D7B35D49EB2E62B" +
"0871CDAC638939E25E8A1E0EF9D5280FA8CA328B351C3C765989CBCF3DAA8B6C" +
"CC3AAF9F3979C92B3720FC88DC95ED84A1BE059C6499B9FDA236E7E818B04B0B" +
"C39C1E876B193BFE5569753F88128CC08AAA9B63D1A16F80EF2554D7189C411F" +
"5869CA52C5B83FA36FF216B9C1D30062BEBCFD2DC5BCE0911934FDA79A86F6E6" +
"98CED759C3FF9B6477338F3DA4F9CD8514EA9982CCAFB341B2384DD902F3D1AB" +
"7AC61DD29C6F21BA5B862F3730E37CFDC4FD806C22F221");
using (MemoryStream msEnc = new MemoryStream())
{
using (ChaCha20Stream c = new ChaCha20Stream(msEnc, true, pbKey, pbIV))
{
Random r = CryptoRandom.NewWeakRandom();
r.NextBytes(pb64);
c.Write(pb64, 0, pb64.Length); // Skip first block
int p = 0;
while (p < pb.Length)
{
int cb = r.Next(1, pb.Length - p + 1);
c.Write(pb, p, cb);
p += cb;
}
Debug.Assert(p == pb.Length);
}
byte[] pbEnc0 = msEnc.ToArray();
byte[] pbEnc = MemUtil.Mid(pbEnc0, 64, pbEnc0.Length - 64);
Assert.That(MemUtil.ArraysEqual(pbEnc, pbExpc), Is.True);
using (MemoryStream msCT = new MemoryStream(pbEnc0, false))
{
using (ChaCha20Stream cDec = new ChaCha20Stream(msCT, false,
pbKey, pbIV))
{
byte[] pbPT = MemUtil.Read(cDec, pbEnc0.Length);
Assert.That(cDec.ReadByte(), Is.LessThan(0));
Assert.That(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 0, 64), pb64), Is.True);
Assert.That(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 64, pbEnc.Length), pb), Is.True);
}
}
}
// ======================================================
// Test vector TC8 from RFC draft by J. Strombergson:
// https://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-01
pbKey = new byte[32] {
0xC4, 0x6E, 0xC1, 0xB1, 0x8C, 0xE8, 0xA8, 0x78,
0x72, 0x5A, 0x37, 0xE7, 0x80, 0xDF, 0xB7, 0x35,
0x1F, 0x68, 0xED, 0x2E, 0x19, 0x4C, 0x79, 0xFB,
0xC6, 0xAE, 0xBE, 0xE1, 0xA6, 0x67, 0x97, 0x5D
};
// The first 4 bytes are set to zero and a large counter
// is used; this makes the RFC 7539 version of ChaCha20
// compatible with the original specification by
// D. J. Bernstein.
pbIV = new byte[12] { 0x00, 0x00, 0x00, 0x00,
0x1A, 0xDA, 0x31, 0xD5, 0xCF, 0x68, 0x82, 0x21
};
pb = new byte[128];
pbExpc = new byte[128] {
0xF6, 0x3A, 0x89, 0xB7, 0x5C, 0x22, 0x71, 0xF9,
0x36, 0x88, 0x16, 0x54, 0x2B, 0xA5, 0x2F, 0x06,
0xED, 0x49, 0x24, 0x17, 0x92, 0x30, 0x2B, 0x00,
0xB5, 0xE8, 0xF8, 0x0A, 0xE9, 0xA4, 0x73, 0xAF,
0xC2, 0x5B, 0x21, 0x8F, 0x51, 0x9A, 0xF0, 0xFD,
0xD4, 0x06, 0x36, 0x2E, 0x8D, 0x69, 0xDE, 0x7F,
0x54, 0xC6, 0x04, 0xA6, 0xE0, 0x0F, 0x35, 0x3F,
0x11, 0x0F, 0x77, 0x1B, 0xDC, 0xA8, 0xAB, 0x92,
0xE5, 0xFB, 0xC3, 0x4E, 0x60, 0xA1, 0xD9, 0xA9,
0xDB, 0x17, 0x34, 0x5B, 0x0A, 0x40, 0x27, 0x36,
0x85, 0x3B, 0xF9, 0x10, 0xB0, 0x60, 0xBD, 0xF1,
0xF8, 0x97, 0xB6, 0x29, 0x0F, 0x01, 0xD1, 0x38,
0xAE, 0x2C, 0x4C, 0x90, 0x22, 0x5B, 0xA9, 0xEA,
0x14, 0xD5, 0x18, 0xF5, 0x59, 0x29, 0xDE, 0xA0,
0x98, 0xCA, 0x7A, 0x6C, 0xCF, 0xE6, 0x12, 0x27,
0x05, 0x3C, 0x84, 0xE4, 0x9A, 0x4A, 0x33, 0x32
};
using (ChaCha20Cipher c = new ChaCha20Cipher(pbKey, pbIV, true))
{
c.Decrypt(pb, 0, pb.Length);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
}
#endif
}
}
}

View File

@@ -0,0 +1,84 @@
using System;
using System.IO;
using System.Security;
using System.Text;
using ModernKeePassLib.Serialization;
using ModernKeePassLib.Utility;
#if KeePassLib
using KeePassLib.Cryptography.Cipher;
#else
using ModernKeePassLib.Cryptography.Cipher;
#endif
using NUnit.Framework;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace ModernKeePassLib.Test.Cryptography.Cipher
{
[TestFixture()]
public class StandardAesEngineTests
{
// Test vector (official ECB test vector #356)
private byte[] pbReferenceCT = new byte[16] {
0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7
};
[Test]
public void TestEncryptStream()
{
byte[] pbIV = new byte[16];
byte[] pbTestKey = new byte[32];
byte[] pbTestData = new byte[16];
pbTestData[0] = 0x04;
var outStream = new MemoryStream(new byte[16]);
var aes = new StandardAesEngine();
var inStream = aes.EncryptStream(outStream, pbTestKey, pbIV);
new BinaryWriter(inStream).Write(pbTestData);
//Assert.That(outStream.Position, Is.EqualTo(16));
outStream.Position = 0;
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.That(outBytes, Is.EqualTo(pbReferenceCT));
}
[Test]
public void TestDecryptStream()
{
byte[] pbIV = new byte[16];
byte[] pbTestKey = new byte[32];
byte[] pbTestData = new byte[16];
pbTestData[0] = 0x04;
// Possible Mono Bug? This only works with size >= 48
var inStream = new MemoryStream(new byte[32]);
inStream.Write(pbReferenceCT, 0, pbReferenceCT.Length);
inStream.Position = 0;
var aes = new StandardAesEngine();
var outStream = aes.DecryptStream(inStream, pbTestKey, pbIV);
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.That(outBytes, Is.EqualTo(pbTestData));
}
[Test]
public void TestBouncyCastleAes()
{
byte[] pbIV = new byte[16];
byte[] pbTestKey = new byte[32];
byte[] pbTestData = new byte[16];
/*int i;
for (i = 0; i < 16; ++i) pbIV[i] = 0;
for (i = 0; i < 32; ++i) pbTestKey[i] = 0;
for (i = 0; i < 16; ++i) pbTestData[i] = 0;*/
pbTestData[0] = 0x04;
var aesEngine = new AesEngine();
//var parametersWithIv = new ParametersWithIV(new KeyParameter(pbTestKey), pbIV);
aesEngine.Init(true, new KeyParameter(pbTestKey));
Assert.That(aesEngine.GetBlockSize(), Is.EqualTo(pbTestData.Length));
aesEngine.ProcessBlock(pbTestData, 0, pbTestData, 0);
//Assert.That(MemUtil.ArraysEqual(pbTestData, pbReferenceCT), Is.False);
Assert.That(pbTestData, Is.EqualTo(pbReferenceCT));
}
}
}

View File

@@ -0,0 +1,60 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using ModernKeePassLib.Cryptography;
#endif
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class CryptoRandomStreamTests
{
void TestGetRandomBytes(CryptoRandomStream stream)
{
const uint length = 16;
var bytes1 = stream.GetRandomBytes (length);
Assert.That (bytes1.Length, Is.EqualTo (length));
var bytes2 = stream.GetRandomBytes (length);
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
}
[Test ()]
public void TestGetRandomBytesCrsAlgorithmSalsa20 ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.Salsa20, new byte[16]);
TestGetRandomBytes (stream);
}
[Test ()]
public void TestGetRandomBytesCrsAlgorithmArcFourVariant ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.ArcFourVariant, new byte[16]);
TestGetRandomBytes (stream);
}
void TestGetRandomInt64 (CryptoRandomStream stream)
{
var value1 = stream.GetRandomUInt64 ();
var value2 = stream.GetRandomUInt64 ();
Assert.That (value2, Is.Not.EqualTo (value1));
}
[Test ()]
public void TestGetRandomInt64AlgorithmSalsa20 ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.Salsa20, new byte[16]);
TestGetRandomInt64 (stream);
}
[Test ()]
public void TestGetRandomInt64AlgorithmArcFourVariant ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.ArcFourVariant, new byte[16]);
TestGetRandomInt64 (stream);
}
}
}

View File

@@ -0,0 +1,44 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using ModernKeePassLib.Cryptography;
#endif
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class CryptoRandomTests
{
[Test ()]
public void TestAddEntropy ()
{
// just making sure it does not throw an exception
CryptoRandom.Instance.AddEntropy (new byte[1]);
}
[Test ()]
public void TestGetRandomBytes ()
{
const int length = 32;
var bytes1 = CryptoRandom.Instance.GetRandomBytes (length);
Assert.That (bytes1.Length, Is.EqualTo (length));
var bytes2 = CryptoRandom.Instance.GetRandomBytes (length);
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
}
[Test ()]
public void TestGeneratedBytesCount ()
{
const int length = 1;
CryptoRandom.Instance.GetRandomBytes (length);
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
CryptoRandom.Instance.GetRandomBytes (length);
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
Assert.That (count2, Is.GreaterThan (count1));
}
}
}

View File

@@ -0,0 +1,89 @@
using System;
using System.Text;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Hash;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Hash
{
[TestFixture]
public class Blake2bTests
{
[Test]
public void TestBlake2b()
{
Blake2b h = new Blake2b();
// ======================================================
// From https://tools.ietf.org/html/rfc7693
byte[] pbData = StrUtil.Utf8.GetBytes("abc");
byte[] pbExpc = new byte[64] {
0xBA, 0x80, 0xA5, 0x3F, 0x98, 0x1C, 0x4D, 0x0D,
0x6A, 0x27, 0x97, 0xB6, 0x9F, 0x12, 0xF6, 0xE9,
0x4C, 0x21, 0x2F, 0x14, 0x68, 0x5A, 0xC4, 0xB7,
0x4B, 0x12, 0xBB, 0x6F, 0xDB, 0xFF, 0xA2, 0xD1,
0x7D, 0x87, 0xC5, 0x39, 0x2A, 0xAB, 0x79, 0x2D,
0xC2, 0x52, 0xD5, 0xDE, 0x45, 0x33, 0xCC, 0x95,
0x18, 0xD3, 0x8A, 0xA8, 0xDB, 0xF1, 0x92, 0x5A,
0xB9, 0x23, 0x86, 0xED, 0xD4, 0x00, 0x99, 0x23
};
byte[] pbC = h.ComputeHash(pbData);
Assert.That(MemUtil.ArraysEqual(pbC, pbExpc), Is.True);
// ======================================================
// Computed using the official b2sum tool
pbExpc = new byte[64] {
0x78, 0x6A, 0x02, 0xF7, 0x42, 0x01, 0x59, 0x03,
0xC6, 0xC6, 0xFD, 0x85, 0x25, 0x52, 0xD2, 0x72,
0x91, 0x2F, 0x47, 0x40, 0xE1, 0x58, 0x47, 0x61,
0x8A, 0x86, 0xE2, 0x17, 0xF7, 0x1F, 0x54, 0x19,
0xD2, 0x5E, 0x10, 0x31, 0xAF, 0xEE, 0x58, 0x53,
0x13, 0x89, 0x64, 0x44, 0x93, 0x4E, 0xB0, 0x4B,
0x90, 0x3A, 0x68, 0x5B, 0x14, 0x48, 0xB7, 0x55,
0xD5, 0x6F, 0x70, 0x1A, 0xFE, 0x9B, 0xE2, 0xCE
};
pbC = h.ComputeHash(MemUtil.EmptyByteArray);
Assert.That(MemUtil.ArraysEqual(pbC, pbExpc), Is.True);
// ======================================================
// Computed using the official b2sum tool
string strS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:,;_-\r\n";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; ++i) sb.Append(strS);
pbData = StrUtil.Utf8.GetBytes(sb.ToString());
pbExpc = new byte[64] {
0x59, 0x69, 0x8D, 0x3B, 0x83, 0xF4, 0x02, 0x4E,
0xD8, 0x99, 0x26, 0x0E, 0xF4, 0xE5, 0x9F, 0x20,
0xDC, 0x31, 0xEE, 0x5B, 0x45, 0xEA, 0xBB, 0xFC,
0x1C, 0x0A, 0x8E, 0xED, 0xAA, 0x7A, 0xFF, 0x50,
0x82, 0xA5, 0x8F, 0xBC, 0x4A, 0x46, 0xFC, 0xC5,
0xEF, 0x44, 0x4E, 0x89, 0x80, 0x7D, 0x3F, 0x1C,
0xC1, 0x94, 0x45, 0xBB, 0xC0, 0x2C, 0x95, 0xAA,
0x3F, 0x08, 0x8A, 0x93, 0xF8, 0x75, 0x91, 0xB0
};
Random r = CryptoRandom.NewWeakRandom();
int p = 0;
while (p < pbData.Length)
{
int cb = r.Next(1, pbData.Length - p + 1);
h.TransformBlock(pbData, p, cb, pbData, p);
p += cb;
}
Assert.That(p, Is.EqualTo(pbData.Length));
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
Assert.That(MemUtil.ArraysEqual(h.Hash, pbExpc), Is.True);
h.Clear();
}
}
}

View File

@@ -0,0 +1,117 @@
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Hash;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Hash
{
[TestFixture]
public class HmacTests
{
[Test]
public void TestHmac1()
{
// Test vectors from RFC 4231
var pbKey = new byte[20];
for (var i = 0; i < pbKey.Length; ++i) pbKey[i] = 0x0B;
var pbMsg = StrUtil.Utf8.GetBytes("Hi There");
var pbExpc = new byte[]
{
0xB0, 0x34, 0x4C, 0x61, 0xD8, 0xDB, 0x38, 0x53,
0x5C, 0xA8, 0xAF, 0xCE, 0xAF, 0x0B, 0xF1, 0x2B,
0x88, 0x1D, 0xC2, 0x00, 0xC9, 0x83, 0x3D, 0xA7,
0x26, 0xE9, 0x37, 0x6C, 0x2E, 0x32, 0xCF, 0xF7
};
HmacEval(pbKey, pbMsg, pbExpc);
}
[Test]
public void TestHmac2()
{
var pbKey = new byte[131];
for (var i = 0; i < pbKey.Length; ++i) pbKey[i] = 0xAA;
var pbMsg = StrUtil.Utf8.GetBytes(
"This is a test using a larger than block-size key and " +
"a larger than block-size data. The key needs to be " +
"hashed before being used by the HMAC algorithm.");
var pbExpc = new byte[] {
0x9B, 0x09, 0xFF, 0xA7, 0x1B, 0x94, 0x2F, 0xCB,
0x27, 0x63, 0x5F, 0xBC, 0xD5, 0xB0, 0xE9, 0x44,
0xBF, 0xDC, 0x63, 0x64, 0x4F, 0x07, 0x13, 0x93,
0x8A, 0x7F, 0x51, 0x53, 0x5C, 0x3A, 0x35, 0xE2
};
HmacEval(pbKey, pbMsg, pbExpc);
}
[Test]
public void TestHmacSha1ComputeHash()
{
var expectedHash = "AC2C2E614882CE7158F69B7E3B12114465945D01";
var message = StrUtil.Utf8.GetBytes("testing123");
var key = StrUtil.Utf8.GetBytes("hello");
using (var result = new HMACSHA1(key))
{
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
}
}
[Test]
public void TestHmacSha256ComputeHash()
{
var expectedHash = "09C1BD2DE4E5659C0EFAF9E6AE4723E9CF96B69609B4E562F6AFF1745D7BF4E0";
var message = StrUtil.Utf8.GetBytes("testing123");
var key = StrUtil.Utf8.GetBytes("hello");
using (var result = new HMACSHA256(key))
{
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);
}
[Test]
public void TestHmacOtp()
{
var pbSecret = StrUtil.Utf8.GetBytes("12345678901234567890");
var vExp = new []{ "755224", "287082", "359152",
"969429", "338314", "254676", "287922", "162583", "399871",
"520489" };
for (var i = 0; i < vExp.Length; ++i)
{
Assert.That(HmacOtp.Generate(pbSecret, (ulong)i, 6, false, -1), Is.EqualTo(vExp[i]));
}
}
private static void HmacEval(byte[] pbKey, byte[] pbMsg,
byte[] pbExpc)
{
using (var h = new HMACSHA256(pbKey))
{
h.TransformBlock(pbMsg, 0, pbMsg.Length, pbMsg, 0);
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
byte[] pbHash = h.Hash;
Assert.That(MemUtil.ArraysEqual(pbHash, pbExpc), Is.True);
// Reuse the object
h.Initialize();
h.TransformBlock(pbMsg, 0, pbMsg.Length, pbMsg, 0);
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
pbHash = h.Hash;
Assert.That(MemUtil.ArraysEqual(pbHash, pbExpc), Is.True);
}
}
}
}

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

@@ -0,0 +1,71 @@
using System.IO;
using NUnit.Framework;
using ModernKeePassLib.Cryptography;
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class HashingStreamExTests
{
const string data = "test";
// The expected hash includes the \n added by WriteLine
static readonly byte[] sha256HashOfData = {
0xf2, 0xca, 0x1b, 0xb6, 0xc7, 0xe9, 0x07, 0xd0,
0x6d, 0xaf, 0xe4, 0x68, 0x7e, 0x57, 0x9f, 0xce,
0x76, 0xb3, 0x7e, 0x4e, 0x93, 0xb7, 0x60, 0x50,
0x22, 0xda, 0x52, 0xe6, 0xcc, 0xc2, 0x6f, 0xd2
};
[Test ()]
public void TestRead ()
{
// if we use larger size, StreamReader will read past newline and cause bad hash
var bytes = new byte[data.Length + 1];
using (var ms = new MemoryStream (bytes)) {
using (var sw = new StreamWriter (ms)) {
// set NewLine to ensure we don't run into cross-platform issues on Windows
sw.NewLine = "\n";
sw.WriteLine (data);
}
}
using (var ms = new MemoryStream (bytes)) {
using (var hs = new HashingStreamEx (ms, false, null)) {
using (var sr = new StreamReader (hs)) {
var read = sr.ReadLine ();
Assert.That (read, Is.EqualTo (data));
}
// When the StreamReader is disposed, it calls Dispose on the
//HasingStreamEx, which computes the hash.
Assert.That (hs.Hash, Is.EqualTo (sha256HashOfData));
}
}
}
[Test ()]
public void TestWrite ()
{
var bytes = new byte[16];
using (var ms = new MemoryStream (bytes)) {
using (var hs = new HashingStreamEx (ms, true, null)) {
using (var sw = new StreamWriter (hs)) {
// set NewLine to ensure we don't run into cross-platform issues on Windows
sw.NewLine = "\n";
sw.WriteLine (data);
}
// When the StreamWriter is disposed, it calls Dispose on the
//HasingStreamEx, which computes the hash.
Assert.That (hs.Hash, Is.EqualTo (sha256HashOfData));
}
}
using (var ms = new MemoryStream (bytes)) {
using (var sr = new StreamReader (ms)) {
var read = sr.ReadLine ();
Assert.That (read, Is.EqualTo (data));
}
}
}
}
}

View File

@@ -0,0 +1,36 @@
using NUnit.Framework;
using System;
using System.Text;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using ModernKeePassLib.Cryptography;
#endif
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class HmacOtpTests
{
// Using the test case from Appendix D of RFC 4226
const string secret = "12345678901234567890";
static readonly string[] expectedHOTP = new string[] {
"755224", "287082", "359152", "969429", "338314",
"254676", "287922", "162583", "399871", "520489"
};
[Test ()]
public void TestGenerate ()
{
var secretBytes = Encoding.UTF8.GetBytes (secret);
for (ulong i = 0; i < 10; i++) {
var hotp = HmacOtp.Generate (secretBytes, i, 6, false, -1);
Assert.That (hotp, Is.EqualTo (expectedHOTP[i]));
}
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
{
[TestFixture]
public class AesKdfTests
{
[Test]
public void TestAesKdf()
{
// Up to KeePass 2.34, the OtpKeyProv plugin used the public
// CompositeKey.TransformKeyManaged method (and a finalizing
// SHA-256 computation), which became an internal method of
// the AesKdf class in KeePass 2.35, thus OtpKeyProv now
// uses the AesKdf class; here we ensure that the results
// are the same
var r = CryptoRandom.NewWeakRandom();
var pbKey = new byte[32];
r.NextBytes(pbKey);
var pbSeed = new byte[32];
r.NextBytes(pbSeed);
var uRounds = (ulong)r.Next(1, 0x7FFF);
var pbMan = new byte[pbKey.Length];
Array.Copy(pbKey, pbMan, pbKey.Length);
Assert.That(AesKdf.TransformKeyManaged(pbMan, pbSeed, uRounds), Is.True);
pbMan = CryptoUtil.HashSha256(pbMan);
var kdf = new AesKdf();
var p = kdf.GetDefaultParameters();
p.SetUInt64(AesKdf.ParamRounds, uRounds);
p.SetByteArray(AesKdf.ParamSeed, pbSeed);
var pbKdf = kdf.Transform(pbKey, p);
Assert.That(MemUtil.ArraysEqual(pbMan, pbKdf), Is.True);
}
}
}

View File

@@ -0,0 +1,145 @@
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
{
[TestFixture]
public class Argon2Tests
{
[Test]
public void TestArgon2()
{
Argon2Kdf kdf = new Argon2Kdf();
// ======================================================
// From the official Argon2 1.3 reference code package
// (test vector for Argon2d 1.3); also on
// https://tools.ietf.org/html/draft-irtf-cfrg-argon2-00
var p = kdf.GetDefaultParameters();
kdf.Randomize(p);
Assert.That(p.GetUInt32(Argon2Kdf.ParamVersion, 0), Is.EqualTo(0x13U));
byte[] pbMsg = new byte[32];
for (int i = 0; i < pbMsg.Length; ++i) pbMsg[i] = 1;
p.SetUInt64(Argon2Kdf.ParamMemory, 32 * 1024);
p.SetUInt64(Argon2Kdf.ParamIterations, 3);
p.SetUInt32(Argon2Kdf.ParamParallelism, 4);
byte[] pbSalt = new byte[16];
for (int i = 0; i < pbSalt.Length; ++i) pbSalt[i] = 2;
p.SetByteArray(Argon2Kdf.ParamSalt, pbSalt);
byte[] pbKey = new byte[8];
for (int i = 0; i < pbKey.Length; ++i) pbKey[i] = 3;
p.SetByteArray(Argon2Kdf.ParamSecretKey, pbKey);
byte[] pbAssoc = new byte[12];
for (int i = 0; i < pbAssoc.Length; ++i) pbAssoc[i] = 4;
p.SetByteArray(Argon2Kdf.ParamAssocData, pbAssoc);
byte[] pbExpc = new byte[32] {
0x51, 0x2B, 0x39, 0x1B, 0x6F, 0x11, 0x62, 0x97,
0x53, 0x71, 0xD3, 0x09, 0x19, 0x73, 0x42, 0x94,
0xF8, 0x68, 0xE3, 0xBE, 0x39, 0x84, 0xF3, 0xC1,
0xA1, 0x3A, 0x4D, 0xB9, 0xFA, 0xBE, 0x4A, 0xCB
};
byte[] pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
// ======================================================
// From the official Argon2 1.3 reference code package
// (test vector for Argon2d 1.0)
p.SetUInt32(Argon2Kdf.ParamVersion, 0x10);
pbExpc = new byte[32] {
0x96, 0xA9, 0xD4, 0xE5, 0xA1, 0x73, 0x40, 0x92,
0xC8, 0x5E, 0x29, 0xF4, 0x10, 0xA4, 0x59, 0x14,
0xA5, 0xDD, 0x1F, 0x5C, 0xBF, 0x08, 0xB2, 0x67,
0x0D, 0xA6, 0x8A, 0x02, 0x85, 0xAB, 0xF3, 0x2B
};
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
// ======================================================
// From the official 'phc-winner-argon2-20151206.zip'
// (test vector for Argon2d 1.0)
p.SetUInt64(Argon2Kdf.ParamMemory, 16 * 1024);
pbExpc = new byte[32] {
0x57, 0xB0, 0x61, 0x3B, 0xFD, 0xD4, 0x13, 0x1A,
0x0C, 0x34, 0x88, 0x34, 0xC6, 0x72, 0x9C, 0x2C,
0x72, 0x29, 0x92, 0x1E, 0x6B, 0xBA, 0x37, 0x66,
0x5D, 0x97, 0x8C, 0x4F, 0xE7, 0x17, 0x5E, 0xD2
};
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
// ======================================================
// Computed using the official 'argon2' application
// (test vectors for Argon2d 1.3)
p = kdf.GetDefaultParameters();
pbMsg = StrUtil.Utf8.GetBytes("ABC1234");
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 11) * 1024); // 2 MB
p.SetUInt64(Argon2Kdf.ParamIterations, 2);
p.SetUInt32(Argon2Kdf.ParamParallelism, 2);
pbSalt = StrUtil.Utf8.GetBytes("somesalt");
p.SetByteArray(Argon2Kdf.ParamSalt, pbSalt);
pbExpc = new byte[32] {
0x29, 0xCB, 0xD3, 0xA1, 0x93, 0x76, 0xF7, 0xA2,
0xFC, 0xDF, 0xB0, 0x68, 0xAC, 0x0B, 0x99, 0xBA,
0x40, 0xAC, 0x09, 0x01, 0x73, 0x42, 0xCE, 0xF1,
0x29, 0xCC, 0xA1, 0x4F, 0xE1, 0xC1, 0xB7, 0xA3
};
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 10) * 1024); // 1 MB
p.SetUInt64(Argon2Kdf.ParamIterations, 3);
pbExpc = new byte[32] {
0x7A, 0xBE, 0x1C, 0x1C, 0x8D, 0x7F, 0xD6, 0xDC,
0x7C, 0x94, 0x06, 0x3E, 0xD8, 0xBC, 0xD8, 0x1C,
0x2F, 0x87, 0x84, 0x99, 0x12, 0x83, 0xFE, 0x76,
0x00, 0x64, 0xC4, 0x58, 0xA4, 0xDA, 0x35, 0x70
};
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 20) * 1024); // 1 GB
p.SetUInt64(Argon2Kdf.ParamIterations, 2);
p.SetUInt32(Argon2Kdf.ParamParallelism, 3);
pbExpc = new byte[32] {
0xE6, 0xE7, 0xCB, 0xF5, 0x5A, 0x06, 0x93, 0x05,
0x32, 0xBA, 0x86, 0xC6, 0x1F, 0x45, 0x17, 0x99,
0x65, 0x41, 0x77, 0xF9, 0x30, 0x55, 0x9A, 0xE8,
0x3D, 0x21, 0x48, 0xC6, 0x2D, 0x0C, 0x49, 0x11
};
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
}
}
}

View File

@@ -0,0 +1,33 @@
using NUnit.Framework;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Keys;
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class CompositeKeyTests
{
[Test]
public void TestGenerateKey32 ()
{
var originalKey = new byte[32];
var expectedKey = new byte[32] {
0xF0, 0xED, 0x57, 0xD5, 0xF0, 0xDA, 0xF3, 0x47,
0x90, 0xD0, 0xDB, 0x43, 0x25, 0xC6, 0x81, 0x2C,
0x81, 0x6A, 0x0D, 0x94, 0x96, 0xA9, 0x03, 0xE1,
0x20, 0xD4, 0x3A, 0x3E, 0x45, 0xAD, 0x02, 0x65
};
const ulong rounds = 1;
var composite = new CompositeKey ();
AesKdf kdf = new AesKdf();
KdfParameters p = kdf.GetDefaultParameters();
p.SetUInt64(AesKdf.ParamRounds, rounds);
p.SetByteArray(AesKdf.ParamSeed, originalKey);
var key = composite.GenerateKey32(p);
Assert.That (key, Is.Not.Null);
var keyData = key.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedKey));
}
}
}

View File

@@ -0,0 +1,39 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Keys;
#else
using ModernKeePassLib.Keys;
#endif
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class KcpCustomKeyTests
{
static readonly byte[] testData = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
[Test ()]
public void TestConstruct ()
{
var expectedHash = new byte[32] {
0xAF, 0x55, 0x70, 0xF5, 0xA1, 0x81, 0x0B, 0x7A,
0xF7, 0x8C, 0xAF, 0x4B, 0xC7, 0x0A, 0x66, 0x0F,
0x0D, 0xF5, 0x1E, 0x42, 0xBA, 0xF9, 0x1D, 0x4D,
0xE5, 0xB2, 0x32, 0x8D, 0xE0, 0xE8, 0x3D, 0xFC
};
var key = new KcpCustomKey ("test1", testData, false);
var keyData = key.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (testData));
key = new KcpCustomKey ("test2", testData, true);
keyData = key.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedHash));
}
}
}

View File

@@ -0,0 +1,76 @@
using NUnit.Framework;
using System;
using System.IO;
#if KeePassLib
using KeePassLib.Keys;
#else
using ModernKeePassLib.Keys;
#endif
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class KcpKeyFileTests
{
const string testCreateFile = "TestCreate.xml";
const string testKey = "0123456789";
const string expectedFileStart =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<KeyFile>\r\n" +
"\t<Meta>\r\n" +
"\t\t<Version>1.00</Version>\r\n" +
"\t</Meta>\r\n" +
"\t<Key>\r\n" +
"\t\t<Data>";
const string expectedFileEnd = "\t</Key>\r\n" +
"</KeyFile>\r\n";
[Test ()]
public void TestConstruct ()
{
var expectedKeyData = new byte[32] {
0xC1, 0xB1, 0x12, 0x77, 0x23, 0xB8, 0x99, 0xB8,
0xB9, 0x3B, 0x1B, 0xFF, 0x6C, 0xBE, 0xA1, 0x5B,
0x8B, 0x99, 0xAC, 0xBD, 0x99, 0x51, 0x85, 0x95,
0x31, 0xAA, 0x14, 0x3D, 0x95, 0xBF, 0x63, 0xFF
};
var fullPath = Path.Combine(Path.GetTempPath(), testCreateFile);
using (var fs = new FileStream(fullPath, FileMode.Create)) {
using (var sw = new StreamWriter(fs)) {
sw.Write (expectedFileStart);
sw.Write (testKey);
sw.Write (expectedFileEnd);
}
}
try {
var keyFile = new KcpKeyFile (fullPath);
var keyData = keyFile.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedKeyData));
} finally {
File.Delete (fullPath);
}
}
[Test ()]
public void TestCreate ()
{
var fullPath = Path.Combine(Path.GetTempPath(), testCreateFile);
File.Create(fullPath).Close();
KcpKeyFile.Create (fullPath, null);
try {
var fileContents = File.ReadAllText (fullPath);
Assert.That (fileContents.Length, Is.EqualTo (187));
Assert.That (fileContents, Does.StartWith (expectedFileStart));
Assert.That (fileContents, Does.EndWith (expectedFileEnd));
} finally {
File.Delete (fullPath);
}
}
}
}

View File

@@ -0,0 +1,33 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Keys;
#else
using ModernKeePassLib.Keys;
#endif
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class KcpPasswordTests
{
const string testPassword = "password";
[Test ()]
public void TestConstruct ()
{
var expectedHash = new byte[32] {
0x5E, 0x88, 0x48, 0x98, 0xDA, 0x28, 0x04, 0x71,
0x51, 0xD0, 0xE5, 0x6F, 0x8D, 0xC6, 0x29, 0x27,
0x73, 0x60, 0x3D, 0x0D, 0x6A, 0xAB, 0xBD, 0xD6,
0x2A, 0x11, 0xEF, 0x72, 0x1D, 0x15, 0x42, 0xD8
};
var key = new KcpPassword (testPassword);
var keyData = key.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedHash));
}
}
}

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{067456C0-086C-46A8-B37F-1405717B7BFC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ModernKeePassLib.Test</RootNamespace>
<AssemblyName>ModernKeePassLib.Test</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto">
<HintPath>..\packages\Portable.BouncyCastle.1.8.1.3\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.2.0.0\lib\Net45\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
<HintPath>..\packages\Validation.2.4.18\lib\net45\Validation.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Cryptography\Hash\SHAManagedTests.cs" />
<Compile Include="Cryptography\KeyDerivation\Argon2Tests.cs" />
<Compile Include="Cryptography\Hash\Blake2bTests.cs" />
<Compile Include="Cryptography\Cipher\Chacha20Tests.cs" />
<Compile Include="Cryptography\Hash\HmacTests.cs" />
<Compile Include="Cryptography\Cipher\StandardAesEngineTests.cs" />
<Compile Include="Cryptography\CryptoRandomStreamTests.cs" />
<Compile Include="Cryptography\CryptoRandomTests.cs" />
<Compile Include="Cryptography\HashingStreamExTests.cs" />
<Compile Include="Cryptography\HmacOtpTests.cs" />
<Compile Include="Cryptography\KeyDerivation\AesKdfTests.cs" />
<Compile Include="Keys\CompositeKeyTests.cs" />
<Compile Include="Keys\KcpCustomKeyTests.cs" />
<Compile Include="Keys\KcpKeyFileTests.cs" />
<Compile Include="Keys\KcpPasswordTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serialization\HashedBlockStreamTests.cs" />
<Compile Include="Serialization\KdbxFileTests.cs" />
<Compile Include="Utility\GfxUtilTests.cs" />
<Compile Include="Utility\MemUtilTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModernKeePassLib\ModernKeePassLib.csproj">
<Project>{2e710089-9559-4967-846c-e763dd1f3acb}</Project>
<Name>ModernKeePassLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ModernKeePassLib.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModernKeePassLib.Test")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("067456c0-086c-46a8-b37f-1405717b7bfc")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
using NUnit.Framework;
using System;
using System.IO;
#if KeePassLib
using KeePassLib.Serialization;
#else
using ModernKeePassLib.Serialization;
#endif
namespace ModernKeePassLib.Test.Serialization
{
[TestFixture ()]
public class HashedBlockStreamTests
{
static readonly byte[] data = new byte[16];
static readonly byte[] hashStreamData = new byte[] {
// The first 4 bytes are an integer indicating the block index
0x00, 0x00, 0x00, 0x00,
// Then the SHA-256 hash of the data
0x37, 0x47, 0x08, 0xFF, 0xF7, 0x71, 0x9D, 0xD5,
0x97, 0x9E, 0xC8, 0x75, 0xD5, 0x6C, 0xD2, 0x28,
0x6F, 0x6D, 0x3C, 0xF7, 0xEC, 0x31, 0x7A, 0x3B,
0x25, 0x63, 0x2A, 0xAB, 0x28, 0xEC, 0x37, 0xBB,
// then an integer that is the length of the data
0x10, 0x00, 0x00, 0x00,
// and finally the data itself
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// Next, a terminating block
0x01, 0x00, 0x00, 0x00,
// terminating block is indicated by a hash of all 0s...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// ...and by a size of 0
0x00, 0x00, 0x00, 0x00
};
[Test ()]
public void TestRead ()
{
using (var ms = new MemoryStream (hashStreamData)) {
using (var hbs = new HashedBlockStream (ms, false)) {
using (var br = new BinaryReader(hbs)) {
var bytes = br.ReadBytes (data.Length);
Assert.That (bytes, Is.EqualTo (data));
Assert.That (() => br.ReadByte (), Throws.InstanceOf<EndOfStreamException> ());
}
}
}
}
[Test ()]
public void TestWrite ()
{
var buffer = new byte[hashStreamData.Length];
using (var ms = new MemoryStream (buffer)) {
using (var hbs = new HashedBlockStream (ms, true)) {
using (var bw = new BinaryWriter(hbs)) {
bw.Write (data);
}
}
Assert.That (buffer, Is.EqualTo (hashStreamData));
}
}
}
}

View File

@@ -0,0 +1,172 @@
using NUnit.Framework;
using System;
using System.Globalization;
using System.IO;
using System.Text;
using ModernKeePassLib.Keys;
using ModernKeePassLib.Security;
using ModernKeePassLib.Serialization;
using ModernKeePassLib.Collections;
namespace ModernKeePassLib.Test.Serialization
{
[TestFixture()]
public class KdbxFileTests
{
const string TestLocalizedAppName = "My Localized App Name";
const string TestDatabaseName = "My Database Name";
const string TestDatabaseDescription = "My Database Description";
const string TestDefaultUserName = "My Default User Name";
const string TestColor = "#FF0000"; // Red
const string TestRootGroupName = "My Root Group Name";
const string TestRootGroupNotes = "My Root Group Notes";
const string TestRootGroupDefaultAutoTypeSequence = "My Root Group Default Auto Type Sequence";
const string TestDatabase = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n" +
"<KeePassFile>\r\n" +
"\t<Meta>\r\n" +
"\t\t<Generator>" + TestLocalizedAppName + "</Generator>\r\n" +
"\t\t<DatabaseName>" + TestDatabaseName + "</DatabaseName>\r\n" +
"\t\t<DatabaseNameChanged>2017-10-23T08:03:55Z</DatabaseNameChanged>\r\n" +
"\t\t<DatabaseDescription>" + TestDatabaseDescription + "</DatabaseDescription>\r\n" +
"\t\t<DatabaseDescriptionChanged>2017-10-23T08:03:55Z</DatabaseDescriptionChanged>\r\n" +
"\t\t<DefaultUserName>" + TestDefaultUserName + "</DefaultUserName>\r\n" +
"\t\t<DefaultUserNameChanged>2017-10-23T08:03:55Z</DefaultUserNameChanged>\r\n" +
"\t\t<MaintenanceHistoryDays>365</MaintenanceHistoryDays>\r\n" +
//"\t\t<Color>" + testColor + "</Color>\r\n" +
"\t\t<Color></Color>\r\n" +
"\t\t<MasterKeyChanged>2017-10-23T08:03:55Z</MasterKeyChanged>\r\n" +
"\t\t<MasterKeyChangeRec>-1</MasterKeyChangeRec>\r\n" +
"\t\t<MasterKeyChangeForce>-1</MasterKeyChangeForce>\r\n" +
"\t\t<MemoryProtection>\r\n" +
"\t\t\t<ProtectTitle>False</ProtectTitle>\r\n" +
"\t\t\t<ProtectUserName>False</ProtectUserName>\r\n" +
"\t\t\t<ProtectPassword>True</ProtectPassword>\r\n" +
"\t\t\t<ProtectURL>False</ProtectURL>\r\n" +
"\t\t\t<ProtectNotes>False</ProtectNotes>\r\n" +
"\t\t</MemoryProtection>\r\n" +
"\t\t<RecycleBinEnabled>True</RecycleBinEnabled>\r\n" +
"\t\t<RecycleBinUUID>AAAAAAAAAAAAAAAAAAAAAA==</RecycleBinUUID>\r\n" +
"\t\t<RecycleBinChanged>2017-10-23T08:03:55Z</RecycleBinChanged>\r\n" +
"\t\t<EntryTemplatesGroup>AAAAAAAAAAAAAAAAAAAAAA==</EntryTemplatesGroup>\r\n" +
"\t\t<EntryTemplatesGroupChanged>2017-10-23T08:03:55Z</EntryTemplatesGroupChanged>\r\n" +
"\t\t<HistoryMaxItems>10</HistoryMaxItems>\r\n" +
"\t\t<HistoryMaxSize>6291456</HistoryMaxSize>\r\n" +
"\t\t<LastSelectedGroup>AAAAAAAAAAAAAAAAAAAAAA==</LastSelectedGroup>\r\n" +
"\t\t<LastTopVisibleGroup>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleGroup>\r\n" +
"\t\t<Binaries />\r\n" +
"\t\t<CustomData />\r\n" +
"\t</Meta>\r\n" +
"\t<Root>\r\n" +
"\t\t<Group>\r\n" +
"\t\t\t<UUID>AAAAAAAAAAAAAAAAAAAAAA==</UUID>\r\n" +
"\t\t\t<Name>" + TestRootGroupName + "</Name>\r\n" +
"\t\t\t<Notes>" + TestRootGroupNotes + "</Notes>\r\n" +
"\t\t\t<IconID>49</IconID>\r\n" +
"\t\t\t<Times>\r\n" +
"\t\t\t\t<CreationTime>2017-10-23T08:03:55Z</CreationTime>\r\n" +
"\t\t\t\t<LastModificationTime>2017-10-23T08:03:55Z</LastModificationTime>\r\n" +
"\t\t\t\t<LastAccessTime>2017-10-23T08:03:55Z</LastAccessTime>\r\n" +
"\t\t\t\t<ExpiryTime>2017-10-23T08:03:55Z</ExpiryTime>\r\n" +
"\t\t\t\t<Expires>False</Expires>\r\n" +
"\t\t\t\t<UsageCount>0</UsageCount>\r\n" +
"\t\t\t\t<LocationChanged>2017-10-23T08:03:55Z</LocationChanged>\r\n" +
"\t\t\t</Times>\r\n" +
"\t\t\t<IsExpanded>True</IsExpanded>\r\n" +
"\t\t\t<DefaultAutoTypeSequence>" + TestRootGroupDefaultAutoTypeSequence + "</DefaultAutoTypeSequence>\r\n" +
"\t\t\t<EnableAutoType>null</EnableAutoType>\r\n" +
"\t\t\t<EnableSearching>null</EnableSearching>\r\n" +
"\t\t\t<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>\r\n" +
"\t\t</Group>\r\n" +
"\t\t<DeletedObjects />\r\n" +
"\t</Root>\r\n" +
"</KeePassFile>";
const string TestDate = "2017-10-23T08:03:55Z";
[Test()]
public void TestLoad()
{
var database = new PwDatabase();
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(TestDatabase)))
{
var file = new KdbxFile(database);
file.Load(ms, KdbxFormat.PlainXml, null);
}
//Assert.That(database.Color.ToArgb(), Is.EqualTo(Color.Red.ToArgb()));
Assert.That(database.Compression, Is.EqualTo(PwCompressionAlgorithm.GZip));
//Assert.That (database.CustomData, Is.EqualTo ());
Assert.That(database.CustomIcons, Is.Empty);
}
[Test()]
public void TestSave()
{
var buffer = new byte[4096];
using (var ms = new MemoryStream(buffer))
{
var database = new PwDatabase();
database.New(new IOConnectionInfo(), new CompositeKey());
var date = DateTime.Parse(TestDate, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);
//var date = DateTime.UtcNow;
PwDatabase.LocalizedAppName = TestLocalizedAppName;
database.Name = TestDatabaseName;
database.NameChanged = date;
database.Description = TestDatabaseDescription;
database.DescriptionChanged = date;
database.DefaultUserName = TestDefaultUserName;
database.DefaultUserNameChanged = date;
//database.Color = Color.Red;
database.MasterKeyChanged = date;
database.RecycleBinChanged = date;
database.EntryTemplatesGroupChanged = date;
database.RootGroup.Uuid = PwUuid.Zero;
database.RootGroup.Name = TestRootGroupName;
database.RootGroup.Notes = TestRootGroupNotes;
database.RootGroup.DefaultAutoTypeSequence = TestRootGroupDefaultAutoTypeSequence;
database.RootGroup.CreationTime = date;
database.RootGroup.LastModificationTime = date;
database.RootGroup.LastAccessTime = date;
database.RootGroup.ExpiryTime = date;
database.RootGroup.LocationChanged = date;
var file = new KdbxFile(database);
file.Save(ms, null, KdbxFormat.PlainXml, null);
}
var fileContents = Encoding.UTF8.GetString(buffer).Replace("\0", "");
if (typeof(KdbxFile).Namespace.StartsWith("KeePassLib.")
&& Environment.OSVersion.Platform != PlatformID.Win32NT)
{
// Upstream KeePassLib does not specify line endings for XmlTextWriter,
// so it uses native line endings.
fileContents = fileContents.Replace("\n", "\r\n");
}
Assert.That(fileContents, Is.EqualTo(TestDatabase));
}
[Test]
public void TestSearch()
{
var database = new PwDatabase();
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(TestDatabase)))
{
var file = new KdbxFile(database);
file.Load(ms, KdbxFormat.PlainXml, null);
}
var sp = new SearchParameters()
{
SearchString = "sfsoiwsefsi"
};
var listStorage = new PwObjectList<PwEntry>();
database.RootGroup.SearchEntries(sp, listStorage);
Assert.AreEqual(0U, listStorage.UCount);
var entry = new PwEntry(true, true);
entry.Strings.Set("Title", new ProtectedString(false, "NaMe"));
database.RootGroup.AddEntry(entry, true);
sp.SearchString = "name";
database.RootGroup.SearchEntries(sp, listStorage);
Assert.AreEqual(1U, listStorage.UCount);
}
}
}

View File

@@ -0,0 +1,33 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Utility;
#else
using Splat;
using ModernKeePassLib.Utility;
#endif
namespace ModernKeePassLib.Test.Utility
{
[TestFixture ()]
public class GfxUtilTests
{
// 16x16 all white PNG file, base64 encoded
const string testImageData =
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAAsTAAA" +
"LEwEAmpwYAAAAB3RJTUUH3wMOFgIgmTCUMQAAABl0RVh0Q29tbWVudABDcmVhdG" +
"VkIHdpdGggR0lNUFeBDhcAAAAaSURBVCjPY/z//z8DKYCJgUQwqmFUw9DRAABVb" +
"QMdny4VogAAAABJRU5ErkJggg==";
[Test ()]
public void TestLoadImage ()
{
var testData = Convert.FromBase64String (testImageData);
var image = GfxUtil.ScaleImage(testData, 16, 16).GetAwaiter().GetResult();
//var image = GfxUtil.LoadImage(testData);
Assert.That (image.Width, Is.EqualTo (16));
Assert.That (image.Height, Is.EqualTo (16));
}
}
}

View File

@@ -0,0 +1,89 @@
using System.Text;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Utility
{
[TestFixture]
public class MemUtilTests
{
private byte[] _pb = CryptoRandom.Instance.GetRandomBytes((uint)CryptoRandom.NewWeakRandom().Next(0, 0x2FFFF));
[Test]
public void TestGzip()
{
var pbCompressed = MemUtil.Compress(_pb);
Assert.That(MemUtil.ArraysEqual(MemUtil.Decompress(pbCompressed), _pb), Is.True);
}
[Test]
public void TestMemUtil()
{
Encoding enc = StrUtil.Utf8;
_pb = enc.GetBytes("012345678901234567890a");
byte[] pbN = enc.GetBytes("9012");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(9));
pbN = enc.GetBytes("01234567890123");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(0));
pbN = enc.GetBytes("a");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(21));
pbN = enc.GetBytes("0a");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(20));
pbN = enc.GetBytes("1");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(1));
pbN = enc.GetBytes("b");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.LessThan(0));
pbN = enc.GetBytes("012b");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.LessThan(0));
}
[Test]
public void TestBase32()
{
byte[] pbRes = MemUtil.ParseBase32("MY======");
byte[] pbExp = Encoding.UTF8.GetBytes("f");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
pbRes = MemUtil.ParseBase32("MZXQ====");
pbExp = Encoding.UTF8.GetBytes("fo");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
pbRes = MemUtil.ParseBase32("MZXW6===");
pbExp = Encoding.UTF8.GetBytes("foo");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
pbRes = MemUtil.ParseBase32("MZXW6YQ=");
pbExp = Encoding.UTF8.GetBytes("foob");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
pbRes = MemUtil.ParseBase32("MZXW6YTB");
pbExp = Encoding.UTF8.GetBytes("fooba");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
pbRes = MemUtil.ParseBase32("MZXW6YTBOI======");
pbExp = Encoding.UTF8.GetBytes("foobar");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
pbRes = MemUtil.ParseBase32("JNSXSIDQOJXXM2LEMVZCAYTBONSWIIDPNYQG63TFFV2GS3LFEBYGC43TO5XXEZDTFY======");
pbExp = Encoding.UTF8.GetBytes("Key provider based on one-time passwords.");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
}
[Test]
public void TestMemUtil2()
{
var i = 0 - 0x10203040;
var pbRes = MemUtil.Int32ToBytes(i);
Assert.That(MemUtil.ByteArrayToHexString(pbRes), Is.EqualTo("C0CFDFEF"));
Assert.That(MemUtil.BytesToUInt32(pbRes), Is.EqualTo((uint)i));
Assert.That(MemUtil.BytesToInt32(pbRes), Is.EqualTo(i));
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net462" />
<package id="NUnit" version="3.8.1" targetFramework="net452" />
<package id="Splat" version="2.0.0" targetFramework="net462" />
<package id="Validation" version="2.4.18" targetFramework="net451" />
</packages>

View File

@@ -1,17 +1,17 @@
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Cipher;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Cipher
{
[TestFixture]
[TestClass]
public class Chacha20Tests
{
[Test]
[TestMethod]
public void TestChacha20()
{
// ======================================================
@@ -42,7 +42,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
c.Seek(64, SeekOrigin.Begin); // Skip first block
c.Encrypt(pb, 0, pb.Length);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
}
#if DEBUG
@@ -80,7 +80,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
c.Encrypt(pb64, 0, pb64.Length); // Skip first block
c.Encrypt(pb, 0, pb.Length);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
}
// ======================================================
@@ -135,7 +135,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
byte[] pbEnc0 = msEnc.ToArray();
byte[] pbEnc = MemUtil.Mid(pbEnc0, 64, pbEnc0.Length - 64);
Assert.That(MemUtil.ArraysEqual(pbEnc, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbEnc, pbExpc));
using (MemoryStream msCT = new MemoryStream(pbEnc0, false))
{
@@ -144,9 +144,9 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
{
byte[] pbPT = MemUtil.Read(cDec, pbEnc0.Length);
Assert.That(cDec.ReadByte(), Is.LessThan(0));
Assert.That(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 0, 64), pb64), Is.True);
Assert.That(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 64, pbEnc.Length), pb), Is.True);
Assert.IsTrue(cDec.ReadByte() < 0);
Assert.IsTrue(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 0, 64), pb64));
Assert.IsTrue(MemUtil.ArraysEqual(MemUtil.Mid(pbPT, 64, pbEnc.Length), pb));
}
}
}
@@ -196,7 +196,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
{
c.Decrypt(pb, 0, pb.Length);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
}
#endif
}

View File

@@ -1,22 +1,15 @@
using System;
using System.IO;
using System.Security;
using System.IO;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Serialization;
using ModernKeePassLib.Utility;
#if KeePassLib
using KeePassLib.Cryptography.Cipher;
#else
using ModernKeePassLib.Cryptography.Cipher;
#endif
using NUnit.Framework;
using ModernKeePassLib.Utility;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace ModernKeePassLib.Test.Cryptography.Cipher
{
[TestFixture()]
[TestClass()]
public class StandardAesEngineTests
{
// Test vector (official ECB test vector #356)
@@ -24,7 +17,7 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22,
0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7
};
[Test]
[TestMethod]
public void TestEncryptStream()
{
byte[] pbIV = new byte[16];
@@ -36,13 +29,13 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aes = new StandardAesEngine();
var inStream = aes.EncryptStream(outStream, pbTestKey, pbIV);
new BinaryWriter(inStream).Write(pbTestData);
//Assert.That(outStream.Position, Is.EqualTo(16));
Assert.AreEqual(outStream.Position, 16);
outStream.Position = 0;
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.That(outBytes, Is.EqualTo(pbReferenceCT));
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbReferenceCT));
}
[Test]
[TestMethod]
public void TestDecryptStream()
{
byte[] pbIV = new byte[16];
@@ -57,10 +50,10 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aes = new StandardAesEngine();
var outStream = aes.DecryptStream(inStream, pbTestKey, pbIV);
var outBytes = new BinaryReaderEx(outStream, Encoding.UTF8, string.Empty).ReadBytes(16);
Assert.That(outBytes, Is.EqualTo(pbTestData));
Assert.IsTrue(MemUtil.ArraysEqual(outBytes, pbTestData));
}
[Test]
[TestMethod]
public void TestBouncyCastleAes()
{
byte[] pbIV = new byte[16];
@@ -75,10 +68,9 @@ namespace ModernKeePassLib.Test.Cryptography.Cipher
var aesEngine = new AesEngine();
//var parametersWithIv = new ParametersWithIV(new KeyParameter(pbTestKey), pbIV);
aesEngine.Init(true, new KeyParameter(pbTestKey));
Assert.That(aesEngine.GetBlockSize(), Is.EqualTo(pbTestData.Length));
Assert.AreEqual(aesEngine.GetBlockSize(), pbTestData.Length);
aesEngine.ProcessBlock(pbTestData, 0, pbTestData, 0);
//Assert.That(MemUtil.ArraysEqual(pbTestData, pbReferenceCT), Is.False);
Assert.That(pbTestData, Is.EqualTo(pbReferenceCT));
Assert.IsTrue(MemUtil.ArraysEqual(pbTestData, pbReferenceCT));
}
}
}

View File

@@ -1,60 +1,56 @@
using NUnit.Framework;
using System;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using ModernKeePassLib.Cryptography;
#endif
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class CryptoRandomStreamTests
{
void TestGetRandomBytes(CryptoRandomStream stream)
[TestClass]
public class CryptoRandomStreamTests
{
const uint length = 16;
var bytes1 = stream.GetRandomBytes (length);
Assert.That (bytes1.Length, Is.EqualTo (length));
var bytes2 = stream.GetRandomBytes (length);
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
}
private void TestGetRandomBytes(CryptoRandomStream stream)
{
const uint length = 16;
var bytes1 = stream.GetRandomBytes(length);
Assert.AreEqual(bytes1.Length, (int)length);
var bytes2 = stream.GetRandomBytes(length);
Assert.IsFalse(MemUtil.ArraysEqual(bytes2, bytes1));
}
[Test ()]
public void TestGetRandomBytesCrsAlgorithmSalsa20 ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.Salsa20, new byte[16]);
TestGetRandomBytes (stream);
}
[TestMethod]
public void TestGetRandomBytesCrsAlgorithmSalsa20()
{
var stream = new CryptoRandomStream(CrsAlgorithm.Salsa20, new byte[16]);
TestGetRandomBytes(stream);
}
[Test ()]
public void TestGetRandomBytesCrsAlgorithmArcFourVariant ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.ArcFourVariant, new byte[16]);
TestGetRandomBytes (stream);
}
[TestMethod]
public void TestGetRandomBytesCrsAlgorithmArcFourVariant()
{
var stream = new CryptoRandomStream(CrsAlgorithm.ArcFourVariant, new byte[16]);
TestGetRandomBytes(stream);
}
void TestGetRandomInt64 (CryptoRandomStream stream)
{
var value1 = stream.GetRandomUInt64 ();
var value2 = stream.GetRandomUInt64 ();
Assert.That (value2, Is.Not.EqualTo (value1));
}
private void TestGetRandomInt64(CryptoRandomStream stream)
{
var value1 = stream.GetRandomUInt64();
var value2 = stream.GetRandomUInt64();
Assert.AreNotEqual(value2, value1);
}
[Test ()]
public void TestGetRandomInt64AlgorithmSalsa20 ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.Salsa20, new byte[16]);
TestGetRandomInt64 (stream);
}
[TestMethod]
public void TestGetRandomInt64AlgorithmSalsa20()
{
var stream = new CryptoRandomStream(CrsAlgorithm.Salsa20, new byte[16]);
TestGetRandomInt64(stream);
}
[Test ()]
public void TestGetRandomInt64AlgorithmArcFourVariant ()
{
var stream = new CryptoRandomStream (CrsAlgorithm.ArcFourVariant, new byte[16]);
TestGetRandomInt64 (stream);
[TestMethod]
public void TestGetRandomInt64AlgorithmArcFourVariant()
{
var stream = new CryptoRandomStream(CrsAlgorithm.ArcFourVariant, new byte[16]);
TestGetRandomInt64(stream);
}
}
}
}

View File

@@ -1,44 +1,38 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
#endif
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class CryptoRandomTests
{
[Test ()]
public void TestAddEntropy ()
[TestClass()]
public class CryptoRandomTests
{
// just making sure it does not throw an exception
CryptoRandom.Instance.AddEntropy (new byte[1]);
}
[TestMethod]
public void TestAddEntropy()
{
// just making sure it does not throw an exception
CryptoRandom.Instance.AddEntropy(new byte[1]);
}
[Test ()]
public void TestGetRandomBytes ()
{
const int length = 32;
var bytes1 = CryptoRandom.Instance.GetRandomBytes (length);
Assert.That (bytes1.Length, Is.EqualTo (length));
var bytes2 = CryptoRandom.Instance.GetRandomBytes (length);
Assert.That (bytes2, Is.Not.EqualTo (bytes1));
}
[TestMethod]
public void TestGetRandomBytes()
{
const int length = 32;
var bytes1 = CryptoRandom.Instance.GetRandomBytes(length);
Assert.AreEqual(bytes1.Length, length);
var bytes2 = CryptoRandom.Instance.GetRandomBytes(length);
Assert.AreNotEqual(bytes2, bytes1);
}
[Test ()]
public void TestGeneratedBytesCount ()
{
const int length = 1;
CryptoRandom.Instance.GetRandomBytes (length);
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
CryptoRandom.Instance.GetRandomBytes (length);
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
Assert.That (count2, Is.GreaterThan (count1));
[TestMethod]
public void TestGeneratedBytesCount()
{
const int length = 1;
CryptoRandom.Instance.GetRandomBytes(length);
var count1 = CryptoRandom.Instance.GeneratedBytesCount;
CryptoRandom.Instance.GetRandomBytes(length);
var count2 = CryptoRandom.Instance.GeneratedBytesCount;
Assert.IsTrue(count2 > count1);
}
}
}
}

View File

@@ -1,17 +1,17 @@
using System;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Hash;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Hash
{
[TestFixture]
[TestClass]
public class Blake2bTests
{
[Test]
public void TestBlake2b()
[TestMethod]
public void TestBlake2bUtf8()
{
Blake2b h = new Blake2b();
@@ -19,7 +19,8 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
// From https://tools.ietf.org/html/rfc7693
byte[] pbData = StrUtil.Utf8.GetBytes("abc");
byte[] pbExpc = new byte[64] {
byte[] pbExpc = new byte[64]
{
0xBA, 0x80, 0xA5, 0x3F, 0x98, 0x1C, 0x4D, 0x0D,
0x6A, 0x27, 0x97, 0xB6, 0x9F, 0x12, 0xF6, 0xE9,
0x4C, 0x21, 0x2F, 0x14, 0x68, 0x5A, 0xC4, 0xB7,
@@ -31,12 +32,18 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
};
byte[] pbC = h.ComputeHash(pbData);
Assert.That(MemUtil.ArraysEqual(pbC, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbC, pbExpc));
}
[TestMethod]
public void TestBlake2bEmpty()
{
// ======================================================
// Computed using the official b2sum tool
Blake2b h = new Blake2b();
pbExpc = new byte[64] {
var pbExpc = new byte[64]
{
0x78, 0x6A, 0x02, 0xF7, 0x42, 0x01, 0x59, 0x03,
0xC6, 0xC6, 0xFD, 0x85, 0x25, 0x52, 0xD2, 0x72,
0x91, 0x2F, 0x47, 0x40, 0xE1, 0x58, 0x47, 0x61,
@@ -47,18 +54,23 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
0xD5, 0x6F, 0x70, 0x1A, 0xFE, 0x9B, 0xE2, 0xCE
};
pbC = h.ComputeHash(MemUtil.EmptyByteArray);
Assert.That(MemUtil.ArraysEqual(pbC, pbExpc), Is.True);
var pbC = h.ComputeHash(MemUtil.EmptyByteArray);
Assert.IsTrue(MemUtil.ArraysEqual(pbC, pbExpc));
}
// ======================================================
[TestMethod]
public void TestBlake2bString()
{
// ======================================================
// Computed using the official b2sum tool
Blake2b h = new Blake2b();
string strS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:,;_-\r\n";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; ++i) sb.Append(strS);
pbData = StrUtil.Utf8.GetBytes(sb.ToString());
var pbData = StrUtil.Utf8.GetBytes(sb.ToString());
pbExpc = new byte[64] {
var pbExpc = new byte[64] {
0x59, 0x69, 0x8D, 0x3B, 0x83, 0xF4, 0x02, 0x4E,
0xD8, 0x99, 0x26, 0x0E, 0xF4, 0xE5, 0x9F, 0x20,
0xDC, 0x31, 0xEE, 0x5B, 0x45, 0xEA, 0xBB, 0xFC,
@@ -77,11 +89,11 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
h.TransformBlock(pbData, p, cb, pbData, p);
p += cb;
}
Assert.That(p, Is.EqualTo(pbData.Length));
Assert.AreEqual(p, pbData.Length);
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
Assert.That(MemUtil.ArraysEqual(h.Hash, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(h.Hash, pbExpc));
h.Clear();
}

View File

@@ -1,14 +1,14 @@
using ModernKeePassLib.Cryptography;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.Hash;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Hash
{
[TestFixture]
[TestClass]
public class HmacTests
{
[Test]
[TestMethod]
public void TestHmac1()
{
// Test vectors from RFC 4231
@@ -26,7 +26,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
HmacEval(pbKey, pbMsg, pbExpc);
}
[Test]
[TestMethod]
public void TestHmac2()
{
var pbKey = new byte[131];
@@ -44,7 +44,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
HmacEval(pbKey, pbMsg, pbExpc);
}
[Test]
[TestMethod]
public void TestHmacSha1ComputeHash()
{
var expectedHash = "AC2C2E614882CE7158F69B7E3B12114465945D01";
@@ -52,11 +52,11 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
var key = StrUtil.Utf8.GetBytes("hello");
using (var result = new HMACSHA1(key))
{
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
}
}
[Test]
[TestMethod]
public void TestHmacSha256ComputeHash()
{
var expectedHash = "09C1BD2DE4E5659C0EFAF9E6AE4723E9CF96B69609B4E562F6AFF1745D7BF4E0";
@@ -64,7 +64,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
var key = StrUtil.Utf8.GetBytes("hello");
using (var result = new HMACSHA256(key))
{
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
}
}
@@ -79,7 +79,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
return (sbinary);
}
[Test]
[TestMethod]
public void TestHmacOtp()
{
var pbSecret = StrUtil.Utf8.GetBytes("12345678901234567890");
@@ -89,7 +89,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
for (var i = 0; i < vExp.Length; ++i)
{
Assert.That(HmacOtp.Generate(pbSecret, (ulong)i, 6, false, -1), Is.EqualTo(vExp[i]));
Assert.AreEqual(HmacOtp.Generate(pbSecret, (ulong)i, 6, false, -1), vExp[i]);
}
}
@@ -102,7 +102,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
byte[] pbHash = h.Hash;
Assert.That(MemUtil.ArraysEqual(pbHash, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbHash, pbExpc));
// Reuse the object
h.Initialize();
@@ -110,7 +110,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
h.TransformFinalBlock(MemUtil.EmptyByteArray, 0, 0);
pbHash = h.Hash;
Assert.That(MemUtil.ArraysEqual(pbHash, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbHash, pbExpc));
}
}
}

View File

@@ -1,31 +1,31 @@
using ModernKeePassLib.Cryptography.Hash;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography.Hash;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.Hash
{
[TestFixture]
[TestClass]
public class SHAManagedTests
{
[Test]
[TestMethod]
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));
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
}
}
[Test]
[TestMethod]
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));
Assert.AreEqual(ByteToString(result.ComputeHash(message)), expectedHash);
}
}
private static string ByteToString(byte[] buff)

View File

@@ -1,71 +1,83 @@
using System.IO;
using NUnit.Framework;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class HashingStreamExTests
{
const string data = "test";
// The expected hash includes the \n added by WriteLine
static readonly byte[] sha256HashOfData = {
0xf2, 0xca, 0x1b, 0xb6, 0xc7, 0xe9, 0x07, 0xd0,
0x6d, 0xaf, 0xe4, 0x68, 0x7e, 0x57, 0x9f, 0xce,
0x76, 0xb3, 0x7e, 0x4e, 0x93, 0xb7, 0x60, 0x50,
0x22, 0xda, 0x52, 0xe6, 0xcc, 0xc2, 0x6f, 0xd2
};
[Test ()]
public void TestRead ()
[TestClass()]
public class HashingStreamExTests
{
// if we use larger size, StreamReader will read past newline and cause bad hash
var bytes = new byte[data.Length + 1];
using (var ms = new MemoryStream (bytes)) {
using (var sw = new StreamWriter (ms)) {
// set NewLine to ensure we don't run into cross-platform issues on Windows
sw.NewLine = "\n";
sw.WriteLine (data);
}
}
using (var ms = new MemoryStream (bytes)) {
using (var hs = new HashingStreamEx (ms, false, null)) {
using (var sr = new StreamReader (hs)) {
var read = sr.ReadLine ();
Assert.That (read, Is.EqualTo (data));
}
// When the StreamReader is disposed, it calls Dispose on the
//HasingStreamEx, which computes the hash.
Assert.That (hs.Hash, Is.EqualTo (sha256HashOfData));
}
}
}
const string data = "test";
[Test ()]
public void TestWrite ()
{
var bytes = new byte[16];
using (var ms = new MemoryStream (bytes)) {
using (var hs = new HashingStreamEx (ms, true, null)) {
using (var sw = new StreamWriter (hs)) {
// set NewLine to ensure we don't run into cross-platform issues on Windows
sw.NewLine = "\n";
sw.WriteLine (data);
}
// When the StreamWriter is disposed, it calls Dispose on the
//HasingStreamEx, which computes the hash.
Assert.That (hs.Hash, Is.EqualTo (sha256HashOfData));
// The expected hash includes the \n added by WriteLine
static readonly byte[] sha256HashOfData =
{
0xf2, 0xca, 0x1b, 0xb6, 0xc7, 0xe9, 0x07, 0xd0,
0x6d, 0xaf, 0xe4, 0x68, 0x7e, 0x57, 0x9f, 0xce,
0x76, 0xb3, 0x7e, 0x4e, 0x93, 0xb7, 0x60, 0x50,
0x22, 0xda, 0x52, 0xe6, 0xcc, 0xc2, 0x6f, 0xd2
};
[TestMethod]
public void TestRead()
{
// if we use larger size, StreamReader will read past newline and cause bad hash
var bytes = new byte[data.Length + 1];
using (var ms = new MemoryStream(bytes))
{
using (var sw = new StreamWriter(ms))
{
// set NewLine to ensure we don't run into cross-platform issues on Windows
sw.NewLine = "\n";
sw.WriteLine(data);
}
}
using (var ms = new MemoryStream(bytes))
{
using (var hs = new HashingStreamEx(ms, false, null))
{
using (var sr = new StreamReader(hs))
{
var read = sr.ReadLine();
Assert.AreEqual(read, data);
}
// When the StreamReader is disposed, it calls Dispose on the
//HasingStreamEx, which computes the hash.
Assert.IsTrue(MemUtil.ArraysEqual(hs.Hash, sha256HashOfData));
}
}
}
}
using (var ms = new MemoryStream (bytes)) {
using (var sr = new StreamReader (ms)) {
var read = sr.ReadLine ();
Assert.That (read, Is.EqualTo (data));
[TestMethod]
public void TestWrite()
{
var bytes = new byte[16];
using (var ms = new MemoryStream(bytes))
{
using (var hs = new HashingStreamEx(ms, true, null))
{
using (var sw = new StreamWriter(hs))
{
// set NewLine to ensure we don't run into cross-platform issues on Windows
sw.NewLine = "\n";
sw.WriteLine(data);
}
// When the StreamWriter is disposed, it calls Dispose on the
//HasingStreamEx, which computes the hash.
Assert.IsTrue(MemUtil.ArraysEqual(hs.Hash, sha256HashOfData));
}
}
using (var ms = new MemoryStream(bytes))
{
using (var sr = new StreamReader(ms))
{
var read = sr.ReadLine();
Assert.AreEqual(read, data);
}
}
}
}
}
}
}

View File

@@ -1,36 +1,32 @@
using NUnit.Framework;
using System;
using System.Text;
#if KeePassLib
using KeePassLib.Cryptography;
#else
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
#endif
namespace ModernKeePassLib.Test.Cryptography
{
[TestFixture ()]
public class HmacOtpTests
{
// Using the test case from Appendix D of RFC 4226
const string secret = "12345678901234567890";
static readonly string[] expectedHOTP = new string[] {
"755224", "287082", "359152", "969429", "338314",
"254676", "287922", "162583", "399871", "520489"
};
[Test ()]
public void TestGenerate ()
[TestClass()]
public class HmacOtpTests
{
var secretBytes = Encoding.UTF8.GetBytes (secret);
// Using the test case from Appendix D of RFC 4226
for (ulong i = 0; i < 10; i++) {
var hotp = HmacOtp.Generate (secretBytes, i, 6, false, -1);
Assert.That (hotp, Is.EqualTo (expectedHOTP[i]));
}
const string secret = "12345678901234567890";
static readonly string[] expectedHOTP = new string[]
{
"755224", "287082", "359152", "969429", "338314",
"254676", "287922", "162583", "399871", "520489"
};
[TestMethod]
public void TestGenerate()
{
var secretBytes = Encoding.UTF8.GetBytes(secret);
for (ulong i = 0; i < 10; i++)
{
var hotp = HmacOtp.Generate(secretBytes, i, 6, false, -1);
Assert.AreEqual(hotp, expectedHOTP[i]);
}
}
}
}
}

View File

@@ -1,15 +1,15 @@
using System;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
{
[TestFixture]
[TestClass]
public class AesKdfTests
{
[Test]
[TestMethod]
public void TestAesKdf()
{
// Up to KeePass 2.34, the OtpKeyProv plugin used the public
@@ -27,7 +27,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
var pbMan = new byte[pbKey.Length];
Array.Copy(pbKey, pbMan, pbKey.Length);
Assert.That(AesKdf.TransformKeyManaged(pbMan, pbSeed, uRounds), Is.True);
Assert.IsTrue(AesKdf.TransformKeyManaged(pbMan, pbSeed, uRounds));
pbMan = CryptoUtil.HashSha256(pbMan);
var kdf = new AesKdf();
@@ -36,7 +36,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
p.SetByteArray(AesKdf.ParamSeed, pbSeed);
var pbKdf = kdf.Transform(pbKey, p);
Assert.That(MemUtil.ArraysEqual(pbMan, pbKdf), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbMan, pbKdf));
}
}
}

View File

@@ -1,13 +1,13 @@
using ModernKeePassLib.Cryptography.KeyDerivation;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
{
[TestFixture]
[TestClass]
public class Argon2Tests
{
[Test]
[TestMethod]
public void TestArgon2()
{
Argon2Kdf kdf = new Argon2Kdf();
@@ -20,7 +20,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
var p = kdf.GetDefaultParameters();
kdf.Randomize(p);
Assert.That(p.GetUInt32(Argon2Kdf.ParamVersion, 0), Is.EqualTo(0x13U));
Assert.AreEqual(p.GetUInt32(Argon2Kdf.ParamVersion, 0), 0x13U);
byte[] pbMsg = new byte[32];
for (int i = 0; i < pbMsg.Length; ++i) pbMsg[i] = 1;
@@ -50,7 +50,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
byte[] pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
// ======================================================
// From the official Argon2 1.3 reference code package
@@ -67,7 +67,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
// ======================================================
// From the official 'phc-winner-argon2-20151206.zip'
@@ -84,7 +84,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
// ======================================================
// Computed using the official 'argon2' application
@@ -110,7 +110,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 10) * 1024); // 1 MB
p.SetUInt64(Argon2Kdf.ParamIterations, 3);
@@ -124,9 +124,10 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));
p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 20) * 1024); // 1 GB
// TODO: Out of memory exception
/*p.SetUInt64(Argon2Kdf.ParamMemory, (1 << 20) * 1024); // 1 GB
p.SetUInt64(Argon2Kdf.ParamIterations, 2);
p.SetUInt32(Argon2Kdf.ParamParallelism, 3);
@@ -139,7 +140,7 @@ namespace ModernKeePassLib.Test.Cryptography.KeyDerivation
pb = kdf.Transform(pbMsg, p);
Assert.That(MemUtil.ArraysEqual(pb, pbExpc), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pb, pbExpc));*/
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -1,33 +1,35 @@
using NUnit.Framework;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Keys;
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class CompositeKeyTests
{
[Test]
public void TestGenerateKey32 ()
[TestClass()]
public class CompositeKeyTests
{
var originalKey = new byte[32];
var expectedKey = new byte[32] {
0xF0, 0xED, 0x57, 0xD5, 0xF0, 0xDA, 0xF3, 0x47,
0x90, 0xD0, 0xDB, 0x43, 0x25, 0xC6, 0x81, 0x2C,
0x81, 0x6A, 0x0D, 0x94, 0x96, 0xA9, 0x03, 0xE1,
0x20, 0xD4, 0x3A, 0x3E, 0x45, 0xAD, 0x02, 0x65
};
const ulong rounds = 1;
[TestMethod]
public void TestGenerateKey32()
{
var originalKey = new byte[32];
var expectedKey = new byte[32]
{
0xF0, 0xED, 0x57, 0xD5, 0xF0, 0xDA, 0xF3, 0x47,
0x90, 0xD0, 0xDB, 0x43, 0x25, 0xC6, 0x81, 0x2C,
0x81, 0x6A, 0x0D, 0x94, 0x96, 0xA9, 0x03, 0xE1,
0x20, 0xD4, 0x3A, 0x3E, 0x45, 0xAD, 0x02, 0x65
};
const ulong rounds = 1;
var composite = new CompositeKey ();
AesKdf kdf = new AesKdf();
KdfParameters p = kdf.GetDefaultParameters();
p.SetUInt64(AesKdf.ParamRounds, rounds);
p.SetByteArray(AesKdf.ParamSeed, originalKey);
var key = composite.GenerateKey32(p);
Assert.That (key, Is.Not.Null);
var keyData = key.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedKey));
var composite = new CompositeKey();
AesKdf kdf = new AesKdf();
KdfParameters p = kdf.GetDefaultParameters();
p.SetUInt64(AesKdf.ParamRounds, rounds);
p.SetByteArray(AesKdf.ParamSeed, originalKey);
var key = composite.GenerateKey32(p);
Assert.IsNotNull(key);
var keyData = key.ReadData();
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedKey));
}
}
}
}

View File

@@ -1,39 +1,35 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Keys;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Keys;
#endif
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class KcpCustomKeyTests
{
static readonly byte[] testData = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
[Test ()]
public void TestConstruct ()
[TestClass()]
public class KcpCustomKeyTests
{
var expectedHash = new byte[32] {
0xAF, 0x55, 0x70, 0xF5, 0xA1, 0x81, 0x0B, 0x7A,
0xF7, 0x8C, 0xAF, 0x4B, 0xC7, 0x0A, 0x66, 0x0F,
0x0D, 0xF5, 0x1E, 0x42, 0xBA, 0xF9, 0x1D, 0x4D,
0xE5, 0xB2, 0x32, 0x8D, 0xE0, 0xE8, 0x3D, 0xFC
};
static readonly byte[] testData =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
var key = new KcpCustomKey ("test1", testData, false);
var keyData = key.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (testData));
[TestMethod]
public void TestConstruct()
{
var expectedHash = new byte[32]
{
0xAF, 0x55, 0x70, 0xF5, 0xA1, 0x81, 0x0B, 0x7A,
0xF7, 0x8C, 0xAF, 0x4B, 0xC7, 0x0A, 0x66, 0x0F,
0x0D, 0xF5, 0x1E, 0x42, 0xBA, 0xF9, 0x1D, 0x4D,
0xE5, 0xB2, 0x32, 0x8D, 0xE0, 0xE8, 0x3D, 0xFC
};
key = new KcpCustomKey ("test2", testData, true);
keyData = key.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedHash));
var key = new KcpCustomKey("test1", testData, false);
var keyData = key.KeyData.ReadData();
Assert.IsTrue(MemUtil.ArraysEqual(keyData, testData));
key = new KcpCustomKey("test2", testData, true);
keyData = key.KeyData.ReadData();
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedHash));
}
}
}
}

View File

@@ -1,76 +1,84 @@
using NUnit.Framework;
using System;
using System;
using System.IO;
#if KeePassLib
using KeePassLib.Keys;
#else
using Windows.Storage;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Keys;
#endif
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class KcpKeyFileTests
{
const string testCreateFile = "TestCreate.xml";
const string testKey = "0123456789";
const string expectedFileStart =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<KeyFile>\r\n" +
"\t<Meta>\r\n" +
"\t\t<Version>1.00</Version>\r\n" +
"\t</Meta>\r\n" +
"\t<Key>\r\n" +
"\t\t<Data>";
const string expectedFileEnd = "\t</Key>\r\n" +
"</KeyFile>\r\n";
[Test ()]
public void TestConstruct ()
[TestClass]
public class KcpKeyFileTests
{
var expectedKeyData = new byte[32] {
0xC1, 0xB1, 0x12, 0x77, 0x23, 0xB8, 0x99, 0xB8,
0xB9, 0x3B, 0x1B, 0xFF, 0x6C, 0xBE, 0xA1, 0x5B,
0x8B, 0x99, 0xAC, 0xBD, 0x99, 0x51, 0x85, 0x95,
0x31, 0xAA, 0x14, 0x3D, 0x95, 0xBF, 0x63, 0xFF
};
private const string TestCreateFile = "TestCreate.xml";
private const string TestKey = "0123456789";
var fullPath = Path.Combine(Path.GetTempPath(), testCreateFile);
using (var fs = new FileStream(fullPath, FileMode.Create)) {
using (var sw = new StreamWriter(fs)) {
sw.Write (expectedFileStart);
sw.Write (testKey);
sw.Write (expectedFileEnd);
private const string ExpectedFileStart =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<KeyFile>\r\n" +
"\t<Meta>\r\n" +
"\t\t<Version>1.00</Version>\r\n" +
"\t</Meta>\r\n" +
"\t<Key>\r\n" +
"\t\t<Data>";
private const string ExpectedFileEnd = "\t</Key>\r\n" +
"</KeyFile>\r\n";
[TestMethod]
public void TestConstruct()
{
var expectedKeyData = new byte[32]
{
0xC1, 0xB1, 0x12, 0x77, 0x23, 0xB8, 0x99, 0xB8,
0xB9, 0x3B, 0x1B, 0xFF, 0x6C, 0xBE, 0xA1, 0x5B,
0x8B, 0x99, 0xAC, 0xBD, 0x99, 0x51, 0x85, 0x95,
0x31, 0xAA, 0x14, 0x3D, 0x95, 0xBF, 0x63, 0xFF
};
var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
var file = ApplicationData.Current.TemporaryFolder.CreateFileAsync(TestCreateFile).GetAwaiter().GetResult();
using (var fs = file.OpenStreamForWriteAsync().GetAwaiter().GetResult())
{
using (var sw = new StreamWriter(fs))
{
sw.Write(ExpectedFileStart);
sw.Write(TestKey);
sw.Write(ExpectedFileEnd);
}
}
try
{
var keyFile = new KcpKeyFile(fullPath);
var keyData = keyFile.KeyData.ReadData();
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedKeyData));
}
finally
{
file.DeleteAsync().GetAwaiter().GetResult();
}
}
}
try {
var keyFile = new KcpKeyFile (fullPath);
var keyData = keyFile.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedKeyData));
} finally {
File.Delete (fullPath);
}
}
[TestMethod]
public void TestCreate()
{
var fullPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, TestCreateFile);
var file = ApplicationData.Current.TemporaryFolder.CreateFileAsync(TestCreateFile).GetAwaiter().GetResult();
KcpKeyFile.Create(fullPath, null);
try
{
var fileContents = FileIO.ReadTextAsync(file).GetAwaiter().GetResult();
[Test ()]
public void TestCreate ()
{
var fullPath = Path.Combine(Path.GetTempPath(), testCreateFile);
File.Create(fullPath).Close();
KcpKeyFile.Create (fullPath, null);
try {
var fileContents = File.ReadAllText (fullPath);
Assert.That (fileContents.Length, Is.EqualTo (187));
Assert.That (fileContents, Does.StartWith (expectedFileStart));
Assert.That (fileContents, Does.EndWith (expectedFileEnd));
} finally {
File.Delete (fullPath);
}
Assert.AreEqual(fileContents.Length, 187);
Assert.IsTrue(fileContents.StartsWith(ExpectedFileStart));
Assert.IsTrue(fileContents.EndsWith(ExpectedFileEnd));
}
finally
{
file.DeleteAsync().GetAwaiter().GetResult();
}
}
}
}
}

View File

@@ -1,33 +1,29 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Keys;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Keys;
#endif
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Keys
{
[TestFixture ()]
public class KcpPasswordTests
{
const string testPassword = "password";
[Test ()]
public void TestConstruct ()
[TestClass()]
public class KcpPasswordTests
{
var expectedHash = new byte[32] {
0x5E, 0x88, 0x48, 0x98, 0xDA, 0x28, 0x04, 0x71,
0x51, 0xD0, 0xE5, 0x6F, 0x8D, 0xC6, 0x29, 0x27,
0x73, 0x60, 0x3D, 0x0D, 0x6A, 0xAB, 0xBD, 0xD6,
0x2A, 0x11, 0xEF, 0x72, 0x1D, 0x15, 0x42, 0xD8
};
const string testPassword = "password";
var key = new KcpPassword (testPassword);
var keyData = key.KeyData.ReadData ();
Assert.That (keyData, Is.EqualTo (expectedHash));
[TestMethod]
public void TestConstruct()
{
var expectedHash = new byte[32]
{
0x5E, 0x88, 0x48, 0x98, 0xDA, 0x28, 0x04, 0x71,
0x51, 0xD0, 0xE5, 0x6F, 0x8D, 0xC6, 0x29, 0x27,
0x73, 0x60, 0x3D, 0x0D, 0x6A, 0xAB, 0xBD, 0xD6,
0x2A, 0x11, 0xEF, 0x72, 0x1D, 0x15, 0x42, 0xD8
};
var key = new KcpPassword(testPassword);
var keyData = key.KeyData.ReadData();
Assert.IsTrue(MemUtil.ArraysEqual(keyData, expectedHash));
}
}
}
}

View File

@@ -1,70 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{067456C0-086C-46A8-B37F-1405717B7BFC}</ProjectGuid>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0A4279CF-2A67-4868-9906-052E50C25F3B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ModernKeePassLib.Test</RootNamespace>
<AssemblyName>ModernKeePassLib.Test</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>ModernKeePassLib.Test_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxBundle>Never</AppxBundle>
<AllowCrossPlatformRetargeting>False</AllowCrossPlatformRetargeting>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<AppXPackage>True</AppXPackage>
<AppxPackageIncludePrivateSymbols>true</AppxPackageIncludePrivateSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto">
<HintPath>..\packages\Portable.BouncyCastle.1.8.1.3\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.2.0.0\lib\Net45\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="Windows">
<HintPath>..\ModernKeePassLib\Libs\Windows.winmd</HintPath>
</Reference>
<!--A reference to the entire .Net Framework and Windows SDK are automatically included-->
<SDKReference Include="MSTestFramework, Version=14.0" />
<SDKReference Include="TestPlatform, Version=14.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cryptography\Hash\SHAManagedTests.cs" />
<Compile Include="Cryptography\KeyDerivation\Argon2Tests.cs" />
<Compile Include="Cryptography\Hash\Blake2bTests.cs" />
<Compile Include="Cryptography\Cipher\Chacha20Tests.cs" />
<Compile Include="Cryptography\Hash\HmacTests.cs" />
<Compile Include="Cryptography\Cipher\StandardAesEngineTests.cs" />
<Compile Include="Cryptography\CryptoRandomStreamTests.cs" />
<Compile Include="Cryptography\CryptoRandomTests.cs" />
<Compile Include="Cryptography\HashingStreamExTests.cs" />
<Compile Include="Cryptography\Hash\Blake2bTests.cs" />
<Compile Include="Cryptography\Hash\HmacTests.cs" />
<Compile Include="Cryptography\Hash\SHAManagedTests.cs" />
<Compile Include="Cryptography\HmacOtpTests.cs" />
<Compile Include="Cryptography\KeyDerivation\AesKdfTests.cs" />
<Compile Include="Cryptography\KeyDerivation\Argon2Tests.cs" />
<Compile Include="Keys\CompositeKeyTests.cs" />
<Compile Include="Keys\KcpCustomKeyTests.cs" />
<Compile Include="Keys\KcpKeyFileTests.cs" />
@@ -76,7 +137,10 @@
<Compile Include="Utility\MemUtilTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="ModernKeePassLib.Test_TemporaryKey.pfx" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@@ -85,18 +149,46 @@
<Name>ModernKeePassLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.1.3\lib\netstandard1.0\BouncyCastle.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Splat, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.2.0.0\lib\Portable-Win81+Wpa81\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\win8\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
<HintPath>..\packages\Validation.2.4.18\lib\portable-net45+win8+wp8+wpa81\Validation.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Images\UnitTestLogo.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\UnitTestSmallLogo.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\UnitTestSplashScreen.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\UnitTestStoreLogo.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
</Target>
<Target Name="AfterBuild">
</Target>
-->

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="2aac30f7-3bad-4e17-be76-27de378756c9"
Publisher="CN=GBE"
Version="1.0.0.0" />
<Properties>
<DisplayName>ModernKeePassLib.Test</DisplayName>
<PublisherDisplayName>GBE</PublisherDisplayName>
<Logo>Images\UnitTestStoreLogo.png</Logo>
<Description>ModernKeePassLib.Test</Description>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.0</OSMinVersion>
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="vstest.executionengine.App"
Executable="vstest.executionengine.appcontainer.exe"
EntryPoint="vstest.executionengine.App">
<VisualElements
DisplayName="NoUIEntryPoints"
Logo="Images\UnitTestLogo.png"
SmallLogo="Images\UnitTestSmallLogo.png"
Description="vstest.executionengine.App"
ForegroundText="light"
BackgroundColor="#0084FF">
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
</VisualElements>
</Application>
<Application Id="vstest.executionengine.x86.App"
Executable="vstest.executionengine.appcontainer.x86.exe"
EntryPoint="vstest.executionengine.x86.App">
<VisualElements
DisplayName="NoUIEntryPoints"
Logo="Images\UnitTestLogo.png"
SmallLogo="Images\UnitTestSmallLogo.png"
Description="vstest.executionengine.x86.App"
ForegroundText="light"
BackgroundColor="#0084FF">
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>

View File

@@ -10,18 +10,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModernKeePassLib.Test")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("067456c0-086c-46a8-b37f-1405717b7bfc")]
// Version information for an assembly consists of the following four values:
//
// Major Version

View File

@@ -1,71 +1,73 @@
using NUnit.Framework;
using System;
using System.IO;
#if KeePassLib
using KeePassLib.Serialization;
#else
using System.IO;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Serialization;
#endif
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Test.Serialization
{
[TestFixture ()]
public class HashedBlockStreamTests
{
static readonly byte[] data = new byte[16];
static readonly byte[] hashStreamData = new byte[] {
// The first 4 bytes are an integer indicating the block index
0x00, 0x00, 0x00, 0x00,
// Then the SHA-256 hash of the data
0x37, 0x47, 0x08, 0xFF, 0xF7, 0x71, 0x9D, 0xD5,
0x97, 0x9E, 0xC8, 0x75, 0xD5, 0x6C, 0xD2, 0x28,
0x6F, 0x6D, 0x3C, 0xF7, 0xEC, 0x31, 0x7A, 0x3B,
0x25, 0x63, 0x2A, 0xAB, 0x28, 0xEC, 0x37, 0xBB,
// then an integer that is the length of the data
0x10, 0x00, 0x00, 0x00,
// and finally the data itself
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// Next, a terminating block
0x01, 0x00, 0x00, 0x00,
// terminating block is indicated by a hash of all 0s...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// ...and by a size of 0
0x00, 0x00, 0x00, 0x00
};
[Test ()]
public void TestRead ()
[TestClass()]
public class HashedBlockStreamTests
{
using (var ms = new MemoryStream (hashStreamData)) {
using (var hbs = new HashedBlockStream (ms, false)) {
using (var br = new BinaryReader(hbs)) {
var bytes = br.ReadBytes (data.Length);
Assert.That (bytes, Is.EqualTo (data));
Assert.That (() => br.ReadByte (), Throws.InstanceOf<EndOfStreamException> ());
}
}
}
}
static readonly byte[] data = new byte[16];
[Test ()]
public void TestWrite ()
{
var buffer = new byte[hashStreamData.Length];
using (var ms = new MemoryStream (buffer)) {
using (var hbs = new HashedBlockStream (ms, true)) {
using (var bw = new BinaryWriter(hbs)) {
bw.Write (data);
}
static readonly byte[] hashStreamData = new byte[]
{
// The first 4 bytes are an integer indicating the block index
0x00, 0x00, 0x00, 0x00,
// Then the SHA-256 hash of the data
0x37, 0x47, 0x08, 0xFF, 0xF7, 0x71, 0x9D, 0xD5,
0x97, 0x9E, 0xC8, 0x75, 0xD5, 0x6C, 0xD2, 0x28,
0x6F, 0x6D, 0x3C, 0xF7, 0xEC, 0x31, 0x7A, 0x3B,
0x25, 0x63, 0x2A, 0xAB, 0x28, 0xEC, 0x37, 0xBB,
// then an integer that is the length of the data
0x10, 0x00, 0x00, 0x00,
// and finally the data itself
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// Next, a terminating block
0x01, 0x00, 0x00, 0x00,
// terminating block is indicated by a hash of all 0s...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// ...and by a size of 0
0x00, 0x00, 0x00, 0x00
};
[TestMethod]
public void TestRead()
{
using (var ms = new MemoryStream(hashStreamData))
{
using (var hbs = new HashedBlockStream(ms, false))
{
using (var br = new BinaryReader(hbs))
{
var bytes = br.ReadBytes(data.Length);
Assert.IsTrue(MemUtil.ArraysEqual(bytes, data));
Assert.ThrowsException<EndOfStreamException>(() => br.ReadByte());
}
}
}
}
[TestMethod]
public void TestWrite()
{
var buffer = new byte[hashStreamData.Length];
using (var ms = new MemoryStream(buffer))
{
using (var hbs = new HashedBlockStream(ms, true))
{
using (var bw = new BinaryWriter(hbs))
{
bw.Write(data);
}
}
Assert.IsTrue(MemUtil.ArraysEqual(buffer, hashStreamData));
}
}
Assert.That (buffer, Is.EqualTo (hashStreamData));
}
}
}
}

View File

@@ -1,8 +1,8 @@
using NUnit.Framework;
using System;
using System;
using System.Globalization;
using System.IO;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Keys;
using ModernKeePassLib.Security;
using ModernKeePassLib.Serialization;
@@ -10,7 +10,7 @@ using ModernKeePassLib.Collections;
namespace ModernKeePassLib.Test.Serialization
{
[TestFixture()]
[TestClass()]
public class KdbxFileTests
{
const string TestLocalizedAppName = "My Localized App Name";
@@ -86,7 +86,7 @@ namespace ModernKeePassLib.Test.Serialization
const string TestDate = "2017-10-23T08:03:55Z";
[Test()]
[TestMethod]
public void TestLoad()
{
var database = new PwDatabase();
@@ -96,12 +96,12 @@ namespace ModernKeePassLib.Test.Serialization
file.Load(ms, KdbxFormat.PlainXml, null);
}
//Assert.That(database.Color.ToArgb(), Is.EqualTo(Color.Red.ToArgb()));
Assert.That(database.Compression, Is.EqualTo(PwCompressionAlgorithm.GZip));
Assert.AreEqual(database.Compression, PwCompressionAlgorithm.GZip);
//Assert.That (database.CustomData, Is.EqualTo ());
Assert.That(database.CustomIcons, Is.Empty);
Assert.IsTrue(database.CustomIcons.Count == 0);
}
[Test()]
[TestMethod]
public void TestSave()
{
var buffer = new byte[4096];
@@ -134,18 +134,17 @@ namespace ModernKeePassLib.Test.Serialization
var file = new KdbxFile(database);
file.Save(ms, null, KdbxFormat.PlainXml, null);
}
var fileContents = Encoding.UTF8.GetString(buffer).Replace("\0", "");
if (typeof(KdbxFile).Namespace.StartsWith("KeePassLib.")
&& Environment.OSVersion.Platform != PlatformID.Win32NT)
var fileContents = Encoding.UTF8.GetString(buffer, 0, buffer.Length).Replace("\0", "");
if (typeof(KdbxFile).Namespace.StartsWith("KeePassLib."))
{
// Upstream KeePassLib does not specify line endings for XmlTextWriter,
// so it uses native line endings.
fileContents = fileContents.Replace("\n", "\r\n");
}
Assert.That(fileContents, Is.EqualTo(TestDatabase));
Assert.AreEqual(fileContents, TestDatabase);
}
[Test]
[TestMethod]
public void TestSearch()
{
var database = new PwDatabase();

View File

@@ -1,16 +1,10 @@
using NUnit.Framework;
using System;
#if KeePassLib
using KeePassLib.Utility;
#else
using Splat;
using System;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Utility;
#endif
namespace ModernKeePassLib.Test.Utility
{
[TestFixture ()]
[TestClass ()]
public class GfxUtilTests
{
// 16x16 all white PNG file, base64 encoded
@@ -20,14 +14,14 @@ namespace ModernKeePassLib.Test.Utility
"VkIHdpdGggR0lNUFeBDhcAAAAaSURBVCjPY/z//z8DKYCJgUQwqmFUw9DRAABVb" +
"QMdny4VogAAAABJRU5ErkJggg==";
[Test ()]
[TestMethod]
public void TestLoadImage ()
{
var testData = Convert.FromBase64String (testImageData);
var image = GfxUtil.ScaleImage(testData, 16, 16).GetAwaiter().GetResult();
//var image = GfxUtil.LoadImage(testData);
Assert.That (image.Width, Is.EqualTo (16));
Assert.That (image.Height, Is.EqualTo (16));
Assert.AreEqual(image.Width, 16);
Assert.AreEqual(image.Height, 16);
}
}
}

View File

@@ -1,89 +1,89 @@
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Utility;
using NUnit.Framework;
namespace ModernKeePassLib.Test.Utility
{
[TestFixture]
[TestClass]
public class MemUtilTests
{
private byte[] _pb = CryptoRandom.Instance.GetRandomBytes((uint)CryptoRandom.NewWeakRandom().Next(0, 0x2FFFF));
[Test]
[TestMethod]
public void TestGzip()
{
var pbCompressed = MemUtil.Compress(_pb);
Assert.That(MemUtil.ArraysEqual(MemUtil.Decompress(pbCompressed), _pb), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(MemUtil.Decompress(pbCompressed), _pb));
}
[Test]
[TestMethod]
public void TestMemUtil()
{
Encoding enc = StrUtil.Utf8;
_pb = enc.GetBytes("012345678901234567890a");
byte[] pbN = enc.GetBytes("9012");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(9));
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 9);
pbN = enc.GetBytes("01234567890123");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(0));
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 0);
pbN = enc.GetBytes("a");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(21));
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 21);
pbN = enc.GetBytes("0a");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(20));
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 20);
pbN = enc.GetBytes("1");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.EqualTo(1));
Assert.AreEqual(MemUtil.IndexOf(_pb, pbN), 1);
pbN = enc.GetBytes("b");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.LessThan(0));
Assert.IsTrue(MemUtil.IndexOf(_pb, pbN) < 0);
pbN = enc.GetBytes("012b");
Assert.That(MemUtil.IndexOf(_pb, pbN), Is.LessThan(0));
Assert.IsTrue(MemUtil.IndexOf(_pb, pbN) < 0);
}
[Test]
[TestMethod]
public void TestBase32()
{
byte[] pbRes = MemUtil.ParseBase32("MY======");
byte[] pbExp = Encoding.UTF8.GetBytes("f");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
pbRes = MemUtil.ParseBase32("MZXQ====");
pbExp = Encoding.UTF8.GetBytes("fo");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
pbRes = MemUtil.ParseBase32("MZXW6===");
pbExp = Encoding.UTF8.GetBytes("foo");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
pbRes = MemUtil.ParseBase32("MZXW6YQ=");
pbExp = Encoding.UTF8.GetBytes("foob");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
pbRes = MemUtil.ParseBase32("MZXW6YTB");
pbExp = Encoding.UTF8.GetBytes("fooba");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
pbRes = MemUtil.ParseBase32("MZXW6YTBOI======");
pbExp = Encoding.UTF8.GetBytes("foobar");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
pbRes = MemUtil.ParseBase32("JNSXSIDQOJXXM2LEMVZCAYTBONSWIIDPNYQG63TFFV2GS3LFEBYGC43TO5XXEZDTFY======");
pbExp = Encoding.UTF8.GetBytes("Key provider based on one-time passwords.");
Assert.That(MemUtil.ArraysEqual(pbRes, pbExp), Is.True);
Assert.IsTrue(MemUtil.ArraysEqual(pbRes, pbExp));
}
[Test]
[TestMethod]
public void TestMemUtil2()
{
var i = 0 - 0x10203040;
var pbRes = MemUtil.Int32ToBytes(i);
Assert.That(MemUtil.ByteArrayToHexString(pbRes), Is.EqualTo("C0CFDFEF"));
Assert.That(MemUtil.BytesToUInt32(pbRes), Is.EqualTo((uint)i));
Assert.That(MemUtil.BytesToInt32(pbRes), Is.EqualTo(i));
Assert.AreEqual(MemUtil.ByteArrayToHexString(pbRes), "C0CFDFEF");
Assert.AreEqual(MemUtil.BytesToUInt32(pbRes), (uint)i);
Assert.AreEqual(MemUtil.BytesToInt32(pbRes), i);
}
}
}

View File

@@ -1,6 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net462" />
<package id="NUnit" version="3.8.1" targetFramework="net452" />
<package id="Splat" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="win81" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="win81" />
<package id="Portable.BouncyCastle" version="1.8.1.3" targetFramework="win81" />
<package id="Splat" version="2.0.0" targetFramework="win81" />
<package id="System.Collections" version="4.3.0" targetFramework="win81" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="win81" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="win81" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="win81" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="win81" />
<package id="System.Globalization" version="4.3.0" targetFramework="win81" />
<package id="System.IO" version="4.3.0" targetFramework="win81" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="win81" />
<package id="System.Linq" version="4.3.0" targetFramework="win81" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="win81" />
<package id="System.Net.Http" version="4.3.0" targetFramework="win81" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="win81" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="win81" />
<package id="System.Reflection" version="4.3.0" targetFramework="win81" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="win81" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="win81" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="win81" />
<package id="System.Runtime.WindowsRuntime" version="4.3.0" targetFramework="win81" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="win81" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="win81" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="win81" />
<package id="System.Threading" version="4.3.0" targetFramework="win81" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="win81" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="win81" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="win81" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="win81" />
<package id="Validation" version="2.4.18" targetFramework="win81" />
</packages>

View File

@@ -27,8 +27,8 @@ namespace ModernKeePassLib.Cryptography.Hash
if (value == null) throw new ArgumentNullException(nameof(value));
byte[] resBuf = new byte[Hmac.GetMacSize()];
Hmac.BlockUpdate(value, 0, length);
Hmac.DoFinal(resBuf, 0);
Hmac.BlockUpdate(value, offset, length);
Hmac.DoFinal(resBuf, offset);
return resBuf;
}

View File

@@ -1,15 +1,10 @@
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Macs;
using Org.BouncyCastle.Crypto.Parameters;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLib.Cryptography.Hash
{
public class HMACSHA1: HMAC
public class HMACSHA1: HashAlgorithm
{
public HMACSHA1(byte[] key)
{
Hmac = new HMac(new Sha1Digest());
Hmac.Init(new KeyParameter(key));
}
public HMACSHA1(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1).CreateHash(key.AsBuffer())) {}
}
}

View File

@@ -1,15 +1,10 @@
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Macs;
using Org.BouncyCastle.Crypto.Parameters;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLib.Cryptography.Hash
{
public class HMACSHA256: HMAC
public class HMACSHA256: HashAlgorithm
{
public HMACSHA256(byte[] key)
{
Hmac = new HMac(new Sha256Digest());
Hmac.Init(new KeyParameter(key));
}
public HMACSHA256(byte[] key) : base (MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256).CreateHash(key.AsBuffer())) {}
}
}

View File

@@ -1,25 +1,78 @@
using System;
using Org.BouncyCastle.Crypto;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Security.Cryptography.Core;
using Validation;
namespace ModernKeePassLib.Cryptography.Hash
{
public abstract class HashAlgorithm: IDisposable
{
protected IDigest Digest;
/// <summary>
/// The platform-specific hash object.
/// </summary>
private readonly CryptographicHash _hash;
public byte[] Hash
/// <summary>
/// Initializes a new instance of the <see cref="HashAlgorithm"/> class.
/// </summary>
/// <param name="hash">The platform hash.</param>
internal HashAlgorithm(CryptographicHash hash)
{
get
{
var result = new byte[Digest.GetDigestSize()];
Digest.DoFinal(result, 0);
return result;
}
Requires.NotNull(hash, "Hash");
_hash = hash;
}
public bool CanReuseTransform => true;
public bool CanTransformMultipleBlocks => true;
public byte[] Hash => _hash.GetValueAndReset().ToArray();
public void Append(byte[] data)
{
_hash.Append(data.AsBuffer());
}
public byte[] GetValueAndReset()
{
return _hash.GetValueAndReset().ToArray();
}
#region ICryptoTransform methods
public int TransformBlock(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;
}
Append(buffer);
if (outputBuffer != null)
{
Array.Copy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
}
return inputCount;
}
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{
this.TransformBlock(inputBuffer, inputOffset, inputCount, null, 0);
if (inputCount == inputBuffer.Length)
{
return inputBuffer;
}
var buffer = new byte[inputCount];
Array.Copy(inputBuffer, inputOffset, buffer, 0, inputCount);
return buffer;
}
public byte[] ComputeHash(byte[] value)
{
return ComputeHash(value, 0, value.Length);
@@ -29,33 +82,19 @@ namespace ModernKeePassLib.Cryptography.Hash
{
if (value == null) throw new ArgumentNullException(nameof(value));
byte[] resBuf = new byte[Digest.GetDigestSize()];
Digest.BlockUpdate(value, 0, length);
Digest.DoFinal(resBuf, 0);
TransformFinalBlock(value, offset, length);
var resBuf = GetValueAndReset();
return resBuf;
}
public void TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
public void Initialize()
{
Digest.BlockUpdate(inputBuffer, inputOffset, inputCount);
if ((outputBuffer != null) && ((inputBuffer != outputBuffer) || (inputOffset != outputOffset)))
Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
}
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int 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()
{
Digest.Reset();
}
#endregion
}
}

View File

@@ -1,12 +1,9 @@
using Org.BouncyCastle.Crypto.Digests;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLib.Cryptography.Hash
{
public class SHA256Managed : HashAlgorithm
{
public SHA256Managed()
{
Digest = new Sha256Digest();
}
public SHA256Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256).CreateHash()) {}
}
}

View File

@@ -1,12 +1,9 @@
using Org.BouncyCastle.Crypto.Digests;
using Windows.Security.Cryptography.Core;
namespace ModernKeePassLib.Cryptography.Hash
{
public class SHA512Managed: HashAlgorithm
{
public SHA512Managed()
{
Digest = new Sha512Digest();
}
public SHA512Managed() : base(HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha512).CreateHash()) {}
}
}

View File

@@ -268,7 +268,6 @@ namespace ModernKeePassLib.Keys
doc.Load(ms);
XmlElement el = doc.DocumentElement;
if((el == null) || !el.Name.Equals(RootElementName)) return null;
if(el.ChildNodes.Count < 2) return null;

View File

@@ -4,6 +4,6 @@
<NuGetPackageRoot>$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
</PropertyGroup>
<ImportGroup>
<Import Project="$(NuGetPackageRoot)\NETStandard.Library\2.0.0\build\NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)\NETStandard.Library\2.0.0\build\NETStandard.Library.targets')" />
<Import Project="$(NuGetPackageRoot)\NETStandard.Library\2.0.1\build\NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)\NETStandard.Library\2.0.1\build\NETStandard.Library.targets')" />
</ImportGroup>
</Project>

View File

@@ -20,17 +20,11 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
#if ModernKeePassLib
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Native;
using ModernKeePassLib.Utility;
using ModernKeePassLib.Cryptography;
#else
using KeePassLib.Cryptography;
using KeePassLib.Native;
using KeePassLib.Utility;
#endif
#if KeePassLibSD
using KeePassLibSD;

View File

@@ -19,16 +19,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Globalization;
using System.IO;
using System.Security.Cryptography;
using System.Drawing;
using System.Text;
using System.Xml.Serialization;
#if !KeePassUAP
using System.Drawing;
using System.Windows.Forms;
#endif
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Utility;
namespace ModernKeePassLib.Translation
@@ -112,7 +114,7 @@ namespace ModernKeePassLib.Translation
else { Debug.Assert(false); }
}
#if (!KeePassLibSD && !KeePassRT)
#if (!KeePassLibSD && !KeePassUAP)
internal void ApplyTo(Control c)
{
Debug.Assert(c != null); if(c == null) return;
@@ -267,7 +269,7 @@ namespace ModernKeePassLib.Translation
return m_strMemberName.CompareTo(kpOther.Name);
}
#if (!KeePassLibSD && !KeePassRT)
#if (!KeePassLibSD && !KeePassUAP)
private static readonly Type[] m_vTextControls = new Type[] {
typeof(MenuStrip), typeof(PictureBox), typeof(ListView),
typeof(TreeView), typeof(ToolStrip), typeof(WebBrowser),

View File

@@ -21,10 +21,11 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Reflection;
#if !KeePassUAP
using System.Windows.Forms;
#endif
namespace ModernKeePassLib.Translation
{
@@ -67,7 +68,7 @@ namespace ModernKeePassLib.Translation
}
}
#if (!KeePassLibSD && !KeePassRT)
#if (!KeePassLibSD && !KeePassUAP)
private Form m_formEnglish = null;
[XmlIgnore]
public Form FormEnglish

View File

@@ -19,10 +19,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Xml.Serialization;
#if !KeePassUAP
using System.Windows.Forms;
using System.Diagnostics;
#endif
namespace ModernKeePassLib.Translation
{
@@ -66,7 +69,7 @@ namespace ModernKeePassLib.Translation
return dict;
}
#if (!KeePassLibSD && !KeePassRT)
#if (!KeePassLibSD && !KeePassUAP)
public void ApplyTo(ToolStripItemCollection tsic)
{
if(tsic == null) throw new ArgumentNullException("tsic");

View File

@@ -19,24 +19,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Windows.Forms;
using System.ComponentModel;
#if !KeePassUAP
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
#endif
#if KeePassLibSD
using ICSharpCode.SharpZipLib.GZip;
#else
using System.IO.Compression;
#endif
using ModernKeePassLib.Interfaces;
using ModernKeePassLib.Utility;
#if !KeePassLibSD
using System.IO.Compression;
#else
using ICSharpCode.SharpZipLib.GZip;
#endif
namespace ModernKeePassLib.Translation
{
[XmlRoot("Translation")]

View File

@@ -2,13 +2,13 @@
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "2.0.0",
"NETStandard.Library": "2.0.1",
"Portable.BouncyCastle": "1.8.1.3",
"Splat": "2.0.0",
"System.Runtime.WindowsRuntime": "4.3.0",
"System.Xml.ReaderWriter": "4.3.0",
"System.Xml.XmlSerializer": "4.3.0",
"Validation": "2.4.15"
"Validation": "2.4.18"
},
"frameworks": {
"netstandard1.2": {}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="521e59e9-f0bf-4bdb-bf03-3f8d4c056c29"
Publisher="CN=GBE"
Version="1.0.0.0" />
<Properties>
<DisplayName>UnitTestLibrary</DisplayName>
<PublisherDisplayName>GBE</PublisherDisplayName>
<Logo>Images\UnitTestStoreLogo.png</Logo>
<Description>UnitTestLibrary</Description>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.0</OSMinVersion>
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="vstest.executionengine.App"
Executable="vstest.executionengine.appcontainer.exe"
EntryPoint="vstest.executionengine.App">
<VisualElements
DisplayName="NoUIEntryPoints"
Logo="Images\UnitTestLogo.png"
SmallLogo="Images\UnitTestSmallLogo.png"
Description="vstest.executionengine.App"
ForegroundText="light"
BackgroundColor="#0084FF">
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
</VisualElements>
</Application>
<Application Id="vstest.executionengine.x86.App"
Executable="vstest.executionengine.appcontainer.x86.exe"
EntryPoint="vstest.executionengine.x86.App">
<VisualElements
DisplayName="NoUIEntryPoints"
Logo="Images\UnitTestLogo.png"
SmallLogo="Images\UnitTestSmallLogo.png"
Description="vstest.executionengine.x86.App"
ForegroundText="light"
BackgroundColor="#0084FF">
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>

View File

@@ -0,0 +1,28 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UnitTestLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTestLibrary")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
namespace UnitTestLibrary
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{ce2b2c45-2b99-46b1-a29e-128e63fd0933}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTestLibrary</RootNamespace>
<AssemblyName>UnitTestLibrary</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>UnitTestLibrary_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxBundle>Never</AppxBundle>
<AllowCrossPlatformRetargeting>False</AllowCrossPlatformRetargeting>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<AppXPackage>True</AppXPackage>
<AppxPackageIncludePrivateSymbols>true</AppxPackageIncludePrivateSymbols>
</PropertyGroup>
<ItemGroup>
<!--A reference to the entire .Net Framework and Windows SDK are automatically included-->
<SDKReference Include="MSTestFramework, Version=14.0" />
<SDKReference Include="TestPlatform, Version=14.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="UnitTestLibrary_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\UnitTestLogo.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\UnitTestSmallLogo.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\UnitTestSplashScreen.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\UnitTestStoreLogo.scale-100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.