Changeset 371 for trunk/CrypPlugins/LFSR


Ignore:
Timestamp:
Jul 1, 2009, 10:24:26 AM (13 years ago)
Author:
Sören Rinne
Message:
  • changed some details
  • added Trivium (not working yet)
  • added NLFSR (not working correct now)
Location:
trunk/CrypPlugins/LFSR
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/LFSR/LFSR.cs

    r318 r371  
    2525{
    2626    [Author("Soeren Rinne", "soeren.rinne@cryptool.de", "Ruhr-Universitaet Bochum, Chair for System Security", "http://www.trust.rub.de/")]
    27     [PluginInfo(false, "LFSR", "Linear Feedback Shift Register", "LFSR/DetailedDescription/Description.xaml", "LFSR/Images/LFSR.png", "LFSR/Images/encrypt.png", "LFSR/Images/decrypt.png")]
     27    [PluginInfo(true, "LFSR", "Linear Feedback Shift Register", "LFSR/DetailedDescription/Description.xaml", "LFSR/Images/LFSR.png", "LFSR/Images/encrypt.png", "LFSR/Images/decrypt.png")]
    2828    [EncryptionType(EncryptionType.SymmetricBlock)]
    2929    public class LFSR : IThroughput
     
    8484        }
    8585
    86         [PropertyInfo(Direction.Input, "TapSequence", "TapSequence function in binary presentation.", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
     86        [PropertyInfo(Direction.Input, "TapSequence", "TapSequence function in binary presentation.", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
    8787        public String InputTapSequence
    8888        {
     
    9898        }
    9999
    100         [PropertyInfo(Direction.Input, "Seed", "Seed of the LFSR in binary presentation.", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
     100        [PropertyInfo(Direction.Input, "Seed", "Seed of the LFSR in binary presentation.", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
    101101        public String InputSeed
    102102        {
     
    111111            }
    112112        }
    113         /*
    114         [PropertyInfo(Direction.Input, "Clock", "Optional clock input. LFSR only advances if clock is 1.", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    115         public CryptoolStream InputClock
    116         {
    117             [MethodImpl(MethodImplOptions.Synchronized)]
    118             get
    119             {
    120                 if (inputClock != null)
    121                 {
    122                     CryptoolStream cs = new CryptoolStream();
    123                     cs.OpenRead(inputClock.FileName);
    124                     listCryptoolStreamsOut.Add(cs);
    125                     return cs;
    126                 }
    127                 else return null;
    128             }
    129             [MethodImpl(MethodImplOptions.Synchronized)]
    130             set
    131             {
    132                 this.inputClock = value;
    133                 if (value != null) listCryptoolStreamsOut.Add(value);
    134                 OnPropertyChanged("InputClock");
    135             }
    136         }*/
    137 
    138         [PropertyInfo(Direction.Input, "Clock", "Optional clock input. LFSR only advances if clock is true.", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
     113
     114        [PropertyInfo(Direction.Input, "Clock", "Optional clock input. LFSR only advances if clock is true.", "", false, true, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
    139115        public Boolean InputClockBool
    140116        {
     
    150126        }
    151127
    152         [PropertyInfo(Direction.Output, "Output stream", "LFSR Stream Output. Use this for bulk output.", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     128        [PropertyInfo(Direction.Output, "Output stream", "LFSR Stream Output. Use this for bulk output.", "", false, true, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    153129        public CryptoolStream OutputStream
    154130        {
     
    207183        }
    208184       
     185        /*
    209186        private bool controllerOutput;
    210187        [ControllerProperty(Direction.Output, "Controller Output", "", DisplayLevel.Beginner)]
     
    213190            get { return controllerOutput; }
    214191            set { controllerOutput = (bool)value; }
    215         }
     192        }*/
    216193
    217194        public void Dispose()
     
    257234        #region private functions
    258235
    259         private void checkForInputTapSequence()
    260         {
     236        private bool checkForInputTapSequence()
     237        {
     238            if ((settings.Polynomial == null || (settings.Polynomial != null && settings.Polynomial.Length == 0)))
     239            {
     240                // awaiting polynomial from input
     241                GuiLogMessage("No feedback polynomial given in settings. Awaiting external input.", NotificationLevel.Info);
     242                /*GuiLogMessage("No feedback polynomial given in settings.", NotificationLevel.Error);
     243                if (!settings.UseBoolClock) inputClock.Close();
     244                return;*/
     245            }
     246            else
     247            {
     248                inputTapSequence = settings.Polynomial;
     249                return true;
     250            }
     251
    261252            if ((inputTapSequence == null || (inputTapSequence != null && inputTapSequence.Length == 0)))
    262253            {
     
    267258                // write a warning to the outside world
    268259                GuiLogMessage("WARNING - No TapSequence provided. Using dummy data (" + dummystring + ").", NotificationLevel.Warning);
    269             }
    270         }
    271 
    272         private void checkForInputSeed()
    273         {
     260                return true;
     261            }
     262            else
     263            {
     264                return false;
     265            }
     266        }
     267
     268        private bool checkForInputSeed()
     269        {
     270            if ((settings.Seed == null || (settings.Seed != null && settings.Seed.Length == 0)))
     271            {
     272                // awaiting seed from input
     273                GuiLogMessage("No seed given in settings. Awaiting external input.", NotificationLevel.Info);
     274                /*GuiLogMessage("No seed given in settings.", NotificationLevel.Error);
     275                if (!settings.UseBoolClock) inputClock.Close();
     276                return;*/
     277            }
     278            else
     279            {
     280                inputSeed = settings.Seed;
     281                return true;
     282            }
     283
    274284            if ((inputSeed == null || (inputSeed != null && inputSeed.Length == 0)))
    275285            {
     
    280290                // write a warning to the outside world
    281291                GuiLogMessage("WARNING - No Seed provided. Using dummy data (" + dummystring + ").", NotificationLevel.Warning);
     292                return true;
     293            }
     294            else
     295            {
     296                return false;
    282297            }
    283298        }
     
    446461                if (newSeed)
    447462                {
    448                     checkForInputTapSequence();
    449                     checkForInputSeed();
    450 
    451                     if (inputSeed == null || (inputSeed != null && inputSeed.Length == 0))
     463                    if (!checkForInputTapSequence()) return;
     464                    if (!checkForInputSeed()) return;
     465
     466                    /*if (inputSeed == null || (inputSeed != null && inputSeed.Length == 0))
    452467                    {
    453468                        GuiLogMessage("No Seed given. Aborting now.", NotificationLevel.Error);
     
    461476                        if (!settings.UseBoolClock) inputClock.Close();
    462477                        return;
    463                     }
     478                    }*/
    464479
    465480                    // read tapSequence
     
    777792                }
    778793
    779                 controllerOutput = true;
    780                 OnPropertyChanged("ControllerOutput");
     794                //controllerOutput = true;
     795                //OnPropertyChanged("ControllerOutput");
    781796
    782797                // stop counter
  • trunk/CrypPlugins/LFSR/LFSRPresentation.xaml.cs

    r304 r371  
    197197                    myTextBoxes[i].VerticalContentAlignment = VerticalAlignment.Center;
    198198                    myTextBoxes[i].BorderBrush = Brushes.Black;
    199                     //if (i % 2 != 0) myTextBoxes[i].Background = Brushes.Lavender;
    200                     //if (i != 0)
    201                     //{
    202                         if (tapSequence[i] == '1') myTextBoxes[i].Background = Brushes.DodgerBlue;
    203                     //}
     199                    //if (tapSequence[i] == '1') myTextBoxes[i].Background = Brushes.DodgerBlue;
    204200                    if (clockingBit == i) myTextBoxes[i].Background = Brushes.Orange;
    205201
  • trunk/CrypPlugins/LFSR/LFSRSettings.cs

    r304 r371  
    2525        //[ContextMenu("Rounds", "How many bits shall be generated?", 1, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, new int[] { 10, 50, 100 }, "10 bits", "50 bits", "100 bits")]
    2626        //[TaskPane("Rounds", "How many bits shall be generated?", null, 1, false, DisplayLevel.Beginner, ControlType.TextBox)]
    27         [TaskPane("Number of rounds", "How many bits shall be generated? Note: This only applies if no boolean clock is used.", null, 0, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
     27        [TaskPane("Number of rounds", "How many bits shall be generated? Note: This only applies if no boolean clock is used.", null, 2, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
    2828        public int Rounds
    2929        {
     
    3636        }
    3737
     38        string polynomial;
     39        [TaskPane("Polynomial", "Define the feedback polynomial either in a textual or a numeric way. For example x^5 +x^2 + 1 which is equal to 10010", null, 0, false, DisplayLevel.Beginner, ControlType.TextBox)]
     40        public string Polynomial
     41        {
     42            get { return this.polynomial; }
     43            set
     44            {
     45                this.polynomial = value;
     46                OnPropertyChanged("Polynomial");
     47                HasChanges = true;
     48            }
     49        }
     50
     51
     52
     53        string seed;
     54        [TaskPane("Seed", "Define the seed of the LFSR. For example 11100", null, 1, false, DisplayLevel.Beginner, ControlType.TextBox)]
     55        public string Seed
     56        {
     57            get { return this.seed; }
     58            set
     59            {
     60                this.seed = value;
     61                OnPropertyChanged("Seed");
     62                HasChanges = true;
     63            }
     64        }
     65
    3866        private bool noQuickwatch = false;
    3967        [ContextMenu("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for better performance.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Display Quickwatch?" })]
    40         [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for better performance.", null, 1, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
     68        [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for better performance.", null, 3, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
    4169        public bool NoQuickwatch
    4270        {
Note: See TracChangeset for help on using the changeset viewer.