Ignore:
Timestamp:
Sep 23, 2009, 1:19:57 PM (12 years ago)
Author:
oruba
Message:
  • added TriviumControl for M/S with CubeAttack
  • added M/S support for Trivium
  • added sample file for CubeAttack w/ Trivium
Location:
trunk/CrypPlugins/Trivium
Files:
2 edited

Legend:

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

    r562 r563  
    1212using Cryptool.PluginBase.Miscellaneous;
    1313using System.Security.Cryptography;
     14// for IControl
     15using Cryptool.PluginBase.Control;
     16// reference to the TriviumController interface (own dll)
     17using Cryptool.TriviumController;
    1418
    1519namespace Cryptool.Trivium
     
    3741        public uint[] c = new uint[111];
    3842        public uint t1, t2, t3;
     43        public int masterSlaveRounds = 0;
    3944        #endregion
    4045
     
    455460        }
    456461
    457         private void initTrivium(int[] IV, int[] key)
     462        public void initTrivium(int[] IV, int[] key)
    458463        {
    459464                int i,j;
     
    508513
    509514            // belegung fertig, jetzt takten ohne output
    510 
    511             for (i = 0; i < settings.InitRounds; i++) // default 1152 = 4 * 288
     515            // anzahl der takte laut settings oder lut master/slave
     516            int myRounds;
     517
     518            if (masterSlaveRounds != 0)
     519                myRounds = masterSlaveRounds;
     520            else
     521                myRounds = settings.InitRounds;
     522
     523            for (i = 0; i < myRounds; i++) // default 1152 = 4 * 288
    512524            {
    513525                t1 = a[65] ^ (a[90] & a[91]) ^ a[92] ^ b[77];
     
    526538        }
    527539
    528         private string keystreamTrivium(int nBits)
     540        public string keystreamTrivium(int nBits)
    529541        {
    530542            int i, j;
     
    665677
    666678        #endregion
     679
     680        #region IControl
     681
     682        private IControlTrivium triviumSlave;
     683        [PropertyInfo(Direction.ControlSlave, "Trivium Slave", "Direct access to Trivium.", "", DisplayLevel.Beginner)]
     684        public IControlTrivium TriviumSlave
     685        {
     686            get
     687            {
     688                if (triviumSlave == null)
     689                    triviumSlave = new TriviumControl(this);
     690                return triviumSlave;
     691            }
     692        }
     693
     694        #endregion
    667695    }
     696
     697    #region TriviumControl : IControlTrivium
     698
     699    public class TriviumControl : IControlTrivium
     700    {
     701        private Trivium plugin;
     702        private TriviumSettings pluginSettings;
     703
     704        public TriviumControl(Trivium Plugin)
     705        {
     706            this.plugin = Plugin;
     707        }
     708
     709        public TriviumControl(TriviumSettings PluginSettings)
     710        {
     711            this.pluginSettings = PluginSettings;
     712        }
     713
     714        #region IControlEncryption Members
     715
     716        // here comes the slave side implementation
     717        public int GenerateTriviumKeystream(int[] IV, int[] key, int length, int rounds, bool byteSwapping)
     718        {
     719            string resultString;
     720            int resultInt;
     721
     722            //pluginSettings.InitRounds = rounds;
     723
     724            plugin.masterSlaveRounds = rounds;
     725            plugin.initTrivium(IV, key);
     726
     727            resultString = plugin.keystreamTrivium(length);
     728
     729            return resultInt = Int32.Parse(resultString.Substring(resultString.Length - 1, 1));
     730        }
     731
     732        #endregion
     733    }
     734
     735    #endregion
    668736
    669737    enum TriviumImage
  • trunk/CrypPlugins/Trivium/Trivium.csproj

    r410 r563  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.30729</ProductVersion>
     6    <ProductVersion>9.0.21022</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{118668D4-613C-4D27-973B-092D5B25A692}</ProjectGuid>
     
    5252    <Reference Include="System.Data" />
    5353    <Reference Include="System.Xml" />
     54    <Reference Include="TriviumController, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d4526fd6dc4c2912, processorArchitecture=MSIL">
     55      <SpecificVersion>False</SpecificVersion>
     56      <HintPath>..\TriviumController\bin\Debug\TriviumController.dll</HintPath>
     57    </Reference>
    5458    <Reference Include="WindowsBase">
    5559      <RequiredTargetFramework>3.0</RequiredTargetFramework>
Note: See TracChangeset for help on using the changeset viewer.