Changeset 419 for trunk/CrypPlugins/DES


Ignore:
Timestamp:
Aug 7, 2009, 12:08:23 AM (12 years ago)
Author:
Thomas Schmid
Message:
  • merged IControl branch to trunk
  • added KeySearcher sample: KeySearcher-Sample
  • changed some plugins to work with new enumeration
  • new bins
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo set to
      /branches/IControl_Test_Branch393-418
  • trunk/CrypPlugins/DES/DES.cs

    r211 r419  
    1010using Cryptool.PluginBase.IO;
    1111using System.Windows.Controls;
     12using Cryptool.PluginBase.Control;
    1213
    1314namespace Cryptool.Plugins.Cryptography.Encryption
     
    4546        }
    4647
    47         [PropertyInfo(Direction.Input, "Input", "Data to be encrypted or decrypted", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     48        [PropertyInfo(Direction.InputData, "Input", "Data to be encrypted or decrypted", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    4849        public CryptoolStream InputStream
    4950        {
     
    6768        }
    6869
    69         [PropertyInfo(Direction.Input, "Key", "Must be 8 bytes.", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     70        [PropertyInfo(Direction.InputData, "Key", "Must be 8 bytes.", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    7071        public byte[] InputKey
    7172        {
     
    7879        }
    7980
    80         [PropertyInfo(Direction.Input, "IV", "IV to be used in chaining modes, must be the same as the Blocksize in bytes (8 bytes).", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     81        [PropertyInfo(Direction.InputData, "IV", "IV to be used in chaining modes, must be the same as the Blocksize in bytes (8 bytes).", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    8182        public byte[] InputIV
    8283        {
     
    8990        }
    9091       
    91         [PropertyInfo(Direction.Output, "Output stream", "Encrypted or decrypted output data", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     92        [PropertyInfo(Direction.OutputData, "Output stream", "Encrypted or decrypted output data", null, true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    9293        public CryptoolStream OutputStream
    9394        {
     
    359360
    360361        #endregion
     362
     363        private IControlEncryption testSlave;
     364        [PropertyInfo(Direction.ControlSlave, "DES Slave", "Direct access to DES.", "", DisplayLevel.Beginner)]
     365        public IControlEncryption TestSlave
     366        {
     367          get
     368          {
     369            if (testSlave == null)
     370              testSlave = new DESControl(this);
     371            return testSlave;
     372          }
     373        }   
     374    }
     375
     376    public class DESControl : IControlEncryption
     377    {
     378      private DES plugin;
     379
     380      public DESControl(DES Plugin)
     381      {
     382        this.plugin = Plugin;
     383      }
     384
     385      #region IControlEncryption Members
     386
     387      public byte[] Encrypt(byte[] key, byte[] data, byte[] iv)
     388      {
     389        ((DESSettings)plugin.Settings).Action = 0;
     390        return execute(key, data, iv);
     391      }
     392
     393      public byte[] Decrypt(byte[] key, byte[] data, byte[] iv)
     394      {
     395        ((DESSettings)plugin.Settings).Action = 1;
     396        return execute(key, data, iv);
     397      }
     398
     399      private byte[] execute(byte[] key, byte[] data, byte[] iv)
     400      {
     401        plugin.InputKey = key;
     402        plugin.InputIV = iv;
     403        CryptoolStream cs = new CryptoolStream();
     404        cs.OpenRead(this.GetType().Name, data);
     405        plugin.InputStream = cs;
     406        plugin.Execute();
     407        CryptoolStream output = plugin.OutputStream;
     408
     409        byte[] byteValues = new byte[output.Length];
     410        int bytesRead;
     411        output.Seek(0, SeekOrigin.Begin);
     412        bytesRead = output.Read(byteValues, 0, byteValues.Length);
     413        plugin.Dispose();
     414        cs.Close();
     415        output.Close();
     416        return byteValues;
     417      }
     418
     419      #endregion
    361420    }
    362421}
Note: See TracChangeset for help on using the changeset viewer.