source: trunk/CrypPlugins/Twofish/TwofishSetting.cs @ 2380

Last change on this file since 2380 was 419, checked in by Thomas Schmid, 12 years ago
  • merged IControl branch to trunk
  • added KeySearcher sample: KeySearcher-Sample
  • changed some plugins to work with new enumeration
  • new bins
  • Property svn:keywords set to URL Author Date Rev Id
File size: 4.6 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////////////////////
2// CrypTool V2
3// © 2008 - Gerhard Junker
4// Apache License see http://www.apache.org/licenses/
5//
6// $HeadURL: trunk/CrypPlugins/Twofish/TwofishSetting.cs $
7//////////////////////////////////////////////////////////////////////////////////////////////////
8// $Revision:: 419                                                                            $://
9// $Author:: schmid                                                                           $://
10// $Date:: 2009-08-06 22:08:23 +0000 (Thu, 06 Aug 2009)                                       $://
11//////////////////////////////////////////////////////////////////////////////////////////////////
12
13using System;
14using System.Collections.Generic;
15using System.Text;
16
17using Cryptool.PluginBase;
18using Cryptool.PluginBase.Cryptography;
19using Cryptool.PluginBase.IO;
20
21using System.Security.Cryptography;
22using System.ComponentModel;
23using System.Runtime.InteropServices;
24
25using System.Windows.Controls;
26
27namespace Twofish
28{
29  public class TwofishSettings : ISettings
30  {
31
32    private bool hasChanges = false;
33
34    static int[] keyTab = { 128, 192, 256};
35
36    #region ISettings Member
37
38    /// <summary>
39    /// Gets or sets A value indicating whether this instance has changes.
40    /// </summary>
41    /// <value>
42    ///         <c>true</c> if this instance has changes; otherwise, <c>false</c>.
43    /// </value>
44    public bool HasChanges
45    {
46      get
47      {
48        return hasChanges;
49      }
50      set
51      {
52        hasChanges = value;
53      }
54    }
55
56    #endregion
57
58    int action = 1;
59    [ContextMenu("Action", "Do you want the input data to be encrypted or decrypted?", 2,
60      DisplayLevel.Beginner, ContextMenuControlType.ComboBox,
61      new int[] { 1, 2 }, "Encrypt", "Decrypt")]
62    [TaskPane("Action",
63      "Do you want the input data to be encrypted or decrypted?", "", 0, false,
64       DisplayLevel.Beginner, ControlType.ComboBox,
65       new string[] { "Encrypt", "Decrypt" })]
66    public int Action
67    {
68      get
69      {
70        return action;
71      }
72      set
73      {
74        if (((int)value) != action)
75          hasChanges = true;
76        action = (int)value;
77        OnPropertyChanged("Action");
78      }
79    }
80
81
82    int mode = 0;
83    [ContextMenu("Chaining mode",
84          "Select the block cipher mode of operation.", 2,
85          DisplayLevel.Beginner, ContextMenuControlType.ComboBox, null,
86          new string[] { "Electronic Code Book (ECB)", "Cipher Block Chaining (CBC)" })]
87    [TaskPane("Chaining mode", "Select the block cipher mode of operation.", "", 5, false,
88          DisplayLevel.Experienced, ControlType.ComboBox,
89          new string[] {"Electronic Code Book (ECB)", "Cipher Block Chaining (CBC)"} ) ]
90    public int Mode
91    {
92      get
93      {
94        return mode;
95      }
96
97      set
98      {
99        if (((int)value) != mode)
100          hasChanges = true;
101        this.mode = (int)value;
102        OnPropertyChanged("Mode");
103      }
104    }
105
106
107    int keySize = 0;
108    [ContextMenu("KeySize",
109      "Select the key size. Note that providing a longer key will result in cutting the overlapping bytes, " +
110      "providing a shorter key will result in filling up with zeroes.", 3,
111      DisplayLevel.Beginner, ContextMenuControlType.ComboBox, null, "128 Bits", "192 Bits", "256 Bits")]
112    [TaskPane("KeySize",
113      "Select the key size. Note that providing a longer key will result in cutting the overlapping bytes, "+
114      "providing a shorter key will result in filling up with zeroes.", "", 3, false,
115      DisplayLevel.Beginner, ControlType.ComboBox, new String[] { "128 Bits", "192 Bits", "256 Bits" })]
116    public int KeySize
117    {
118      get
119      {
120        return keySize;
121      }
122      set
123      {
124        if (((int)value) != keySize)
125          hasChanges = true;
126        keySize = (int)value;
127        OnPropertyChanged("KeySize");
128      }
129    }
130
131
132    /// <summary>
133    /// Gets the length of the key.
134    /// </summary>
135    /// <value>The length of the key.</value>
136    public int KeyLength
137    {
138      get
139      {
140        return keyTab[keySize];
141      }
142    }
143
144    #region INotifyPropertyChanged Member
145
146    public event PropertyChangedEventHandler  PropertyChanged;
147
148    /// <summary>
149    /// Called when [property changed].
150    /// </summary>
151    /// <param name="name">The name.</param>
152    protected void OnPropertyChanged(string name)
153    {
154      if (PropertyChanged != null)
155      {
156        PropertyChanged(this, new PropertyChangedEventArgs(name));
157      }
158      hasChanges = true;
159    }
160
161    #endregion
162  }
163}
Note: See TracBrowser for help on using the repository browser.