Changeset 1488


Ignore:
Timestamp:
May 25, 2010, 7:21:27 PM (12 years ago)
Author:
pretzsch
Message:

MD5 visualization: Fixed and improved presentation of parsed data block integers

Location:
trunk/CrypPlugins/MD5
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/MD5/Algorithm/PresentableMD5.cs

    r970 r1488  
    655655
    656656            // Determine which part of the data to use in this step
     657            int wordIndex = GetWordIndex(newState.RoundIndex, stepIndex);
     658
     659            // Execute the chosen round function
     660            ExecRoundFunction(newState, roundFunction, newState.DataAsIntegers[wordIndex], stepIndex);
     661        }
     662
     663        public static int GetWordIndex(uint roundIndex, uint stepIndex)
     664        {
    657665            uint wordIndex;
    658             switch (newState.RoundIndex)
     666            switch (roundIndex)
    659667            {
    660668                default:
     
    673681            }
    674682            wordIndex %= 16;
    675 
    676             // Execute the chosen round function
    677             ExecRoundFunction(newState, roundFunction, newState.DataAsIntegers[wordIndex], stepIndex);
     683            return (int)wordIndex;
    678684        }
    679685
  • trunk/CrypPlugins/MD5/Algorithm/PresentableMD5State.cs

    r970 r1488  
    119119        }
    120120
     121        /// <summary>
     122        /// Absolute index of the current step, value range 0 - 63
     123        /// </summary>
    121124        public uint AbsoluteStepIndex
    122125        {
     
    127130        }
    128131
     132        /// <summary>
     133        /// Shift constant used for current step
     134        /// </summary>
    129135        public uint ShiftConstant
    130136        {
     
    135141        }
    136142
     143        /// <summary>
     144        /// Addition constant used for current step
     145        /// </summary>
    137146        public uint AdditionConstant
    138147        {
     
    140149            {
    141150                return PresentableMD5.AdditionConstantTable[AbsoluteStepIndex];
     151            }
     152        }
     153
     154        /// <summary>
     155        /// The index of the message part used for current step
     156        /// </summary>
     157        public int MessagePartIndex
     158        {
     159            get
     160            {
     161                return PresentableMD5.GetWordIndex(RoundIndex, AbsoluteStepIndex);
    142162            }
    143163        }
  • trunk/CrypPlugins/MD5/MD5.csproj

    r1487 r1488  
    115115    <Compile Include="Algorithm\PresentableMD5State.cs" />
    116116    <Compile Include="Presentation\Converters\BytesToStringConverter.cs" />
     117    <Compile Include="Presentation\Converters\HighlightIndexToBrushConverter.cs" />
    117118    <Compile Include="Presentation\Converters\MD5StateDescriptionToStringConverter.cs" />
    118119    <Compile Include="Presentation\Converters\MD5StateToUserControlConverter.cs" />
  • trunk/CrypPlugins/MD5/Presentation/Displays/DataIntegerDisplay.xaml

    r936 r1488  
    33        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    44        xmlns:Cryptool_MD5_Presentation_Displays="clr-namespace:Cryptool.MD5.Presentation.Displays"
    5         x:Class="Cryptool.MD5.Presentation.Displays.DataIntegerDisplay"
    6         x:Name="UserControl" Width="624" Height="64">
    7         <UniformGrid Columns="8" Rows="2">
    8                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="0" Value="{Binding .[0]}"/>
    9                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="1" Value="{Binding .[1]}"/>
    10                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="2" Value="{Binding .[2]}"/>
    11                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="3" Value="{Binding .[3]}"/>
    12                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="4" Value="{Binding .[4]}"/>
    13                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="5" Value="{Binding .[5]}"/>
    14                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="6" Value="{Binding .[6]}"/>
    15                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="7" Value="{Binding .[7]}"/>
    16                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="8" Value="{Binding .[8]}"/>
    17                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="9" Value="{Binding .[9]}"/>
    18                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="10" Value="{Binding .[10]}"/>
    19                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="11" Value="{Binding .[11]}"/>
    20                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="12" Value="{Binding .[12]}"/>
    21                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="13" Value="{Binding .[13]}"/>
    22                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="14" Value="{Binding .[14]}"/>
    23                 <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="15" Value="{Binding .[15]}"/>
     5    xmlns:Converters1="clr-namespace:Cryptool.Plugins.MD5.Presentation.Converters" x:Class="Cryptool.MD5.Presentation.Displays.DataIntegerDisplay"
     6        Name="DataIntegerUserControl" Width="624" Height="64">
     7    <UserControl.Resources>
     8        <Converters1:HighlightIndexToBrushConverter x:Key="highlightConverter"/>
     9    </UserControl.Resources>
     10    <UniformGrid Columns="8" Rows="2" DataContext="{Binding DisplayedValues,ElementName=DataIntegerUserControl}">
     11        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="0" Value="{Binding .[0]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=0}"/>
     12        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="1" Value="{Binding .[1]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=1}"/>
     13        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="2" Value="{Binding .[2]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=2}"/>
     14        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="3" Value="{Binding .[3]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=3}"/>
     15        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="4" Value="{Binding .[4]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=4}"/>
     16        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="5" Value="{Binding .[5]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=5}"/>
     17        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="6" Value="{Binding .[6]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=6}"/>
     18        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="7" Value="{Binding .[7]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=7}"/>
     19        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="8" Value="{Binding .[8]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=8}"/>
     20        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="9" Value="{Binding .[9]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=9}"/>
     21        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="10" Value="{Binding .[10]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=10}"/>
     22        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="11" Value="{Binding .[11]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=11}"/>
     23                <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="12" Value="{Binding .[12]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=12}"/>
     24                <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="13" Value="{Binding .[13]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=13}"/>
     25                <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="14" Value="{Binding .[14]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=14}"/>
     26                <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="15" Value="{Binding .[15]}" Background="{Binding HighlightedValue,ElementName=DataIntegerUserControl,Converter={StaticResource highlightConverter},ConverterParameter=15}"/>
    2427        </UniformGrid>
    2528</UserControl>
  • trunk/CrypPlugins/MD5/Presentation/Displays/DataIntegerDisplay.xaml.cs

    r936 r1488  
    11using System;
    22using System.Collections.Generic;
     3using System.Linq;
    34using System.Text;
    45using System.Windows;
     
    1920        public partial class DataIntegerDisplay : UserControl
    2021        {
     22        public int HighlightedValue
     23        {
     24            get { return (int)GetValue(HighlightedValueProperty); }
     25            set { SetValue(HighlightedValueProperty, value); }
     26        }
     27
     28        public UInt32[] DisplayedValues
     29        {
     30            get { return (UInt32[])GetValue(DisplayedValuesProperty); }
     31            set { SetValue(DisplayedValuesProperty, value); }
     32        }
     33
     34        // Using a DependencyProperty as the backing store for DisplayedValues.  This enables animation, styling, binding, etc...
     35        public static readonly DependencyProperty DisplayedValuesProperty =
     36            DependencyProperty.Register("DisplayedValues", typeof(UInt32[]), typeof(DataIntegerDisplay), new UIPropertyMetadata(new UInt32[16]));
     37
     38            // Using a DependencyProperty as the backing store for HighlightedValue.  This enables animation, styling, binding, etc...
     39        public static readonly DependencyProperty HighlightedValueProperty =
     40            DependencyProperty.Register("HighlightedValue", typeof(int), typeof(DataIntegerDisplay), new UIPropertyMetadata(-1));
     41
     42       
    2143                public DataIntegerDisplay()
    2244                {
  • trunk/CrypPlugins/MD5/Presentation/Displays/StateDescriptionDisplay.xaml

    r895 r1488  
    99    <Grid>
    1010        <Label Name="label1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" Content="{Binding CurrentState.State,Converter={StaticResource md5StateDescriptionToStringConverter}}" Background="SteelBlue" Foreground="White" />
    11         <Label Background="SteelBlue" Content="{Binding CurrentStateNumber}" FontSize="20" Foreground="White" HorizontalContentAlignment="Center" Name="label2" VerticalContentAlignment="Center" HorizontalAlignment="Right" Width="70" />
     11        <Label Background="SteelBlue" Content="" FontSize="20" Foreground="White" HorizontalContentAlignment="Center" Name="label2" VerticalContentAlignment="Center" HorizontalAlignment="Right" Width="70" />
    1212    </Grid>
    1313</UserControl>
  • trunk/CrypPlugins/MD5/Presentation/States/RoundStepPresentation.xaml

    r1240 r1488  
    264264        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="AC" Margin="127,165.298,0,186" HorizontalAlignment="Left" Width="117.755" Value="{Binding CurrentState.AdditionConstant}"/>
    265265        <Cryptool_MD5_Presentation_Displays:LabelledIntegerDisplay Caption="SC" Margin="127,0,0,122.646" HorizontalAlignment="Left" Width="117.755" Value="{Binding CurrentState.ShiftConstant}" VerticalAlignment="Bottom" Height="48.702"/>
    266         <Cryptool_MD5_Presentation_Displays:DataIntegerDisplay Margin="12,101,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="298" Height="46"/>
     266        <Cryptool_MD5_Presentation_Displays:DataIntegerDisplay Margin="12,101,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="298" Height="46" DisplayedValues="{Binding CurrentState.DataAsIntegers}" HighlightedValue="{Binding CurrentState.MessagePartIndex}"/>
    267267        <Label Margin="12,165.298,679,186" Name="label1" VerticalContentAlignment="Center">Addition constant</Label>
    268268        <Label Height="48.702" HorizontalAlignment="Left" Margin="12,0,0,119" Name="label2" VerticalAlignment="Bottom" VerticalContentAlignment="Center" Width="109">Shift constant</Label>
  • trunk/CrypPlugins/MD5/Presentation/States/StartingCompressionPresentation.xaml

    r936 r1488  
    2020        <Label Margin="364,180,356,175" x:Name="label1" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Style="{DynamicResource labelStyle}" Content="&gt;&gt;&gt;"/>
    2121        <TextBlock Margin="8,0,8,98.7" x:Name="textBlock2_Copy" TextWrapping="Wrap" Style="{DynamicResource textBlockStyle}" VerticalAlignment="Bottom" Height="35" ><Run Text="We also split our "/><Run Text="512 bit "/><Run Text="data block into 16 "/><Run Text="little-endian "/><Run Text="integers"/><Run Text=", each "/><Run Text="32 bit:"/></TextBlock>
    22         <displays:DataIntegerDisplay Margin="8,0,8,8" VerticalAlignment="Bottom" Height="86.7" DataContext="{Binding NextState.DataAsIntegers}"/>
     22        <displays:DataIntegerDisplay Margin="8,0,8,8" VerticalAlignment="Bottom" Height="86.7" DisplayedValues="{Binding NextState.DataAsIntegers}"/>
    2323    </Grid>
    2424</UserControl>
Note: See TracChangeset for help on using the changeset viewer.