Skip to content

Commit

Permalink
fix crash and new release with fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Aigner committed Jun 5, 2018
1 parent 59385f4 commit f074eb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion HashCalculator/Package.appxmanifest
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="15288RonaldAigner.TPMPCRCalculator" Publisher="CN=F0305663-AD67-4176-BA71-C858A3680A99" Version="1.2.3.0" />
<Identity Name="15288RonaldAigner.TPMPCRCalculator" Publisher="CN=F0305663-AD67-4176-BA71-C858A3680A99" Version="1.3.0.0" />
<mp:PhoneIdentity PhoneProductId="46ab5a51-8729-472c-b2ac-2e7bebf98a66" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>TPM PCR Calculator</DisplayName>
Expand Down
6 changes: 3 additions & 3 deletions HashCalculator/Views/PermutateHash.xaml
Expand Up @@ -74,11 +74,11 @@
<TextBox Grid.Row="3" Grid.Column="0" x:Name="ExpectedResultHash" Margin="20,10,10,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" PlaceholderText="Insert expected result hash" FontFamily="Consolas" />
<Button Grid.Row="3" Grid.Column="1" x:Name="PermutateHashes" Content="Permutate" Margin="10,10,20,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="PermutateHashes_Click" />
<CheckBox Grid.Row="4" Grid.Column="0" x:Name="DontChangeHashOrder" Content="Do not change order of hashes" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource BodyTextBlockStyle}" Margin="20,10" ToolTipService.ToolTip="Select this checkbox to only test different initialization values of a PCR."/>
<Button Grid.Row="4" Grid.Column="1" x:Name="Cancel" Content="Cancel" Margin="20,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Cancel_Click" />
<Button Grid.Row="4" Grid.Column="1" x:Name="Cancel" Content="Cancel" Margin="10,10,20,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="Cancel_Click" />
<TextBlock Grid.Row="5" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="20,10" Text="List of hashes to test with:" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Top" />
<ListView Grid.Row="6" Grid.ColumnSpan="2" x:Name="Hashes" Margin="20,10" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontFamily="Consolas" BorderBrush="{StaticResource ListBoxBorderThemeBrush}"/>
<ListView Grid.Row="6" Grid.ColumnSpan="2" x:Name="Hashes" Margin="20,10" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontFamily="Consolas" />
<TextBlock Grid.Row="7" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="20,10" Text="Order of hashes used to compute expected value" VerticalAlignment="Top" Style="{StaticResource BodyTextBlockStyle}" />
<ListView Grid.Row="8" Grid.ColumnSpan="2" x:Name="ResultHashes" Margin="20,10" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontFamily="Consolas" BorderBrush="{StaticResource ListBoxBorderThemeBrush}"/>
<ListView Grid.Row="8" Grid.ColumnSpan="2" x:Name="ResultHashes" Margin="20,10" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontFamily="Consolas" />
<ProgressBar Grid.Row="8" Grid.Column="2" x:Name="PercentComputed" Margin="20,10" Visibility="Collapsed" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
</Grid>
</StackPanel>
Expand Down
23 changes: 17 additions & 6 deletions HashCalculator/Views/PermutateHash.xaml.cs
Expand Up @@ -140,16 +140,16 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

private void AddHash_Click(object sender, RoutedEventArgs e)
{
string hash = HashToAdd.Text.Trim();
ResultHashes.Items.Clear();
try
{
string hash = HashToAdd.Text.Trim();
Worker.ValidateIsHash((string)ListOfAlgorithms.SelectedItem, hash);
Hashes.Items.Add(hash);
HashToAdd.Text = "";
}
catch (Exception ex)
{
ResultHashes.Items.Clear();
ResultHashes.Items.Add(ex.Message);
}
}
Expand All @@ -165,20 +165,28 @@ private void Reset_Click(object sender, RoutedEventArgs e)
private async void PermutateHashes_Click(object sender, RoutedEventArgs e)
{
bool found = false;
ResultHashes.Items.Clear();
try
{
cts = new CancellationTokenSource();
Worker.ValidateIsHash((string)ListOfAlgorithms.SelectedItem, ExpectedResultHash.Text.Trim());

ResultHashes.Items.Clear();
cts = new CancellationTokenSource();
found = await CheckAndUpdateAsync(cts.Token);
}
catch (OperationCanceledException)
{
ResultHashes.Items.Add("Computation cancelled.");
}
catch (Exception)
catch (Exception ex)
{
ResultHashes.Items.Add("Computation failed.");
if (string.IsNullOrEmpty(ex.Message))
{
ResultHashes.Items.Add("Computation failed.");
}
else
{
ResultHashes.Items.Add(ex.Message);
}
}
finally
{
Expand Down Expand Up @@ -238,6 +246,9 @@ private async Task<List<string>> CheckAndUpdateAsync(string algorithm, int initi

private async Task<bool> CheckAndUpdateAsync(CancellationToken ct)
{
if (Hashes.Items.Count == 0)
return false;

int[] singlePermutation = new int[Hashes.Items.Count];
for (int i = 0; i < Hashes.Items.Count; i++)
singlePermutation[i] = i;
Expand Down

0 comments on commit f074eb8

Please sign in to comment.