Changeset 8136


Ignore:
Timestamp:
May 30, 2019, 5:49:04 PM (3 years ago)
Author:
Christian Bender
Message:

ToyCiphers: updated implementation, changes to the UI, changes to the description, added documentation

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginsExperimental/ToyCiphers/Properties/Resources.Designer.cs

    r8128 r8136  
    289289       
    290290        /// <summary>
    291         ///   Sucht eine lokalisierte Zeichenfolge, die The SBox substitutes fixed input bits for other output bits. The following table describes the SBox, where the first line represents the decimal representation of the input bits and the second line represents the decimal representation of the output bits. ähnelt.
     291        ///   Sucht eine lokalisierte Zeichenfolge, die The SBox substitutes fixed input bits for other output bits. The following table describes the SBox, where the first line represents the value of the input bits and the second line represents the output bits. ähnelt.
    292292        /// </summary>
    293293        internal static string DescSBox {
     
    298298       
    299299        /// <summary>
    300         ///   Sucht eine lokalisierte Zeichenfolge, die Table of the Permutation: ähnelt.
     300        ///   Sucht eine lokalisierte Zeichenfolge, die Table of the permutation: ähnelt.
    301301        /// </summary>
    302302        internal static string HeaderPermutation {
     
    352352       
    353353        /// <summary>
    354         ///   Sucht eine lokalisierte Zeichenfolge, die Input for a messages to be encrypted ähnelt.
     354        ///   Sucht eine lokalisierte Zeichenfolge, die The messages entered are too small or too large. Please check the requirements of this cipher. ähnelt.
     355        /// </summary>
     356        internal static string MessageError {
     357            get {
     358                return ResourceManager.GetString("MessageError", resourceCulture);
     359            }
     360        }
     361       
     362        /// <summary>
     363        ///   Sucht eine lokalisierte Zeichenfolge, die Input for messages to be encrypted ähnelt.
    355364        /// </summary>
    356365        internal static string MessageInput {
     
    397406       
    398407        /// <summary>
    399         ///   Sucht eine lokalisierte Zeichenfolge, die DCA ToyCiphers ähnelt.
     408        ///   Sucht eine lokalisierte Zeichenfolge, die DCA ToyCipher ähnelt.
    400409        /// </summary>
    401410        internal static string PluginCaption {
     
    406415       
    407416        /// <summary>
    408         ///   Sucht eine lokalisierte Zeichenfolge, die The ToyCiphers component contains various algorithms for encrypting information. The algorithms are very simple and short to demonstrate certain things. ähnelt.
     417        ///   Sucht eine lokalisierte Zeichenfolge, die The ToyCipher component contains various algorithms for text encryption. The algorithms are very simple and short to demonstrate cryptographic principles or cryptoanalytical methods. ähnelt.
    409418        /// </summary>
    410419        internal static string PluginTooltip {
  • trunk/CrypPluginsExperimental/ToyCiphers/Properties/Resources.de.resx

    r8128 r8136  
    191191  </data>
    192192  <data name="DescPermutation" xml:space="preserve">
    193     <value>Die Permutation vertauscht die feste Position i eines Eingabebit auf eine Position j in der Ausgabe. Die folgende Tabelle beschreibt die Permutation, wobei die erste Zeile die dezimale Position eines Bits in der Eingabe darstellt und die zweite Zeile die Position des entsprechenden Bits in der Ausgabe.</value>
     193    <value>Die Permutation vertauscht die feste Position i eines Eingabebits auf eine Position j in der Ausgabe. Die folgende Tabelle beschreibt die Permutation, wobei die erste Zeile die Position eines Bits in der Eingabe darstellt und die zweite Zeile die Position des entsprechenden Bits in der Ausgabe.</value>
    194194  </data>
    195195  <data name="DescSBox" xml:space="preserve">
    196     <value>Die SBox substituiert feste Eingabebits auf andere Ausgabebits. Die folgende Tabelle beschreibt die SBox, wobei die erste Zeile die dezimale Repräsentation der Eingabebits darstellt und die zweite Zeile die dezimale Repräsentation der Ausgabebits. </value>
     196    <value>Die SBox substituiert feste Eingabebits auf andere Ausgabebits. Die folgende Tabelle beschreibt die SBox, wobei die erste Zeile den Wert der Eingabebits und die zweite Zeile die Ausgabebits darstellt. </value>
    197197  </data>
    198198  <data name="HeaderPermutation" xml:space="preserve">
     
    214214    <value>An diesem Eingang liegt der Schlüssel an, mit dem die Nachricht verschlüsselt wird</value>
    215215  </data>
     216  <data name="MessageError" xml:space="preserve">
     217    <value>Die eingegebenen Nachrichten sind zu klein oder groß. Bitte überprüfen Sie die Anforderungen dieser Chiffre.</value>
     218  </data>
    216219  <data name="MessageInput" xml:space="preserve">
    217220    <value>Eingang für zu verschlüsselnde Nachrichten</value>
     
    224227  </data>
    225228  <data name="PluginCaption" xml:space="preserve">
    226     <value>DCA ToyCiphers</value>
     229    <value>DCA ToyCipher</value>
    227230  </data>
    228231  <data name="PluginTooltip" xml:space="preserve">
    229     <value>Die ToyCiphers-Komponente enthält verschiedene Algorithmen zur Verschlüsselung von Informationen. Die Algorithmen sind sehr einfach und kurz, um an ihnen bestimmte Dinge demonstrieren zu können.</value>
     232    <value>Die ToyCipher-Komponente enthält verschiedene Algorithmen zur Verschlüsselung von Texten. Die Algorithmen sind sehr einfach und kurz, um an ihnen beispielsweise kryptographische Prinzipien oder kryptoanalytische Verfahren demonstrieren zu können.</value>
    230233  </data>
    231234  <data name="SingleMessageOutput" xml:space="preserve">
  • trunk/CrypPluginsExperimental/ToyCiphers/Properties/Resources.resx

    r8128 r8136  
    196196  </data>
    197197  <data name="DescSBox" xml:space="preserve">
    198     <value>The SBox substitutes fixed input bits for other output bits. The following table describes the SBox, where the first line represents the decimal representation of the input bits and the second line represents the decimal representation of the output bits.</value>
     198    <value>The SBox substitutes fixed input bits for other output bits. The following table describes the SBox, where the first line represents the value of the input bits and the second line represents the output bits.</value>
    199199  </data>
    200200  <data name="HeaderPermutation" xml:space="preserve">
    201     <value>Table of the Permutation:</value>
     201    <value>Table of the permutation:</value>
    202202  </data>
    203203  <data name="HeaderSBox" xml:space="preserve">
     
    216216    <value>This input contains the key with which the message is encrypted</value>
    217217  </data>
     218  <data name="MessageError" xml:space="preserve">
     219    <value>The messages entered are too small or too large. Please check the requirements of this cipher.</value>
     220  </data>
    218221  <data name="MessageInput" xml:space="preserve">
    219     <value>Input for a messages to be encrypted</value>
     222    <value>Input for messages to be encrypted</value>
    220223  </data>
    221224  <data name="MessageInputTooltip" xml:space="preserve">
     
    232235  </data>
    233236  <data name="PluginCaption" xml:space="preserve">
    234     <value>DCA ToyCiphers</value>
     237    <value>DCA ToyCipher</value>
    235238  </data>
    236239  <data name="PluginTooltip" xml:space="preserve">
    237     <value>The ToyCiphers component contains various algorithms for encrypting information. The algorithms are very simple and short to demonstrate certain things.</value>
     240    <value>The ToyCipher component contains various algorithms for text encryption. The algorithms are very simple and short to demonstrate cryptographic principles or cryptoanalytical methods.</value>
    238241  </data>
    239242  <data name="TablePermutationInput" xml:space="preserve">
  • trunk/CrypPluginsExperimental/ToyCiphers/ToyCiphers.cs

    r8128 r8136  
    11/*
    2    Copyright 2011 CrypTool 2 Team <ct2contact@cryptool.org>
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
    33
    44   Licensed under the Apache License, Version 2.0 (the "License");
     
    140140        public void Execute()
    141141        {
    142             // HOWTO: Use this to show the progress of a plugin algorithm execution in the editor.
    143142            ProgressChanged(0, 1);
    144143
     
    148147                //create encryption object for the cipher
    149148                _currentCipher = new Cipher1();
    150                 _currentCipher.SetKeys(readSubkeys(Cipher1Configuration.KEYNUM));
     149                int[] subKeys = readSubkeys(Cipher1Configuration.KEYNUM);
     150                if (subKeys != null)
     151                {
     152                    _currentCipher.SetKeys(subKeys);
     153                    _activePresentation.Dispatcher.Invoke(DispatcherPriority.Send, (SendOrPostCallback)delegate
     154                    {
     155                        ((Cipher1Pres)_activePresentation.MainGrid.Children[0]).Keys = subKeys;
     156                    }, null);
     157                }
    151158            }
    152159            else if (settings.CurrentAlgorithm == Algorithms.Cipher2)
     
    154161                //create encryption object for the cipher
    155162                _currentCipher = new Cipher2();
    156                 _currentCipher.SetKeys(readSubkeys(Cipher2Configuration.KEYNUM));
     163                int[] subKeys = readSubkeys(Cipher2Configuration.KEYNUM);
     164                if (subKeys != null)
     165                {
     166                    _currentCipher.SetKeys(subKeys);
     167                    _activePresentation.Dispatcher.Invoke(DispatcherPriority.Send, (SendOrPostCallback)delegate
     168                    {
     169                        ((Cipher2Pres)_activePresentation.MainGrid.Children[0]).Keys = subKeys;
     170                    }, null);
     171                }
    157172            }
    158173            else if (settings.CurrentAlgorithm == Algorithms.Cipher3)
     
    160175                //create encryption object for the cipher
    161176                _currentCipher = new Cipher3();
    162                 _currentCipher.SetKeys(readSubkeys(Cipher3Configuration.KEYNUM));
     177                int[] subKeys = readSubkeys(Cipher3Configuration.KEYNUM);
     178                if (subKeys != null)
     179                {
     180                    _currentCipher.SetKeys(subKeys);
     181                    _activePresentation.Dispatcher.Invoke(DispatcherPriority.Send, (SendOrPostCallback)delegate
     182                    {
     183                        ((Cipher3Pres)_activePresentation.MainGrid.Children[0]).Keys = subKeys;
     184                    }, null);
     185                }
    163186            }
    164187            else if (settings.CurrentAlgorithm == Algorithms.Cipher4)
     
    166189                //create encryption object for the cipher
    167190                _currentCipher = new Cipher4();
    168                 _currentCipher.SetKeys(readSubkeys(Cipher4Configuration.KEYNUM));
     191                int[] subKeys = readSubkeys(Cipher4Configuration.KEYNUM);
     192                if (subKeys != null)
     193                {
     194                    _currentCipher.SetKeys(subKeys);
     195                    _activePresentation.Dispatcher.Invoke(DispatcherPriority.Send, (SendOrPostCallback)delegate
     196                    {
     197                        ((Cipher4Pres)_activePresentation.MainGrid.Children[0]).Keys = subKeys;
     198                    }, null);
     199                }
    169200            }
    170201
     
    176207            }
    177208
    178             List<int> messages = new List<int>();
    179             var cryptedMessageList = new List<int>();
    180 
     209            List<int> messageList = new List<int>();
     210            List<UInt16> encryptedMessageList = new List<UInt16>();
     211
     212            //Read all messages
    181213            using (CStreamReader reader = _messageInput.CreateReader())
    182214            {
    183                 byte[] inputBlock = new byte[4];
     215                if ((reader.Length % 2) != 0)
     216                {
     217                    GuiLogMessage(Resources.MessageError, NotificationLevel.Error);
     218                    ProgressChanged(1, 1);
     219                    return;
     220                }
     221
     222                byte[] inputBlock = new byte[2];
    184223                int message;
    185224                int readcount = 0;
     
    189228
    190229                }
    191                 message = BitConverter.ToInt32(inputBlock, 0);
    192                 messages.Add(message);
    193             }
    194 
    195             foreach (var message in messages)
    196             {
    197                 cryptedMessageList.Add(message);
    198             }
    199 
    200 
    201 
     230                message = BitConverter.ToUInt16(inputBlock, 0);
     231                messageList.Add(message);
     232            }
     233
     234            //encrypt all messages
     235            foreach (var message in messageList)
     236            {
     237                int encryptedMessage = _currentCipher.EncryptBlock(message);
     238                encryptedMessageList.Add(Convert.ToUInt16(encryptedMessage));
     239            }
    202240           
    203 
     241            //write all messages to the output
    204242            using (CStreamWriter writer = new CStreamWriter())
    205243            {
    206                 foreach (var cryptedMessage in cryptedMessageList)
    207                 {
    208                     byte[] outputblock = BitConverter.GetBytes(cryptedMessage);
    209                     writer.Write(outputblock, 0, outputblock.Length);
     244                foreach (var enctyptedMessage in encryptedMessageList)
     245                {
     246                    byte[] outputBlock = BitConverter.GetBytes(enctyptedMessage);
     247                    writer.Write(outputBlock, 0, outputBlock.Length);
    210248                }
    211249
     
    214252            }
    215253
    216             // HOWTO: Make sure the progress bar is at maximum when your Execute() finished successfully.
    217254            ProgressChanged(1, 1);
    218255        }
     
    288325            int[] keys = new int[keycount];
    289326
    290             if (KeyInput.Length < (keycount * 2))
    291             {
    292                 _subkeysSatisfied = false;
    293             }
    294 
    295             for (int i = 0; i < (KeyInput.Length / 2); i++)
    296             {
    297                 byte[] key = new byte[4];
    298                 for (int j = 0; j < 2; j++)
    299                 {
    300                     key[j] = KeyInput[(i * 2) + j];
    301                 }
    302                 keys[i] = BitConverter.ToInt32(key, 0);
     327            if (settings.CurrentAlgorithm == Algorithms.Cipher1 || settings.CurrentAlgorithm == Algorithms.Cipher2 ||
     328                settings.CurrentAlgorithm == Algorithms.Cipher2)
     329            {
     330                if (KeyInput.Length != (keycount * 2))
     331                {
     332                    _subkeysSatisfied = false;
     333                    return null;
     334                }
     335
     336                for (int i = 0; i < (KeyInput.Length / 2); i++)
     337                {
     338                    byte[] key = new byte[2];
     339                    for (int j = 0; j < 2; j++)
     340                    {
     341                        key[1 - j] = KeyInput[(i * 2) + j];
     342                    }
     343                    keys[i] = BitConverter.ToUInt16(key, 0);
     344                }
     345
     346            }
     347            else
     348            {
     349                if (KeyInput.Length != keycount)
     350                {
     351                    _subkeysSatisfied = false;
     352                    return null;
     353                }
     354
     355                for (int i = 0; i < (KeyInput.Length); i++)
     356                {
     357                    byte[] key = new byte[2];
     358                    key[0] = KeyInput[i];
     359 
     360                    keys[i] = BitConverter.ToUInt16(key, 0);
     361                }
    303362            }
    304363
  • trunk/CrypPluginsExperimental/ToyCiphers/ToyCiphersSettings.cs

    r8126 r8136  
    11/*
    2    Copyright 2011 CrypTool 2 Team <ct2contact@cryptool.org>
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
    33
    44   Licensed under the Apache License, Version 2.0 (the "License");
     
    1414   limitations under the License.
    1515*/
     16
    1617using System;
    1718using System.ComponentModel;
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher1Pres.xaml

    r8128 r8136  
    77             xmlns:controls="clr-namespace:ToyCiphers.UI.Controls"
    88             mc:Ignorable="d"
    9              d:DesignHeight="415" d:DesignWidth="400">
     9             d:DesignHeight="415" d:DesignWidth="540">
    1010    <Grid>
    1111        <Grid.ColumnDefinitions>
     
    1616            <RowDefinition Height="40"></RowDefinition>
    1717        </Grid.RowDefinitions>
    18         <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Hidden">
    19             <Grid Height="390" Width="400">
    20                 <Label Name="InputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Content="{Loc Cipher1LblInputBlock}" HorizontalAlignment="Center"/>
     18        <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Visible">
     19            <Grid Height="390" Width="540">
     20                <Label Name="InputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Content="{Loc Cipher1LblInputBlock}" Margin="120,0,0,0"/>
    2121                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,0,0,0"></controls:_16BitKeyRound>
    22                 <Label FontFamily="Courier New" FontSize="20" Content="K0" HorizontalAlignment="Right" Margin="0,85,10,0"></Label>
     22                <Label FontFamily="Courier New" FontSize="20" Content="K0" HorizontalAlignment="Right" Margin="0,75,145,0"></Label>
     23                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK0, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,95,20,0"></Label>
    2324                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,170,0,0"></controls:_4BitSBox>
    2425                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,170,0,0"></controls:_4BitSBox>
     
    2627                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="290,170,0,0"></controls:_4BitSBox>
    2728                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,185,0,0"></controls:_16BitKeyRound>
    28                 <Label FontFamily="Courier New" FontSize="20" Content="K1" HorizontalAlignment="Right" Margin="0,270,10,0"></Label>
    29                 <Label Name="OutputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Margin="0,350,0,0" Content="{Loc Cipher1LblOutputBlock}" HorizontalAlignment="Center"/>
     29                <Label FontFamily="Courier New" FontSize="20" Content="K1" HorizontalAlignment="Right" Margin="0,260,145,0"></Label>
     30                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK1, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,280,20,0"></Label>
     31                <Label Name="OutputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Margin="125,350,0,0" Content="{Loc Cipher1LblOutputBlock}"/>
    3032            </Grid>
    3133        </Viewbox>
    32         <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Visible">
     34        <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Hidden">
    3335            <Grid Visibility="Visible">
    3436                <Grid.RowDefinitions>
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher1Pres.xaml.cs

    r8128 r8136  
    1 using System.Collections.ObjectModel;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
     17using System;
     18using System.Collections.ObjectModel;
    219using System.ComponentModel;
    320using System.Runtime.CompilerServices;
     
    1431    {
    1532        private ObservableCollection<TableMapping> sboxData;
     33        private int[] _keys;
     34        private string _currentK0;
     35        private string _currentK1;
    1636
    1737        /// <summary>
     
    6282            });
    6383
     84            CurrentK0 = "0000000000000000";
     85            CurrentK0 = CurrentK0.Insert(8, " ");
     86            CurrentK1 = "0000000000000000";
     87            CurrentK1 = CurrentK1.Insert(8, " ");
     88
    6489            DataContext = this;
    6590            InitializeComponent();
     91        }
     92
     93        /// <summary>
     94        /// Property for the keys
     95        /// </summary>
     96        public int[] Keys
     97        {
     98            get { return _keys; }
     99            set
     100            {
     101                _keys = value;
     102                UInt16 keyTemp = Convert.ToUInt16(_keys[0]);
     103
     104                _currentK0 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     105                CurrentK0 = _currentK0.Insert(8, " ");
     106
     107                keyTemp = Convert.ToUInt16(_keys[1]);
     108                _currentK1 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     109                CurrentK1 = _currentK1.Insert(8, " ");
     110
     111                OnPropertyChanged();
     112            }
    66113        }
    67114
     
    75122            {
    76123                sboxData = value;
     124                OnPropertyChanged();
     125            }
     126        }
     127
     128        /// <summary>
     129        /// Property for binding K0
     130        /// </summary>
     131        public string CurrentK0
     132        {
     133            get { return _currentK0; }
     134            set
     135            {
     136                _currentK0 = value;
     137                OnPropertyChanged();
     138            }
     139        }
     140
     141        /// <summary>
     142        /// Property for binding K1
     143        /// </summary>
     144        public string CurrentK1
     145        {
     146            get { return _currentK1; }
     147            set
     148            {
     149                _currentK1 = value;
    77150                OnPropertyChanged();
    78151            }
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher2Pres.xaml

    r8128 r8136  
    1616            <RowDefinition Height="40"></RowDefinition>
    1717        </Grid.RowDefinitions>
    18         <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Hidden">
     18        <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Visible">
    1919            <Grid Height="910" Width="400" HorizontalAlignment="Center">
    2020                <Label Name="InputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Content="{Loc Cipher2LblInputBlock}" HorizontalAlignment="Center"/>
    2121                <!-- Round 1 -->
    2222                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,0,0,0"></controls:_16BitKeyRound>
    23                 <Label FontFamily="Courier New" FontSize="20" Content="K0" HorizontalAlignment="Right" Margin="0,85,10,0"></Label>
     23                <Label FontFamily="Courier New" FontSize="20" Content="K0" HorizontalAlignment="Right" Margin="0,75,10,0"></Label>
     24                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK0, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,95,-115,0"></Label>
    2425                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,170,0,0"></controls:_4BitSBox>
    2526                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,170,0,0"></controls:_4BitSBox>
     
    3031                <!-- Round 2 -->
    3132                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,240,0,0"></controls:_16BitKeyRound>
    32                 <Label FontFamily="Courier New" FontSize="20" Content="K1" HorizontalAlignment="Right" Margin="0,325,10,0"></Label>
     33                <Label FontFamily="Courier New" FontSize="20" Content="K1" HorizontalAlignment="Right" Margin="0,315,10,0"></Label>
     34                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK1, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,335,-115,0"></Label>
    3335                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,410,0,0"></controls:_4BitSBox>
    3436                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,410,0,0"></controls:_4BitSBox>
     
    3941                <!-- Round 3 -->
    4042                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,490,0,0"></controls:_16BitKeyRound>
    41                 <Label FontFamily="Courier New" FontSize="20" Content="K2" HorizontalAlignment="Right" Margin="0,575,10,0"></Label>
     43                <Label FontFamily="Courier New" FontSize="20" Content="K2" HorizontalAlignment="Right" Margin="0,565,10,0"></Label>
     44                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK2, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,585,-115,0"></Label>
    4245                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,660,0,0"></controls:_4BitSBox>
    4346                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,660,0,0"></controls:_4BitSBox>
     
    4548                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="290,660,0,0"></controls:_4BitSBox>
    4649                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,675,0,0"></controls:_16BitKeyRound>
    47                 <Label FontFamily="Courier New" FontSize="20" Content="K3" HorizontalAlignment="Right" Margin="0,760,10,0"></Label>
     50                <Label FontFamily="Courier New" FontSize="20" Content="K3" HorizontalAlignment="Right" Margin="0,750,10,0"></Label>
     51                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK3, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,770,-115,0"></Label>
    4852                <!-- /Round 3 -->
    4953                <Label Name="OutputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Content="{Loc Cipher2LblOutputBlock}" HorizontalAlignment="Center" Margin="0,840,0,0"/>
    5054            </Grid>
    5155        </Viewbox>
    52         <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Visible">
     56        <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Hidden">
    5357            <Grid Visibility="Visible">
    5458                <Grid.RowDefinitions>
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher2Pres.xaml.cs

    r8128 r8136  
    1 using System;
    2 using System.Collections.Generic;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
     17using System;
    318using System.Collections.ObjectModel;
    419using System.ComponentModel;
    5 using System.Linq;
    620using System.Runtime.CompilerServices;
    7 using System.Text;
    8 using System.Threading.Tasks;
    921using System.Windows;
    1022using System.Windows.Controls;
    11 using System.Windows.Data;
    12 using System.Windows.Documents;
    13 using System.Windows.Input;
    14 using System.Windows.Media;
    15 using System.Windows.Media.Imaging;
    16 using System.Windows.Navigation;
    17 using System.Windows.Shapes;
    1823
    1924namespace ToyCiphers.UI
     
    2732        private ObservableCollection<TableMapping> sboxData;
    2833        private ObservableCollection<TableMapping> permutationData;
     34        private int[] _keys;
     35        private string _currentK0;
     36        private string _currentK1;
     37        private string _currentK2;
     38        private string _currentK3;
    2939
    3040        /// <summary>
     
    117127            });
    118128
     129            CurrentK0 = "0000000000000000";
     130            CurrentK0 = CurrentK0.Insert(8, " ");
     131            CurrentK1 = "0000000000000000";
     132            CurrentK1 = CurrentK1.Insert(8, " ");
     133            CurrentK2 = "0000000000000000";
     134            CurrentK2 = CurrentK2.Insert(8, " ");
     135            CurrentK3 = "0000000000000000";
     136            CurrentK3 = CurrentK3.Insert(8, " ");
     137
    119138            DataContext = this;
    120139            InitializeComponent();
     140        }
     141
     142        /// <summary>
     143        /// Property for binding keys
     144        /// </summary>
     145        public int[] Keys
     146        {
     147            get { return _keys; }
     148            set
     149            {
     150                _keys = value;
     151                UInt16 keyTemp = Convert.ToUInt16(_keys[0]);
     152
     153                _currentK0 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     154                CurrentK0 = _currentK0.Insert(8, " ");
     155
     156                keyTemp = Convert.ToUInt16(_keys[1]);
     157                _currentK1 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     158                CurrentK1 = _currentK1.Insert(8, " ");
     159
     160                keyTemp = Convert.ToUInt16(_keys[2]);
     161                _currentK2 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     162                CurrentK2 = _currentK2.Insert(8, " ");
     163
     164                keyTemp = Convert.ToUInt16(_keys[3]);
     165                _currentK3 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     166                CurrentK3 = _currentK3.Insert(8, " ");
     167
     168                OnPropertyChanged();
     169            }
     170        }
     171
     172        /// <summary>
     173        /// Property for binding K0
     174        /// </summary>
     175        public string CurrentK0
     176        {
     177            get { return _currentK0; }
     178            set
     179            {
     180                _currentK0 = value;
     181                OnPropertyChanged();
     182            }
     183        }
     184
     185        /// <summary>
     186        /// Property for binding K1
     187        /// </summary>
     188        public string CurrentK1
     189        {
     190            get { return _currentK1; }
     191            set
     192            {
     193                _currentK1 = value;
     194                OnPropertyChanged();
     195            }
     196        }
     197
     198        /// <summary>
     199        /// Property for binding K2
     200        /// </summary>
     201        public string CurrentK2
     202        {
     203            get { return _currentK2; }
     204            set
     205            {
     206                _currentK2 = value;
     207                OnPropertyChanged();
     208            }
     209        }
     210
     211        /// <summary>
     212        /// Property for binding K3
     213        /// </summary>
     214        public string CurrentK3
     215        {
     216            get { return _currentK3; }
     217            set
     218            {
     219                _currentK3 = value;
     220                OnPropertyChanged();
     221            }
    121222        }
    122223
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher3Pres.xaml

    r8128 r8136  
    1616            <RowDefinition Height="40"></RowDefinition>
    1717        </Grid.RowDefinitions>
    18         <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Hidden">
     18        <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Visible">
    1919            <Grid Height="1400" Width="400" HorizontalAlignment="Center">
    2020                <Label Name="InputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Content="{Loc Cipher3LblInputBlock}" HorizontalAlignment="Center"/>
    2121                <!-- Round 1 -->
    2222                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,0,0,0"></controls:_16BitKeyRound>
    23                 <Label FontFamily="Courier New" FontSize="20" Content="K0" HorizontalAlignment="Right" Margin="0,85,10,0"></Label>
     23                <Label FontFamily="Courier New" FontSize="20" Content="K0" HorizontalAlignment="Right" Margin="0,75,10,0"></Label>
     24                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK0, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,95,-118,0"></Label>
    2425                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,170,0,0"></controls:_4BitSBox>
    2526                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,170,0,0"></controls:_4BitSBox>
     
    3031                <!-- Round 2 -->
    3132                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,240,0,0"></controls:_16BitKeyRound>
    32                 <Label FontFamily="Courier New" FontSize="20" Content="K1" HorizontalAlignment="Right" Margin="0,325,10,0"></Label>
     33                <Label FontFamily="Courier New" FontSize="20" Content="K1" HorizontalAlignment="Right" Margin="0,315,10,0"></Label>
     34                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK1, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,335,-118,0"></Label>
    3335                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,410,0,0"></controls:_4BitSBox>
    3436                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,410,0,0"></controls:_4BitSBox>
     
    3941                <!-- Round 3 -->
    4042                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,490,0,0"></controls:_16BitKeyRound>
    41                 <Label FontFamily="Courier New" FontSize="20" Content="K2" HorizontalAlignment="Right" Margin="0,575,10,0"></Label>
     43                <Label FontFamily="Courier New" FontSize="20" Content="K2" HorizontalAlignment="Right" Margin="0,565,10,0"></Label>
     44                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK2, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,585,-118,0"></Label>
    4245                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,660,0,0"></controls:_4BitSBox>
    4346                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,660,0,0"></controls:_4BitSBox>
     
    4851                <!-- Round 4 -->
    4952                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,740,0,0"></controls:_16BitKeyRound>
    50                 <Label FontFamily="Courier New" FontSize="20" Content="K3" HorizontalAlignment="Right" Margin="0,825,10,0"></Label>
     53                <Label FontFamily="Courier New" FontSize="20" Content="K3" HorizontalAlignment="Right" Margin="0,815,10,0"></Label>
     54                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK3, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,835,-118,0"></Label>
    5155                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,910,0,0"></controls:_4BitSBox>
    5256                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,910,0,0"></controls:_4BitSBox>
     
    5761                <!-- Round 5 -->
    5862                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,990,0,0"></controls:_16BitKeyRound>
    59                 <Label FontFamily="Courier New" FontSize="20" Content="K4" HorizontalAlignment="Right" Margin="0,1075,10,0"></Label>
     63                <Label FontFamily="Courier New" FontSize="20" Content="K4" HorizontalAlignment="Right" Margin="0,1065,10,0"></Label>
     64                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK4, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,1085,-118,0"></Label>
    6065                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="50,1160,0,0"></controls:_4BitSBox>
    6166                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="130,1160,0,0"></controls:_4BitSBox>
     
    6368                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="290,1160,0,0"></controls:_4BitSBox>
    6469                <controls:_16BitKeyRound Grid.Row="0" Grid.Column="0" Margin="50,1175,0,0"></controls:_16BitKeyRound>
    65                 <Label FontFamily="Courier New" FontSize="20" Content="K5" HorizontalAlignment="Right" Margin="0,1260,10,0"></Label>
     70                <Label FontFamily="Courier New" FontSize="20" Content="K5" HorizontalAlignment="Right" Margin="0,1250,10,0"></Label>
     71                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK5, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,1270,-118,0"></Label>
    6672                <Label FontFamily="Courier New" FontSize="20" FontWeight="Bold" Margin="0,1340,0,0" Content="{Loc Cipher3LblOutputBlock}" HorizontalAlignment="Center"/>
    6773                <!-- /Round 5 -->
    6874            </Grid>
    6975        </Viewbox>
    70         <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Visible">
     76        <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Hidden">
    7177            <Grid Visibility="Visible">
    7278                <Grid.RowDefinitions>
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher3Pres.xaml.cs

    r8128 r8136  
    1 using System;
    2 using System.Collections.Generic;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
     17using System;
    318using System.Collections.ObjectModel;
    419using System.ComponentModel;
    5 using System.Linq;
    620using System.Runtime.CompilerServices;
    7 using System.Text;
    8 using System.Threading.Tasks;
    921using System.Windows;
    1022using System.Windows.Controls;
    11 using System.Windows.Data;
    12 using System.Windows.Documents;
    13 using System.Windows.Input;
    14 using System.Windows.Media;
    15 using System.Windows.Media.Imaging;
    16 using System.Windows.Navigation;
    17 using System.Windows.Shapes;
    1823
    1924namespace ToyCiphers.UI
     
    2732        private ObservableCollection<TableMapping> sboxData;
    2833        private ObservableCollection<TableMapping> permutationData;
     34        private int[] _keys;
     35        private string _currentK0;
     36        private string _currentK1;
     37        private string _currentK2;
     38        private string _currentK3;
     39        private string _currentK4;
     40        private string _currentK5;
    2941
    3042        /// <summary>
     
    3648            sboxData.Add(new TableMapping()
    3749            {
    38                 Direction = ToyCiphers.Properties.Resources.Input,
     50                Direction = Properties.Resources.Input,
    3951                ZeroOutput = 0,
    4052                OneOutput = 1,
     
    5668            sboxData.Add(new TableMapping()
    5769            {
    58                 Direction = ToyCiphers.Properties.Resources.Output,
     70                Direction = Properties.Resources.Output,
    5971                ZeroOutput = 6,
    6072                OneOutput = 4,
     
    7890            permutationData.Add(new TableMapping()
    7991            {
    80                 Direction = ToyCiphers.Properties.Resources.TablePermutationInput,
     92                Direction = Properties.Resources.TablePermutationInput,
    8193                ZeroOutput = 0,
    8294                OneOutput = 1,
     
    98110            permutationData.Add(new TableMapping()
    99111            {
    100                 Direction = ToyCiphers.Properties.Resources.TablePermutationOutput,
     112                Direction = Properties.Resources.TablePermutationOutput,
    101113                ZeroOutput = 0,
    102114                OneOutput = 4,
     
    117129            });
    118130
     131
     132
    119133            DataContext = this;
    120134            InitializeComponent();
     
    122136
    123137        /// <summary>
     138        /// Property for the keys
     139        /// </summary>
     140        public int[] Keys
     141        {
     142            get { return _keys; }
     143            set
     144            {
     145                _keys = value;
     146                UInt16 keyTemp = Convert.ToUInt16(_keys[0]);
     147
     148                _currentK0 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     149                CurrentK0 = _currentK0.Insert(8, " ");
     150
     151                keyTemp = Convert.ToUInt16(_keys[1]);
     152                _currentK1 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     153                CurrentK1 = _currentK1.Insert(8, " ");
     154
     155                keyTemp = Convert.ToUInt16(_keys[2]);
     156                _currentK2 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     157                CurrentK2 = _currentK2.Insert(8, " ");
     158
     159                keyTemp = Convert.ToUInt16(_keys[3]);
     160                _currentK3 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     161                CurrentK3 = _currentK3.Insert(8, " ");
     162
     163                keyTemp = Convert.ToUInt16(_keys[4]);
     164                _currentK4 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     165                CurrentK4 = _currentK4.Insert(8, " ");
     166
     167                keyTemp = Convert.ToUInt16(_keys[5]);
     168                _currentK5 = Convert.ToString(keyTemp, 2).PadLeft(16, '0');
     169                CurrentK5 = _currentK5.Insert(8, " ");
     170
     171                OnPropertyChanged();
     172            }
     173        }
     174
     175        /// <summary>
     176        /// Property for binding K0
     177        /// </summary>
     178        public string CurrentK0
     179        {
     180            get { return _currentK0; }
     181            set
     182            {
     183                _currentK0 = value;
     184                OnPropertyChanged();
     185            }
     186        }
     187
     188        /// <summary>
     189        /// Property for binding K1
     190        /// </summary>
     191        public string CurrentK1
     192        {
     193            get { return _currentK1; }
     194            set
     195            {
     196                _currentK1 = value;
     197                OnPropertyChanged();
     198            }
     199        }
     200
     201        /// <summary>
     202        /// Property for binding K2
     203        /// </summary>
     204        public string CurrentK2
     205        {
     206            get { return _currentK2; }
     207            set
     208            {
     209                _currentK2 = value;
     210                OnPropertyChanged();
     211            }
     212        }
     213
     214        /// <summary>
     215        /// Property for binding K3
     216        /// </summary>
     217        public string CurrentK3
     218        {
     219            get { return _currentK3; }
     220            set
     221            {
     222                _currentK3 = value;
     223                OnPropertyChanged();
     224            }
     225        }
     226
     227        /// <summary>
     228        /// Property for binding K4
     229        /// </summary>
     230        public string CurrentK4
     231        {
     232            get { return _currentK4; }
     233            set
     234            {
     235                _currentK4 = value;
     236                OnPropertyChanged();
     237            }
     238        }
     239
     240        /// <summary>
     241        /// Property for binding K5
     242        /// </summary>
     243        public string CurrentK5
     244        {
     245            get { return _currentK5; }
     246            set
     247            {
     248                _currentK5 = value;
     249                OnPropertyChanged();
     250            }
     251        }
     252
     253        /// <summary>
    124254        /// Property for binding the sboxData
    125255        /// </summary>
     
    130260            {
    131261                sboxData = value;
    132                 OnPropertyChanged("SBoxData");
     262                OnPropertyChanged();
    133263            }
    134264        }
     
    143273            {
    144274                permutationData = value;
    145                 OnPropertyChanged("PermutationData");
     275                OnPropertyChanged();
    146276            }
    147277        }
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher4Pres.xaml

    r8128 r8136  
    1616            <RowDefinition Height="40"></RowDefinition>
    1717        </Grid.RowDefinitions>
    18         <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Hidden">
     18        <Viewbox Grid.Row="0" StretchDirection="Both" Stretch="Uniform" Name="CipherGrid" Visibility="Visible">
    1919            <Grid Height="790" Width="400" HorizontalAlignment="Center">
    2020                <Label Name="InputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Content="{Loc Cipher4LblInputBlock}" HorizontalAlignment="Center"/>
    2121                <!-- Round 1 -->
    2222                <controls:_4BitKeyRound Grid.Row="0" Grid.Column="0" Margin="170,0,0,0"></controls:_4BitKeyRound>
    23                 <Label FontFamily="Courier New" FontSize="20" Content="K0" Margin="240,85,10,0"></Label>
     23                <Label FontFamily="Courier New" FontSize="20" Content="K0" Margin="240,75,10,0"></Label>
     24                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK0, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,95,115,0"></Label>
    2425                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="170,170,0,0"></controls:_4BitSBox>
    2526                <!-- /Round 1 -->
    2627                <!-- Round 2 -->
    2728                <controls:_4BitKeyRound Grid.Row="0" Grid.Column="0" Margin="170,185,0,0"></controls:_4BitKeyRound>
    28                 <Label FontFamily="Courier New" FontSize="20" Content="K1" Margin="240,270,10,0"></Label>
     29                <Label FontFamily="Courier New" FontSize="20" Content="K1" Margin="240,260,10,0"></Label>
     30                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK1, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,280,115,0"></Label>
    2931                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="170,355,0,0"></controls:_4BitSBox>
    3032                <!-- /Round 2 -->
    3133                <!-- Round 3 -->
    3234                <controls:_4BitKeyRound Grid.Row="0" Grid.Column="0" Margin="170,370,0,0"></controls:_4BitKeyRound>
    33                 <Label FontFamily="Courier New" FontSize="20" Content="K2" Margin="240,450,10,0"></Label>
     35                <Label FontFamily="Courier New" FontSize="20" Content="K2" Margin="240,440,10,0"></Label>
     36                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK2, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,460,115,0"></Label>
    3437                <controls:_4BitSBox Grid.Row="0" Grid.Column="0" Margin="170,540,0,0"></controls:_4BitSBox>
    3538                <controls:_4BitKeyRound Grid.Row="0" Grid.Column="0" Margin="170,555,0,0"></controls:_4BitKeyRound>
    36                 <Label FontFamily="Courier New" FontSize="20" Content="K3" Margin="240,640,10,0"></Label>
     39                <Label FontFamily="Courier New" FontSize="20" Content="K3" Margin="240,630,10,0"></Label>
     40                <Label FontFamily="Courier New" FontSize="15" Content="{Binding CurrentK3, Mode=OneWay}" HorizontalAlignment="Right" Margin="0,650,115,0"></Label>
    3741                <!-- /Round 3 -->
    3842                <Label Name="OutputBlock" FontFamily="Courier New" FontSize="20" FontWeight="Bold" Margin="0,720,0,0" Content="{Loc Cipher4LblOutputBlock}" HorizontalAlignment="Center"/>
    3943            </Grid>
    4044        </Viewbox>
    41         <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Visible">
     45        <ScrollViewer Name="LabelGrid" Grid.Row="0" VerticalScrollBarVisibility="Auto" Visibility="Hidden">
    4246            <Grid Visibility="Visible">
    4347                <Grid.RowDefinitions>
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Cipher4Pres.xaml.cs

    r8128 r8136  
    1 using System;
    2 using System.Collections.Generic;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
     17using System;
    318using System.Collections.ObjectModel;
    419using System.ComponentModel;
    5 using System.Linq;
    620using System.Runtime.CompilerServices;
    7 using System.Text;
    8 using System.Threading.Tasks;
    921using System.Windows;
    1022using System.Windows.Controls;
    11 using System.Windows.Data;
    12 using System.Windows.Documents;
    13 using System.Windows.Input;
    14 using System.Windows.Media;
    15 using System.Windows.Media.Imaging;
    16 using System.Windows.Navigation;
    17 using System.Windows.Shapes;
    1823
    1924namespace ToyCiphers.UI
     
    2631    {
    2732        private ObservableCollection<TableMapping> sboxData;
     33        private int[] _keys;
     34        private string _currentK0;
     35        private string _currentK1;
     36        private string _currentK2;
     37        private string _currentK3;
    2838
    2939        /// <summary>
     
    7484            });
    7585
     86
     87
    7688            DataContext = this;
    7789            InitializeComponent();
     
    8799            {
    88100                sboxData = value;
    89                 OnPropertyChanged("SBoxData");
     101                OnPropertyChanged();
     102            }
     103        }
     104
     105        /// <summary>
     106        /// Property for the keys
     107        /// </summary>
     108        public int[] Keys
     109        {
     110            get { return _keys; }
     111            set
     112            {
     113                _keys = value;
     114                UInt16 keyTemp = Convert.ToUInt16(_keys[0]);
     115
     116                CurrentK0 = Convert.ToString(keyTemp, 2).PadLeft(4, '0');
     117
     118                keyTemp = Convert.ToUInt16(_keys[1]);
     119                CurrentK1 = Convert.ToString(keyTemp, 2).PadLeft(4, '0');
     120
     121                keyTemp = Convert.ToUInt16(_keys[2]);
     122                CurrentK2 = Convert.ToString(keyTemp, 2).PadLeft(4, '0');
     123
     124                keyTemp = Convert.ToUInt16(_keys[3]);
     125                CurrentK3 = Convert.ToString(keyTemp, 2).PadLeft(4, '0');
     126
     127                OnPropertyChanged();
     128            }
     129        }
     130
     131        /// <summary>
     132        /// Property for binding K0
     133        /// </summary>
     134        public string CurrentK0
     135        {
     136            get { return _currentK0; }
     137            set
     138            {
     139                _currentK0 = value;
     140                OnPropertyChanged();
     141            }
     142        }
     143
     144        /// <summary>
     145        /// Property for binding K1
     146        /// </summary>
     147        public string CurrentK1
     148        {
     149            get { return _currentK1; }
     150            set
     151            {
     152                _currentK1 = value;
     153                OnPropertyChanged();
     154            }
     155        }
     156
     157        /// <summary>
     158        /// Property for binding K2
     159        /// </summary>
     160        public string CurrentK2
     161        {
     162            get { return _currentK2; }
     163            set
     164            {
     165                _currentK2 = value;
     166                OnPropertyChanged();
     167            }
     168        }
     169
     170        /// <summary>
     171        /// Property for binding K3
     172        /// </summary>
     173        public string CurrentK3
     174        {
     175            get { return _currentK3; }
     176            set
     177            {
     178                _currentK3 = value;
     179                OnPropertyChanged();
    90180            }
    91181        }
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Controls/16BitKeyRound.xaml.cs

    r8126 r8136  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using System.Windows;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
    717using System.Windows.Controls;
    8 using System.Windows.Data;
    9 using System.Windows.Documents;
    10 using System.Windows.Input;
    11 using System.Windows.Media;
    12 using System.Windows.Media.Imaging;
    13 using System.Windows.Navigation;
    14 using System.Windows.Shapes;
    1518
    1619namespace ToyCiphers.UI.Controls
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Controls/16BitPermutation.xaml.cs

    r8126 r8136  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using System.Windows;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
    717using System.Windows.Controls;
    8 using System.Windows.Data;
    9 using System.Windows.Documents;
    10 using System.Windows.Input;
    11 using System.Windows.Media;
    12 using System.Windows.Media.Imaging;
    13 using System.Windows.Navigation;
    14 using System.Windows.Shapes;
    1518
    1619namespace ToyCiphers.UI.Controls
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Controls/4BitKeyRound.xaml.cs

    r8126 r8136  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using System.Windows;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
    717using System.Windows.Controls;
    8 using System.Windows.Data;
    9 using System.Windows.Documents;
    10 using System.Windows.Input;
    11 using System.Windows.Media;
    12 using System.Windows.Media.Imaging;
    13 using System.Windows.Navigation;
    14 using System.Windows.Shapes;
    1518
    1619namespace ToyCiphers.UI.Controls
  • trunk/CrypPluginsExperimental/ToyCiphers/UI/Controls/4BitSBox.xaml.cs

    r8126 r8136  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using System.Windows;
     1/*
     2   Copyright 2019 Christian Bender christian1.bender@student.uni-siegen.de
     3
     4   Licensed under the Apache License, Version 2.0 (the "License");
     5   you may not use this file except in compliance with the License.
     6   You may obtain a copy of the License at
     7
     8       http://www.apache.org/licenses/LICENSE-2.0
     9
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15*/
     16
    717using System.Windows.Controls;
    8 using System.Windows.Data;
    9 using System.Windows.Documents;
    10 using System.Windows.Input;
    11 using System.Windows.Media;
    12 using System.Windows.Media.Imaging;
    13 using System.Windows.Navigation;
    14 using System.Windows.Shapes;
    1518
    1619namespace ToyCiphers.UI.Controls
  • trunk/CrypPluginsExperimental/ToyCiphers/userdoc.xml

    r8126 r8136  
    66  <language culture="de-DE"/>
    77
    8   <introduction lang="en">   
     8  <introduction lang="en"> 
     9  The ToyCipher component provides several very small and simple algorithms for encrypting data. ToyCiphers are very suitable to demonstrate cryptographic principles and methods in a simple way due to their slim structure. Furthermore, they can be used for various attacks and analysis methods such as differential cryptanalysis. In the following sections the available ToyCiphers are described: 
     10  <section headline="ToyCipher 1">
     11  ToyChiffre 1 is a symmetric block cipher which works on 16 bit blocks. An encryption round is executed with two round keys of 16 bits each. The encryption round consists of key addition and substitution by four parallel SBoxes. The SBoxes each work on 4-bit blocks. In the presentation of the component ToyCipher 1 is shown graphically. It contains the functionality of the SBox. This cipher is based on the cipher "CIPHERONE" in [2].
     12  <section headline="ToyCipher 2">
     13  ToyCipher 2 is a symmetric block cipher which works on 16 bit blocks. Three encryption rounds are executed, whereby the round keys are each 16 bits in size. The encryption rounds consist of key addition, permutation and substitution by four parallel SBoxes. In the last encryption round the permutation is omitted and two round keys are used. The SBoxes each work on 4-bit blocks. In the presentation of the component ToyCipher 2 is shown graphically. It contains the functionality of the SBox and permutation. This cipher is described in [1].
     14  </section>
     15  <section headline="ToyCipher 3">
     16  ToyCipher 3 is a symmetric block cipher which works on 16 bit blocks. Five encryption rounds are executed, whereby the round keys are each 16 bits in size. The encryption rounds consist of key addition, permutation and subsitution by four parallel SBoxes. In the last encryption round the permutation is omitted and two round keys are used. The SBoxes each work on 4-bit blocks. In the presentation of the component the ToyCipher 3 is shown graphically. It contains the functionality of the SBox and permutation. This cipher is described in [2] with the name "CIPHERFOUR".
     17  </section>
     18  <section headline="ToyCipher 4">
     19  ToyCipher 4 is a symmetric block cipher which works on 4 bit blocks. 3 encryption rounds are executed, whereby the round keys are each 4 bits large. The encryption rounds consist of key addition and substitution. In the presentation of the component ToyCipher 4 is shown graphically. It contains the functionality of the SBox. This cipher is described in [2] with the name "CIPHERTHREE".
     20  </section>
    921  </introduction>
    1022
    1123  <introduction lang="de-DE">   
     24  Die ToyChiffre-Komponente stellt verschiedene sehr kleine und einfache Algorithmen zur Verschlüsselung von Daten bereit. ToyChiffren sind aufgrund ihres schlanken Aufbau sehr geeignet kryptographische Prinzipien und Verfahren auf einfache Art demonstrieren zu können. Darüber hinaus können an ihnen gut verschiedene Angriffe und Analyseverfahren wie beispielsweise differenzielle Kryptoanalyse durchgeführt werden. In den folgenden Abschnitten werden die verfügbaren ToyChiffren beschrieben:
     25  <section headline="ToyChiffre 1">
     26  ToyChiffre 1 ist eine symmetrische Blockchiffre, welche auf 16 Bit großen Blöcken arbeitet. Es wird eine Verschlüsselungsrunde ausgeführt mit zwei je 16 Bit großen Rundenschlüsseln. Die Verschlüsselungsrunde besteht aus Schlüssel-Addition und Substitution durch vier parallele SBoxen. Die SBoxen arbeiten jeweils auf 4 Bit großen Blöcken. In der Präsentation der Komponente ist ToyChiffre 1 graphisch dargestellt. Darin enthalten ist die Funktionsweise der SBox. Diese Chiffre orientiert sich an der Chiffre "CIPHERONE" in [2].
     27  </section>
     28  <section headline="ToyChiffre 2">
     29  ToyChiffre 2 ist eine symmetrische Blockchiffre, welche auf 16 Bit großen Blöcken arbeitet. Es werden drei Verschlüsselungsrunden ausgeführt, wobei die Rundenschlüssel je 16 Bit groß sind. Die Verschlüsselungsrunden bestehen aus Schlüssel-Addition, Permutation und Substitution durch vier parallele SBoxen. In der letzten Verschlüsselungsrunde entfällt die Permutation und es werden zwei Rundenschlüssel verwendet. Die SBoxen arbeiten jeweils auf 4 Bit großen Blöcken. In der Präsentation der Komponente ist ToyChiffre 2 graphisch dargestellt. Darin enthalten ist die Funktionsweise der SBox und Permutation. Diese Chiffre ist in [1] beschrieben.
     30  </section>
     31  <section headline="ToyChiffre 3">
     32  ToyChiffre 3 ist eine symmetrische Blockchiffre, welche auf 16 Bit großen Blöcken arbeitet. Es werden fünf Verschlüsselungsrunden ausgeführt, wobei die Rundenschlüssel je 16 Bit groß sind. Die Verschlüsselungsrunden bestehen aus Schlüssel-Addition, Permutation und Subsitution durch vier parallele SBoxen. In der letzten Verschlüsselungsrunde entfällt die Permutation und es werden zwei Rundenschlüssel verwendet. Die SBoxen arbeiten jeweils auf 4 Bit großen Blöcken. In der Präsentation der Komponente ist die ToyChiffre 3 graphisch dargestellt. Darin enthalten ist die Funktionsweise der SBox und Permutation. Diese Chiffre ist in [2] mit dem Namen "CIPHERFOUR" beschrieben.
     33  </section>
     34  <section headline="ToyChiffre 4">
     35  ToyChiffre 4 ist eine symmetrische Blockchiffre, welche auf 4 Bit großen Blöcken arbeitet. Es werden 3 Verschlüsselungsrunden ausgeführt, wobei die Rundenschlüssel je 4 Bit groß sind. Die Verschlüsselungsrunden bestehen aus Schlüssel-Addition und Substitution. In der Präsentation der Komponente ist ToyChiffre 4 graphisch dargestellt. Darin enthalten ist die Funktionsweise der SBox. Diese Chiffre ist in [2] mit dem Namen "CIPHERTHREE" beschrieben.
     36  </section>
    1237  </introduction>
    1338
    1439  <usage lang="en">
     40  First, an algorithm is selected in the configuration of the ToyCipher component. Depending on the selection, keys of different lengths must be specified. In addition, input messages can be specified, which will be encrypted by the component. The key length can be found in this documentation or in the presentation of the component itself.
    1541  </usage>
    1642
    1743  <usage lang="de-DE">
     44  Zunächst wird in der Konfiguration der ToyChiffre-Komponente ein Algorithmus ausgewählt. In Abhängigkeit der Auswahl müssen verschieden lange Schlüssel angegeben werden. Des weiteren können Eingabenachrichten angegeben werden, welche durch die Komponente dann verschlüsselt ausgegeben werden. Die Schlüssellänge kann in dieser Dokumentation oder in der Präsentation der Komponente selbst entnommen werden.
    1845  </usage>
    1946 
    2047  <presentation lang="en">
     48  The ToyCipher component contains a graphical presentation. In this presentation a short description in textual and graphical form is given for each ToyCipher. The views can be switched via a button
    2149  </presentation>
    2250 
    2351  <presentation lang="de-DE">
     52  Die ToyChiffre-Komponente enthält eine graphische Präsentation. In dieser wird zu jeder ToyChiffre eine kurze Beschreibung in textueller und graphischer Form gegeben. Die Ansichten können über einen Button umgeschaltet werden.
    2453  </presentation>
    2554 
    2655  <references>
     56  <linkReference>
     57      <link url="https://pdfs.semanticscholar.org/dee2/23a06f16f6d6939b363d56b6af5a2c9edbee.pdf" lang="en" />
     58      <caption lang="en">DIFFERENTIAL CRYPTANALYSIS FOR A 3-ROUND SPN</caption>
     59      <link url="https://pdfs.semanticscholar.org/dee2/23a06f16f6d6939b363d56b6af5a2c9edbee.pdf" lang="de-DE" />
     60      <caption lang="de-DE">DIFFERENTIAL CRYPTANALYSIS FOR A 3-ROUND SPN</caption>
     61    </linkReference>
     62        <linkReference>
     63      <link url="https://www.springer.com/de/book/9783642173417" lang="en" />
     64      <caption lang="en">The Block Cipher Companion</caption>
     65      <link url="https://www.springer.com/de/book/9783642173417" lang="de-DE" />
     66      <caption lang="de-DE">The Block Cipher Companion</caption>
     67    </linkReference>
    2768  </references>
    2869</documentation>
  • trunk/Templates/Cryptanalysis/Modern/Differential_Cryptanalysis.xml

    r8127 r8136  
    1717    <plugin name="ToyCiphers" />
    1818  </relevantPlugins>
     19 
    1920  <replacements lang="de">
    20    
     21    <replacement key="$UserMessageInput$" value="Eingabe des Klartext" />
     22        <replacement key="$UserKeyInput$" value="Eingabe des Schlüssel" />
     23        <replacement key="$ToyCipherComponent$" value="DCA ToyCipher" />
     24        <replacement key="$ToyCipherComponentOutput$" value="Ausgabe des Schlüsseltext" />
     25        <replacement key="$DCADesc$" value="In dieser Vorlage wird ein Tutorial für differenzielle Kryptoanalyse von symmetrischen Blockchiffren dargestellt." />
    2126  </replacements>
    2227  <replacements lang="en">
    23    
     28        <replacement key="$UserMessageInput$" value="Input of the plaintext" />
     29        <replacement key="$UserKeyInput$" value="Input of the key" />
     30        <replacement key="$ToyCipherComponent$" value="DCA ToyCipher" />
     31        <replacement key="$ToyCipherComponentOutput$" value="Output of the ciphertext" />
     32        <replacement key="$DCADesc$" value="In this template a tutorial for differential cryptanalysis of symmetric block ciphers is presented." />
    2433  </replacements>
    2534</sample>
Note: See TracChangeset for help on using the changeset viewer.