Changeset 752


Ignore:
Timestamp:
Oct 20, 2009, 1:07:36 PM (12 years ago)
Author:
Sören Rinne
Message:
  • new CubeAttackParser-Sample.cte
  • BFP now needs only one presentation for Cube Attack
  • adjusted Trivium
Location:
trunk
Files:
10 edited

Legend:

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

    r705 r752  
    226226                    lastInputWasFunction = false;
    227227
    228                     int intOutput = ParseBooleanFunction(inputFunction, null, 0);
     228                    int intOutput = ParseBooleanFunction(null, null);
    229229                    if (intOutput == -1) return;
    230230                    else
     
    345345         * *******************************************************************************
    346346        */
    347         public int ParseBooleanFunction(string function, bool[] inputVariables, int switchInputs)
    348         {
     347        public int ParseBooleanFunction(bool[] inputVariables, bool[] dataTwo)
     348        {
     349            string function = null;
    349350            // if function is empty, use input funtion (could happen in case of a master/slave call) or quickwatch function
    350351            // get quickwatch function
     
    358359            }, booleanFunctionParserPresentation);
    359360
    360             if (function == null || function == string.Empty)
    361             {
    362                 if (inputFunction != null && inputFunction != string.Empty)
    363                     function = inputFunction;
    364                 else if (quickwatchFunction != null && quickwatchFunction != string.Empty && switchInputs == 1)
    365                     function = quickwatchFunction;
    366                 else if (quickwatchFunctionCube != null && quickwatchFunctionCube != string.Empty && switchInputs == 2)
    367                     function = quickwatchFunctionCube;
    368                 else if (quickwatchFunction != null && quickwatchFunction != string.Empty)
    369                     function = quickwatchFunction;
    370                 else
    371                     return -1;
    372             }
     361            if (inputFunction != null && inputFunction != string.Empty)
     362                function = inputFunction;
     363            else if (quickwatchFunction != null && quickwatchFunction != string.Empty)
     364                function = quickwatchFunction;
     365            else if (quickwatchFunctionCube != null && quickwatchFunctionCube != string.Empty && settings.UseBFPforCube == true)
     366                function = quickwatchFunctionCube;
     367            else
     368                return -1;
     369
    373370            // replace variables with data
    374             string strExpression = ReplaceVariables(function, inputVariables, switchInputs);
     371            string strExpression = ReplaceVariables(function, inputVariables, dataTwo);
    375372            // test if function is valid
    376373            string strExpressionTested = TestFunction(strExpression);
     
    404401        }
    405402
    406         private string ReplaceVariables(string strExpressionWithVariables, bool[] externData, int switchData)
     403        private string ReplaceVariables(string strExpressionWithVariables, bool[] externDataOne, bool []externDataTwo)
    407404        {
    408405            // remove spaces
     
    465462            }
    466463            // replace extern data (i_0.*) (if there is any)
    467             if (externData != null && externData.Length != 0)
    468             {
    469                 char[] strInputVariableExtern = new char[externData.Length];
     464            if (externDataOne != null && externDataOne.Length != 0)
     465            {
     466                char[] strInputVariableExtern = new char[externDataOne.Length];
    470467                for (int i = strInputVariableExtern.Length - 1; i >= 0; i--)
    471468                {
    472469                    // get numeric values from bool inputs
    473                     strInputVariableExtern[i] = externData[i] ? '1' : '0';
     470                    strInputVariableExtern[i] = externDataOne[i] ? '1' : '0';
    474471                    string replacement = "i_0." + i;
    475472                    strExpression = strExpression.Replace(replacement, strInputVariableExtern[i].ToString());
     
    477474            }
    478475            // replace quickwatch data (i_q.*) (if there is any)
    479             if (switchData == 1 || switchData == 0)
     476            if (settings.UseBFPforCube == false)
    480477            {
    481478                string quickwatchData = (string)this.booleanFunctionParserPresentation.textBoxInputData.Dispatcher.Invoke(DispatcherPriority.Normal, (DispatcherOperationCallback)delegate
     
    483480                    return booleanFunctionParserPresentation.textBoxInputData.Text;
    484481                }, booleanFunctionParserPresentation);
    485                 if (quickwatchData == null || quickwatchData != string.Empty)
     482                if (quickwatchData != null && quickwatchData != string.Empty)
    486483                {
    487484                    char[] strInputVariableQuickwatch = new char[quickwatchData.Length];
     
    493490                    }
    494491                }
    495             } if (switchData == 2)
     492            } else if (settings.UseBFPforCube == true)
    496493            {
    497494                string quickwatchDataCube = (string)this.booleanFunctionParserPresentation.textBoxInputData2.Dispatcher.Invoke(DispatcherPriority.Normal, (DispatcherOperationCallback)delegate
     
    499496                    return booleanFunctionParserPresentation.textBoxInputData2.Text;
    500497                }, booleanFunctionParserPresentation);
    501                 if (quickwatchDataCube == null || quickwatchDataCube != string.Empty)
     498                // Cube Attack Online Phase
     499                if (externDataTwo != null && externDataTwo.Length != 0)
     500                {
     501                    char[] strInputVariableExtern = new char[externDataOne.Length];
     502                    for (int i = strInputVariableExtern.Length - 1; i >= 0; i--)
     503                    {
     504                        // get numeric values from bool inputs
     505                        strInputVariableExtern[i] = externDataTwo[i] ? '1' : '0';
     506                        string replacement = "i_q." + i;
     507                        strExpression = strExpression.Replace(replacement, strInputVariableExtern[i].ToString());
     508                    }
     509                }
     510                // Cube Attack Preprocessing Phase
     511                else if (quickwatchDataCube != null && quickwatchDataCube != string.Empty)
    502512                {
    503513                    char[] strInputVariableQuickwatch = new char[quickwatchDataCube.Length];
     
    509519                    }
    510520                }
     521               
    511522            }
    512523           
     
    836847
    837848        // here comes the slave side implementation of SolveFunction
    838         public int SolveFunction(string function, bool[] data, int switchInputs)
     849        public int SolveFunction(bool[] dataOne, bool[] dataTwo)
    839850        {
    840851            int resultInt;
     
    842853            // the result is computed by calling the ParseBooleanFunction (step into it with F11)
    843854            // returns -1 on error (e.g. not a valid function)
    844             resultInt = plugin.ParseBooleanFunction(function, data, switchInputs);
     855            resultInt = plugin.ParseBooleanFunction(dataOne, dataTwo);
    845856
    846857            return resultInt;
  • trunk/CrypPlugins/BooleanFunctionParser/BooleanFunctionParserPresentation.xaml

    r490 r752  
    4444       
    4545        <Label Name="labelInputFunction2" Grid.Column="2" Grid.Row="0" VerticalAlignment="Top" Margin="4" Padding="0">
    46             2nd boolean function for cube attack:
     46            Boolean function for cube attack:
    4747        </Label>
    4848        <Grid Background="White" Grid.Column="2" Grid.Row="1">
     
    5454        </Grid>
    5555        <Label Name="labelInputData2" Grid.Column="2" Grid.Row="2" VerticalAlignment="Top" Margin="4" Padding="0" >
    56             Secret Key data:
     56            Secret key:
    5757        </Label>
    5858        <Grid Background="White" Grid.Column="2" Grid.Row="3">
  • trunk/CrypPlugins/BooleanFunctionParser/BooleanFunctionParserPresentation.xaml.cs

    r490 r752  
    262262          {
    263263              GridLength colLength = (GridLength)myGridLengthConverter.ConvertFromString("1*");
    264               GridLength colmLength = (GridLength)myGridLengthConverter.ConvertFromString("5");
     264              //GridLength colmLength = (GridLength)myGridLengthConverter.ConvertFromString("5");
     265              GridLength col0Length = (GridLength)myGridLengthConverter.ConvertFromString("0");
    265266              if (col0 != null)
    266267                  Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    267268                  {
    268                       col0.Width = colLength;
     269                      col0.Width = col0Length;
    269270                  }, null);
    270271
     
    274275                      col1.Width = colLength;
    275276                  }, null);
    276               if (colm != null)
     277              /*if (colm != null)
    277278                  Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    278279                  {
    279280                      colm.Width = colmLength;
    280281                  }, null);
     282               */
    281283          }
    282284      }
  • trunk/CrypPlugins/BooleanFunctionParserController/BooleanFunctionParserController.csproj

    r446 r752  
    3434  </PropertyGroup>
    3535  <ItemGroup>
    36     <Reference Include="BooleanFunctionParserController, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6ffa0264846191ab, processorArchitecture=MSIL" />
    3736    <Reference Include="CrypPluginBase, Version=2.0.3517.1, Culture=neutral, PublicKeyToken=db26bd0a20dcbd5c, processorArchitecture=MSIL">
    3837      <SpecificVersion>False</SpecificVersion>
  • trunk/CrypPlugins/BooleanFunctionParserController/IControlSolveFunction.cs

    r477 r752  
    1010    /* **********************************
    1111     * Arguments:
    12      *      string function:    the function to be solved. Can also be null to use BFP input or BFP quickwatch.
    13      *      bool[] data:        the data array for the function. Can also be null to use BFP input or FP quickwatch.
    14      *      int switchInputs:   in normal behaviour this should be 0. In special case like CubeAttack-mode
    15      *                          one can switch between quickwatch column 1 and column 2. Therefor the switch is 1 or 2.
     12     *      bool[] dataOne:        the data array for the function. Can also be null to use BFP input or FP quickwatch.
     13     *      bool[] dataTwo:        the data array for the function. Can also be null to use BFP input or FP quickwatch.
    1614     *                         
    1715     *      Examples:
    18      *      SolveFunction("i_0.0 * i_0.1", bool[] myData = new bool[] {true, false}, 0);
    19      *      SolveFunction("i_1.0 * i_1.1", null, 0);
    20      *      SolveFunction("i_q.0 * i_q.1", bool[] myData = new bool[] {true, false}, 2);
    21      *      SolveFunction(null, null, 1);
    22      *      SolveFunction(null, null, 2);
     16     *      SolveFunction(null, null);
    2317     * **********************************/
    2418    public interface IControlSolveFunction : IControl
    2519    {
    26         int SolveFunction(string function, bool[] data, int switchInputs);
     20        int SolveFunction(bool[] dataOne, bool[] dataTwo);
    2721    }
    2822}
  • trunk/CrypPlugins/LFSR/LFSRSettings.cs

    r651 r752  
    7373        private bool noQuickwatch = false;
    7474        [ContextMenu("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for a better performance.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Display Quickwatch?" })]
    75         [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for a better performance.", null, 3, false, DisplayLevel.Experienced, ControlType.CheckBox, "", null)]
     75        [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for a better performance.", null, 3, true, DisplayLevel.Experienced, ControlType.CheckBox, "", null)]
    7676        public bool NoQuickwatch
    7777        {
  • trunk/CrypPlugins/NLFSR/NLFSRSettings.cs

    r651 r752  
    7272        private bool noQuickwatch = false;
    7373        [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?" })]
    74         [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)]
     74        [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for better performance.", null, 1, true, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
    7575        public bool NoQuickwatch
    7676        {
  • trunk/CrypPlugins/Trivium/Trivium.cs

    r734 r752  
    714714
    715715        // here comes the slave side implementation
    716         public int GenerateTriviumKeystream(int[] IV, int[] key, int length, int rounds, bool byteSwapping)
     716        public int GenerateTriviumKeystream(int[] IV, int[] key, int length, bool byteSwapping)
    717717        {
    718718            string resultString;
     
    727727            }
    728728           
    729             plugin.masterSlaveRounds = rounds;
     729            //plugin.masterSlaveRounds = rounds;
     730            plugin.masterSlaveRounds = ((TriviumSettings)plugin.Settings).InitRounds;
    730731            plugin.initTrivium(IV, key);
    731732
  • trunk/CrypPlugins/TriviumController/IControlTrivium.cs

    r617 r752  
    1010    public interface IControlTrivium : IControl
    1111    {
    12         int GenerateTriviumKeystream(int[] IV, int[] key, int length, int rounds, bool byteSwapping);
     12        int GenerateTriviumKeystream(int[] IV, int[] key, int length, bool byteSwapping);
    1313    }
    1414}
Note: See TracChangeset for help on using the changeset viewer.