Exemplo n.º 1
0
        public void Execute()
        {
            if (InputStream != null)
            {
                using (CStreamReader reader = InputStream.CreateReader())
                {
                    reader.WaitEof();
                    if (reader.Length > settings.MaxLength)
                    {
                        ShowStatusBarMessage("WARNING - Input stream is too large (" + (reader.Length / 1024).ToString("0.00") + " kB), output will be truncated to " + (settings.MaxLength / 1024).ToString("0.00") + "kB", NotificationLevel.Warning);
                    }

                    byte[] buffer = new byte[Math.Min(reader.Length, settings.MaxLength)];
                    reader.Seek(0, SeekOrigin.Begin);
                    reader.Read(buffer, 0, buffer.Length);

                    processInput(buffer);
                }
            }
            else if (InputBytes != null)
            {
                processInput(InputBytes);
            }
            else
            {
                ShowStatusBarMessage("Inputs are null. Nothing to convert.", NotificationLevel.Warning);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called every time this plugin is run in the workflow execution.
        /// </summary>
        public void Execute()
        {
            // The following variables follow the same naming convention used in the
            // specification:
            //     l: length of each message block, in bits.
            //     t: number of blocks the whole message uses.
            //     T: total number of blocks.
            //     N: number of bits in the input message.
            //     w: number of zeroes for padding.
            int   l = bufferSize * 8;
            ulong t = 0;
            ulong T = 0;
            ulong N = 0;
            ulong w = 0;

            byte[] h = new byte[bufferSize];
            System.Array.Copy(IV, h, bufferSize);
            ProgressChanged(0, 1);
            using (CStreamReader reader = InputStream.CreateReader())
            {
                int    bytesRead;
                byte[] buffer = new byte[bufferSize];

                while ((bytesRead = reader.ReadFully(buffer)) == bufferSize)
                {
                    N = N + (ulong)bytesRead * 8;
                    h = Compression(h, buffer);
                    t = t + 1;
                }
                ProgressChanged(0.8, 1);
                N = N + (ulong)bytesRead * 8;
                w = (ulong)((((-(long)N - 65) % l) + l) % l);
                T = (N + w + 65) / (ulong)l;
                int blocksLeft = (int)(T - t);
                buffer[bytesRead] = 0x80;
                int    numberOfZeroBytes = bufferSize - bytesRead - 1;
                byte[] zeroes            = new byte[numberOfZeroBytes];
                System.Array.Copy(zeroes, 0, buffer, bytesRead + 1, numberOfZeroBytes);
                for (uint i = 0; i < blocksLeft; i++)
                {
                    if (i == blocksLeft - 1)
                    {
                        byte[] bytes = System.BitConverter.GetBytes((ulong)T);
                        if (System.BitConverter.IsLittleEndian)
                        {
                            System.Array.Reverse(bytes);
                        }
                        System.Array.Copy(bytes, 0, buffer, bufferSize - 8, 8);
                    }
                    h      = Compression(h, buffer);
                    buffer = new byte[bufferSize];
                }
                h          = Truncation(XOR(P(h), h));
                OutputData = h;
            }
            ProgressChanged(1, 1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called every time this plugin is run in the workflow execution.
        /// </summary>
        public void Execute()
        {
            ProgressChanged(0, 1);

            try
            {
                inputStreamReader = InputStream.CreateReader();
                //inputStreamReader.WaitEof();
                if (!ValidateInputs())
                {
                    return;     // beende die Ausführung bei Problemen mit den Eingabedaten
                }
                debugDataWriter = new CStreamWriter();

                if (settings.Debug)
                {
                    WriteDebug("Starting computation ...\r\n\r\n");
                    WriteDebug(String.Format("mode: {0}\r\n", settings.HashMode));
                    if (settings.HashMode != CypherMatrixHashSettings.CypherMatrixHashMode.Mini)
                    {
                        WriteDebug(String.Format("permutation: {0}\r\n", settings.Perm));
                    }
                    else
                    {
                        WriteDebug("permutation: none\r\n");
                    }
                    WriteDebug("\r\n\r\n");
                }

                Stopwatch sw = new Stopwatch();
                sw.Start();

                Hash();

                sw.Stop();
                if (!stop)
                {
                    GuiLogMessage(string.Format("Processed {0:N} KiB data in {1} ms.", (double)InputStream.Length / 1024, sw.ElapsedMilliseconds), NotificationLevel.Info);
                    GuiLogMessage(string.Format("Achieved data throughput: {0:N} kB/s", (double)InputStream.Length / sw.ElapsedMilliseconds), NotificationLevel.Info);
                }
            }
            catch (Exception exception)
            {
                GuiLogMessage(exception.Message + "\r\n" + exception.StackTrace, NotificationLevel.Error);
                if (settings.Debug)
                {
                    WriteDebug("\r\nThe following error occurred during execution:\r\n");
                    WriteDebug(exception.Message + "\r\n" + exception.StackTrace + "\r\n");
                }
            }
            finally
            {
                if (stop)
                {
                    GuiLogMessage("Computation aborted!", NotificationLevel.Warning);
                    stop = false;
                }
                if (settings.Debug)
                {
                    WriteDebug("\r\n>>>>>>>>>> END OF OPERATION <<<<<<<<<<");
                }
                else
                {
                    WriteDebug("You have to enable the debug logging to see the internal variables here.");
                }

                debugDataWriter.Flush();
                debugDataWriter.Close();
                OnPropertyChanged("OutputDebug");
            }

            ProgressChanged(1, 1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called every time this plugin is run in the workflow execution.
        /// </summary>
        public void Execute()
        {
            ProgressChanged(0, 100);

            #region lokale variablen

            const int BUFFERSIZE = 524288;
            int       exitcode   = -1;

            string path      = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string solverExe = settings.solverExe[(int)settings.SatString];

            //GuiLogMessage(path + "\\" + solverExe, NotificationLevel.Debug);

            outputResultStream = new CStreamWriter();
            inputStream        = InputStream.CreateReader();
            BinaryWriter bw;

            if (settings.ClearOutputHandling == 0)
            {
                outputConsoleString = null; // delete output from last execution
                outputConsoleString = new StringBuilder();
            }
            else
            {
                outputConsoleString.AppendLine();
                outputConsoleString.AppendLine();
            }

            #endregion

            try
            {
                //GuiLogMessage("Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) " + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), NotificationLevel.Debug); // right
                //GuiLogMessage("Environment.CurrentDirectory " + path, NotificationLevel.Debug); // wrong

                // read from input stream and save as temporary file (which will later be passed to the SAT Solver)
                int    bytesRead = 0;
                byte[] bytes     = new byte[BUFFERSIZE];

                using (bw = new BinaryWriter(File.Open(tempCnfFilename, FileMode.Create)))
                {
                    while ((bytesRead = inputStream.ReadFully(bytes)) > 0)
                    {
                        bw.Write(bytes, 0, bytesRead);
                    }
                }

                // build argument string
                string args = buildArgs();

                solverProcess = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName               = path + "\\" + solverExe,
                        Arguments              = args,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true,
                        RedirectStandardInput  = true,
                    }
                };


                // DEBUG print args

                /*
                 * string debug_args = "";
                 * if (args.Contains("-"))
                 * {
                 *  debug_args = args.Substring(args.IndexOf("-"), args.Length - args.IndexOf("-"));
                 * }
                 * outputConsoleString.AppendLine("Arguments: " + debug_args);
                 * outputConsoleStream = new CStreamWriter();
                 * outputConsoleStream.Write(encoding.GetBytes(outputConsoleString.ToString()));
                 * outputConsoleStream.Close();
                 * OnPropertyChanged("OutputConsoleStream");
                 */

                // attach event handler for process' data output
                solverProcess.OutputDataReceived += new DataReceivedEventHandler(ReadProcessOutput);

                solverProcess.Start();
                ProgressChanged(1, 100);

                // begin asynchronous read
                solverProcess.BeginOutputReadLine();
                solverProcess.WaitForExit();
                exitcode = solverProcess.ExitCode;

                // action depends on exitcode and used solver (error handling / result output)
                if (exitcode != -1)
                {
                    exitcodeHandling(exitcode);
                }
                else
                {
                    GuiLogMessage("Solver returned without exitcode!", NotificationLevel.Warning);
                }

                outputResultStream.Close();
                OnPropertyChanged("OutputResultStream");
            }
            catch (Exception exception)
            {
                GuiLogMessage(exception.Message + "\r\n" + exception.StackTrace, NotificationLevel.Error);
            }
            finally
            {
                File.Delete(outputResultFilename);
                File.Delete(tempCnfFilename);
            }
            ProgressChanged(100, 100);
        }
Exemplo n.º 5
0
        public void Execute()
        {
            int keysize;

            switch (_settings.Keysize)
            {
            case 1:
                keysize = 24;
                break;

            case 2:
                keysize = 32;
                break;

            default:
                keysize = 16;
                break;
            }

            if (InputKey.Length != keysize)
            {
                GuiLogMessage(String.Format("Wrong keysize given. Keysize was {0} Bits but needed is {1} Bits.", InputKey.Length * 8, keysize * 8), NotificationLevel.Error);
                return;
            }

            if (InputIV == null)
            {
                if (_settings.Mode > 0)
                {
                    GuiLogMessage("NOTE: No IV provided. Using 0x000..00!", NotificationLevel.Info);
                }
                InputIV = new byte[16];
            }

            if (InputIV.Length < 16 && _settings.Mode > 0)
            {
                GuiLogMessage(String.Format("NOTE: Wrong IV size given. IV size was {0} Bits but needed is 128 Bits. Appending with zeros.", InputIV.Length * 8), NotificationLevel.Info);
                var newIV = new byte[16];
                Array.Copy(InputIV, 0, newIV, 0, InputIV.Length);
                InputIV = newIV;
            }
            else if (InputIV.Length > 16 && _settings.Mode > 0)
            {
                GuiLogMessage(String.Format("NOTE: Wrong IV size given. IV size was {0} Bits but needed is 128 Bits. Removing bytes from position 15.", InputIV.Length * 8), NotificationLevel.Info);
                var newIV = new byte[16];
                Array.Copy(InputIV, 0, newIV, 0, 16);
                InputIV = newIV;
            }

            var keyParameter       = new KeyParameter(InputKey);
            var engine             = new CamelliaEngine();
            var keyParameterWithIv = new ParametersWithIV(keyParameter, InputIV);

            BufferedBlockCipher cipher;

            switch (_settings.Mode)
            {
            case 1:
                cipher = new BufferedBlockCipher(new CbcBlockCipher(engine));
                break;

            case 2:
                cipher = new BufferedBlockCipher(new CfbBlockCipher(engine, 128));
                break;

            case 3:
                cipher = new BufferedBlockCipher(new OfbBlockCipher(engine, 128));
                break;

            default:
                cipher = new BufferedBlockCipher(engine);
                break;
            }

            if (_settings.Mode > 0)
            {
                cipher.Init(_settings.Action == 0, keyParameterWithIv);
            }
            else
            {
                cipher.Init(_settings.Action == 0, keyParameter);
            }

            //Add padding
            if (_settings.Action == 0 && _settings.Padding > 0)
            {
                var paddingType = BlockCipherHelper.PaddingType.None;
                switch (_settings.Padding)
                {
                case 1:
                    paddingType = BlockCipherHelper.PaddingType.Zeros;
                    break;

                case 2:
                    paddingType = BlockCipherHelper.PaddingType.PKCS7;
                    break;

                case 3:
                    paddingType = BlockCipherHelper.PaddingType.ANSIX923;
                    break;

                case 4:
                    paddingType = BlockCipherHelper.PaddingType.ISO10126;
                    break;

                case 5:
                    paddingType = BlockCipherHelper.PaddingType.OneZeros;
                    break;
                }
                InputStream = BlockCipherHelper.AppendPadding(InputStream, paddingType, 16);
            }

            var inputText  = InputStream.CreateReader().ReadFully();
            var outputText = new byte[cipher.GetOutputSize(inputText.Length)];
            var outputLen  = cipher.ProcessBytes(inputText, 0, inputText.Length, outputText, 0);

            cipher.DoFinal(outputText, outputLen);
            OutputStream = new CStreamWriter();

            int offset = outputText.Length;

            //Remove the padding from the output
            if (_settings.Action == 1 && _settings.Padding > 0)
            {
                var paddingType = BlockCipherHelper.PaddingType.None;
                switch (_settings.Padding)
                {
                case 1:
                    paddingType = BlockCipherHelper.PaddingType.Zeros;
                    break;

                case 2:
                    paddingType = BlockCipherHelper.PaddingType.PKCS7;
                    break;

                case 3:
                    paddingType = BlockCipherHelper.PaddingType.ANSIX923;
                    break;

                case 4:
                    paddingType = BlockCipherHelper.PaddingType.ISO10126;
                    break;

                case 5:
                    paddingType = BlockCipherHelper.PaddingType.OneZeros;
                    break;
                }
                offset = BlockCipherHelper.StripPadding(outputText, outputText.Length - outputText.Length % 16, paddingType, outputText.Length);
            }

            //Output encrypted or decrypted text
            ((CStreamWriter)OutputStream).Write(outputText, 0, offset);
            ((CStreamWriter)OutputStream).Close();
            OnPropertyChanged("OutputStream");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Called every time this plugin is run in the workflow execution.
        /// </summary>
        public void Execute()
        {
            ulong dataBitLength  = 0;
            int   blockBitLength = bufferSize * 8;
            ulong n = 0;

            byte[] hash;

            ProgressChanged(0, 1);

            // Used when the BLAKE function is either BLAKE-224 or BLAKE-256.
            uint[] h32 = new uint[8];
            System.Array.Copy(IV32BitWords, h32, 8);
            uint[] m32 = new uint[16];
            uint[] s32 = new uint[4] {
                0, 0, 0, 0
            };
            uint[] t32;

            // Used when the BLAKE function is either BLAKE-384 or BLAKE-512.
            ulong[] h64 = new ulong[8];
            System.Array.Copy(IV64BitWords, h64, 8);
            ulong[] m64 = new ulong[16];
            ulong[] s64 = new ulong[4] {
                0, 0, 0, 0
            };
            ulong[] t64;

            switch (CheckSalt(SaltData))
            {
            case 0:
                // Nothing connected to InputSalt connector. Use default value for salt.
                break;

            case 1:
                // Salt size is different from the one required for BLAKE-224 and BLAKE-256.
                GuiLogMessage(string.Format("ERROR: Wrong salt size. Salt size must be {0} bytes", 16), NotificationLevel.Error);
                return;

            case 2:
                // Salt size is different from the one required for BLAKE-384 and BLAKE-512.
                GuiLogMessage(string.Format("ERROR: Wrong salt size. Salt size must be {0} bytes", 32), NotificationLevel.Error);
                return;

            default:
                // Salt size is correct. Fill the right salt variable depending on the BLAKE function selected.
                if (settings.SelectedFunction == (int)BLAKEFunction.BLAKE224 ||
                    settings.SelectedFunction == (int)BLAKEFunction.BLAKE256)
                {
                    s32 = BytesToUint32Block(SaltData);
                }
                else
                {
                    s64 = BytesToUint64Block(SaltData);
                }
                break;
            }

            using (CStreamReader reader = InputStream.CreateReader())
            {
                int    bytesRead;
                byte[] buffer = new byte[bufferSize];
                while ((bytesRead = reader.ReadFully(buffer)) == bufferSize)
                {
                    dataBitLength = dataBitLength + (ulong)bytesRead * 8;
                    if (settings.SelectedFunction == (int)BLAKEFunction.BLAKE224 ||
                        settings.SelectedFunction == (int)BLAKEFunction.BLAKE256)
                    {
                        m32 = BytesToUint32Block(buffer);
                        t32 = LengthToUint32Words(dataBitLength);
                        Compress32(h32, m32, s32, t32);
                    }
                    else
                    {
                        m64 = BytesToUint64Block(buffer);
                        t64 = LengthToUint64Words(dataBitLength);
                        Compress64(h64, m64, s64, t64);
                    }
                    n = n + 1;
                }
                ProgressChanged(0.8, 1);
                dataBitLength = dataBitLength + (ulong)bytesRead * 8;
                ulong numberOfZeroBits = (ulong)((((-(long)dataBitLength - (finalBytes * 8 + 1)) % blockBitLength) + blockBitLength) % blockBitLength);
                ulong N          = (dataBitLength + numberOfZeroBits + ((ulong)finalBytes * 8 + 1)) / (ulong)blockBitLength;
                int   blocksLeft = (int)(N - n);
                buffer[bytesRead] = 0x80;
                int    numberOfZeroBytes = bufferSize - bytesRead - 1;
                byte[] zeroes            = new byte[numberOfZeroBytes];
                System.Array.Copy(zeroes, 0, buffer, bytesRead + 1, numberOfZeroBytes);
                for (int i = 0; i < blocksLeft; i++)
                {
                    if (i == blocksLeft - 1)
                    {
                        byte[] length = System.BitConverter.GetBytes((ulong)dataBitLength);
                        if (System.BitConverter.IsLittleEndian)
                        {
                            System.Array.Reverse(length);
                        }
                        System.Array.Copy(length, 0, buffer, bufferSize - 8, 8);
                        buffer[bufferSize - finalBytes - 1] ^= paddingBit;
                        if (blocksLeft == 2 || (blocksLeft == 1 && bytesRead == 0))
                        {
                            dataBitLength = 0;
                        }
                    }
                    if (settings.SelectedFunction == (int)BLAKEFunction.BLAKE224 ||
                        settings.SelectedFunction == (int)BLAKEFunction.BLAKE256)
                    {
                        m32 = BytesToUint32Block(buffer);
                        t32 = LengthToUint32Words(dataBitLength);
                        Compress32(h32, m32, s32, t32);
                    }
                    else
                    {
                        m64 = BytesToUint64Block(buffer);
                        t64 = LengthToUint64Words(dataBitLength);
                        Compress64(h64, m64, s64, t64);
                    }
                    buffer = new byte[bufferSize];
                }
                if (settings.SelectedFunction == (int)BLAKEFunction.BLAKE224 ||
                    settings.SelectedFunction == (int)BLAKEFunction.BLAKE256)
                {
                    hash = Uint32BlockToBytes(h32);
                }
                else
                {
                    hash = Uint64BlockToBytes(h64);
                }
                if (settings.SelectedFunction == (int)BLAKEFunction.BLAKE224)
                {
                    System.Array.Resize(ref hash, 28);
                }
                if (settings.SelectedFunction == (int)BLAKEFunction.BLAKE384)
                {
                    System.Array.Resize(ref hash, 48);
                }
                OutputData = hash;
            }
            ProgressChanged(1, 1);
        }
Exemplo n.º 7
0
        public void Execute()
        {
            /* do not execute if checks in PreExecution() failed */
            if (!execute)
            {
                return;
            }

            ProgressChanged(0, 1);

            byte[] input, output;
            int    outputLength, rate, capacity;

            /* setup output stream writer */
            CStreamWriter OutputStreamwriter = new CStreamWriter();

            OutputStream = OutputStreamwriter;
            OnPropertyChanged("OutputStream");

            #if _DEBUG_
            /* setup debug stream writer */
            TextWriter    consoleOut        = Console.Out; // save the standard output
            CStreamWriter debugStream       = new CStreamWriter();
            StreamWriter  debugStreamWriter = new StreamWriter(debugStream);
            debugStreamWriter.AutoFlush = true;     // flush stream every time WriteLine is called
            Console.SetOut(debugStreamWriter);
            DebugStream = debugStream;
            OnPropertyChanged("DebugStream");
            #endif

            #region get input

            /* read input */
            using (CStreamReader reader = InputStream.CreateReader())
            {
                int    bytesRead;
                byte[] buffer = new byte[128];      // buffer of length 128 byte

                MemoryStream stream = new MemoryStream();
                BinaryWriter bw     = new BinaryWriter(stream);

                while ((bytesRead = reader.Read(buffer)) > 0)
                {
                    bw.Write(buffer, 0, bytesRead);
                }

                bw.Close();
                input = stream.ToArray();
                OnPropertyChanged("OutputStream");
            }

            #endregion

            outputLength = settings.OutputLength;
            rate         = settings.Rate;
            capacity     = settings.Capacity;

            /* show presentation intro */
            #region presentation intro

            if (pres.IsVisible)
            {
                /* clean up last round */
                pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                {
                    pres.absorbGrid.Visibility                            = Visibility.Hidden;
                    pres.imgBlankPage.Visibility                          = Visibility.Hidden;
                    pres.labelOutput.Visibility                           = Visibility.Hidden;
                    pres.textBlockStateBeforeAbsorb.Text                  = "";
                    pres.textBlockBlockToAbsorb.Text                      = "";
                    pres.textBlockStateAfterAbsorb.Text                   = "";
                    pres.labelCurrentPhase.Content                        = "";
                    pres.labelCurrentStep.Content                         = "";
                    pres.textBlockExplanation.Text                        = "";
                    pres.textBlockParametersNotSupported.Visibility       = Visibility.Hidden;
                    pres.textBlockParametersNotSupported.Text             = "";
                    pres.textBlockStepPresentationNotAvailable.Visibility = Visibility.Hidden;
                    pres.textBlockStepPresentationNotAvailable.Text       = "";

                    pres.buttonNext.IsEnabled            = true;
                    pres.buttonSkip.IsEnabled            = false;
                    pres.buttonAutostep.IsEnabled        = false;
                    pres.buttonSkipPermutation.IsEnabled = false;
                    pres.autostepSpeedSlider.IsEnabled   = false;
                    pres.spButtons.Visibility            = Visibility.Visible;
                    pres.buttonSkipIntro.Visibility      = Visibility.Visible;

                    pres.imgIntroFirstPage.Visibility = Visibility.Visible;
                }, null);

                AutoResetEvent buttonNextClickedEvent = pres.buttonNextClickedEvent;

                #region check if selected parameters are supported
                if (outputLength > rate)
                {
                    pres.skipPresentation = true;

                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.imgIntroFirstPage.Visibility = Visibility.Hidden;

                        pres.textBlockParametersNotSupported.Text       = Resources.PresOutputLengthError;
                        pres.textBlockParametersNotSupported.Visibility = Visibility.Visible;
                    }, null);
                }
                else if (rate + capacity < 200)
                {
                    pres.skipPresentation = true;

                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.imgIntroFirstPage.Visibility = Visibility.Hidden;

                        pres.textBlockParametersNotSupported.Text       = Resources.PresStateSizeError;
                        pres.textBlockParametersNotSupported.Visibility = Visibility.Visible;
                    }, null);
                }
                #endregion

                if (!pres.skipPresentation)
                {
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.imgIntroFirstPage.Visibility      = Visibility.Hidden;
                        pres.labelIntroIntroduction.Visibility = Visibility.Visible;
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelCurrentPhase.Content = Resources.PresIntroduction;
                        pres.labelCurrentStep.Content  = Resources.PresInitialization;

                        pres.textBlockIntroduction.Text = string.Format(Resources.PresInitializationText, (rate + capacity), capacity, rate);

                        pres.labelIntroIntroduction.Visibility = Visibility.Hidden;
                        pres.imgIntroSpongeInit.Visibility     = Visibility.Visible;
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelCurrentStep.Content = Resources.PresAbsorbingPhase;

                        pres.textBlockIntroduction.Text =
                            string.Format(Resources.PresAbsorbingPhaseText, rate);

                        pres.imgIntroSpongeInit.Visibility   = Visibility.Hidden;
                        pres.imgIntroSpongeAbsorb.Visibility = Visibility.Visible;
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelCurrentStep.Content   = Resources.PresSqueezingPhase;
                        pres.textBlockIntroduction.Text = Resources.PresSqueezingPhaseText;

                        pres.imgIntroSpongeAbsorb.Visibility  = Visibility.Hidden;
                        pres.imgIntroSpongeSqueeze.Visibility = Visibility.Visible;
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    /* calculate l parameter */
                    int l = (int)Math.Log((double)((rate + capacity) / 25), 2);

                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelCurrentStep.Content          = Resources.PresKeccakFPhase;
                        pres.textBlockIntroduction.Text        = string.Format(Resources.PresKeccakFPhaseText, l, (12 + 2 * l));
                        pres.labelIntroIterationAmount.Content = string.Format(Resources.PresKeccakFIterations, (12 + 2 * l));

                        pres.imgIntroSpongeSqueeze.Visibility  = Visibility.Hidden;
                        pres.imgIntroSpongeKeccakf2.Visibility = Visibility.Visible;
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelIntroIterationAmount.Content = "";
                        pres.imgIntroSpongeKeccakf2.Visibility = Visibility.Hidden;
                        pres.imgIntroStateMapping.Visibility   = Visibility.Visible;
                        pres.textBlockIntroduction.Text        = string.Format(Resources.PresKeccakFStateMapping, (capacity + rate), (capacity + rate) / 25);
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.buttonSkipIntro.Visibility      = Visibility.Hidden;
                        pres.imgIntroStateMapping.Visibility = Visibility.Hidden;
                        pres.labelIntroExecution.Visibility  = Visibility.Visible;
                        pres.textBlockIntroduction.Text      = "";
                        pres.labelCurrentPhase.Content       = "";
                        pres.labelCurrentStep.Content        = "";
                    }, null);

                    buttonNextClickedEvent = pres.buttonNextClickedEvent;
                    buttonNextClickedEvent.WaitOne();
                }

                if (!pres.skipPresentation && !pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelIntroExecution.Visibility = Visibility.Hidden;
                    }, null);
                }

                if (pres.skipPresentation || pres.skipIntro)
                {
                    pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                    {
                        pres.labelIntroIterationAmount.Content = "";
                        pres.imgIntroFirstPage.Visibility      = Visibility.Hidden;
                        pres.imgIntroIntroduction.Visibility   = Visibility.Hidden;
                        pres.imgIntroSpongeInit.Visibility     = Visibility.Hidden;
                        pres.imgIntroSpongeAbsorb.Visibility   = Visibility.Hidden;
                        pres.imgIntroSpongeSqueeze.Visibility  = Visibility.Hidden;
                        pres.imgIntroSpongeKeccakf2.Visibility = Visibility.Hidden;
                        pres.imgIntroStateMapping.Visibility   = Visibility.Hidden;
                        pres.imgIntroExecution.Visibility      = Visibility.Hidden;
                        pres.buttonSkipIntro.Visibility        = Visibility.Hidden;
                        pres.labelIntroIntroduction.Visibility = Visibility.Hidden;
                        pres.labelIntroExecution.Visibility    = Visibility.Hidden;
                        pres.textBlockIntroduction.Text        = "";
                    }, null);
                }
            }

            #endregion

            /* hash input */
            output = KeccakHashFunction.Hash(input, outputLength, rate, capacity, ref pres, this);

            /* write output */
            OutputStreamwriter.Write(output);
            OutputStreamwriter.Close();

            #if _DEBUG_
            /* close debug stream and reset standard output */
            debugStreamWriter.Close();
            Console.SetOut(consoleOut);
            #endif

            /* hide button panel */
            if (pres.IsVisible)
            {
                pres.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                {
                    pres.spButtons.Visibility = Visibility.Hidden;
                }, null);
            }

            ProgressChanged(1, 1);
        }