Пример #1
0
 private void bValidate_Click(object sender, RoutedEventArgs e)
 {
     if (this.m_bValidateCorrect == true)
     {
         if (this.validator.verifyRsaSignature(Datablock.getInstance().Message, signature.GetSignature()))
         {
             this.ResultValid();
         }
         else
         {
             this.ResultNotValid();
         }
     }
     else if (this.m_bValidateCorrect == false)
     {
         if (this.validator.verifyRsaSignatureWithFlaw(Datablock.getInstance().Message, signature.GetSignature()))
         {
             this.ResultValid();
         }
         else
         {
             this.ResultNotValid();
         }
     }
 }
Пример #2
0
 public SigGenBleichenbControl()
 {
     InitializeComponent();
     RsaKey.Instance.RaiseKeyGeneratedEvent += handleCustomEvent; // listen
     Datablock.getInstance().RaiseParamChangedEvent += handleCustomEvent;
     this.handleCustomEvent(ParameterChangeType.RsaKey);
     this.loadComboDataBlocPos(24);
 }
Пример #3
0
        // fired when Checkbox Selection changed
        // Hashfunction IdentificationTextbox filled & selected Hashfunction is set
        private void cbHashFunc_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Datablock.getInstance().HashFunctionIdent = (HashFunctionIdent)this.cbHashFunc.SelectedValue;
            this.tbHashIdent.Text = Datablock.getInstance().HashFunctionIdent.DERIdent;

            // HashDigest Textboxen leeren; werden bei Execute befüllt
            this.tbHashDigest.Text           = String.Empty;
            this.lblHashDigestLength.Content = String.Empty;
        }
Пример #4
0
 private void handleParamChanged(ParameterChangeType type)
 {
     if (ParameterChangeType.Message == type)
     {
         if (true == this.tbInputText.IsEnabled)
         {
             this.tbInputText.Text = Encoding.ASCII.GetString(Datablock.getInstance().Message);
         }
         this.tbHashDigest.Text = Datablock.getInstance().GetHashDigestToHexString();
     }
 }
Пример #5
0
        private void loadComboDataBlocPos(int start)
        {
            this.cbPosDataBlock.Items.Clear();

            int lengthDatablock = Datablock.getInstance().HashFunctionIdent.DERIdent.Length * 4 + Datablock.getInstance().HashFunctionIdent.digestLength + 8;
            int end             = RsaKey.Instance.RsaKeySize - lengthDatablock - start;

            for (int i = start; i <= end; i += 8)
            {
                this.cbPosDataBlock.Items.Add(i);
            }
            this.cbPosDataBlock.SelectedIndex = (end - start) / 10;
        }
Пример #6
0
        public void Initialize()
        {
            // ComboBox befüllen
            this.cbHashFunc.Items.Add(HashFuncIdentHandler.SHA1);
            this.cbHashFunc.Items.Add(HashFuncIdentHandler.SHA256);
            this.cbHashFunc.Items.Add(HashFuncIdentHandler.SHA384);
            this.cbHashFunc.Items.Add(HashFuncIdentHandler.SHA512);
            this.cbHashFunc.Items.Add(HashFuncIdentHandler.MD2);
            this.cbHashFunc.Items.Add(HashFuncIdentHandler.MD5);
            this.cbHashFunc.SelectedIndex = 0;

            this.rbTextFromBox.IsChecked = true;

            Datablock.getInstance().RaiseParamChangedEvent += handleParamChanged;
        }
Пример #7
0
        public static void loadRtbColoredSig(RichTextBox richTB, string decryptedSig)
        {
            FlowDocument flowDoc = new FlowDocument();
            Paragraph    para    = new Paragraph();
            Run          run     = new Run(decryptedSig);

            para.Inlines.Add(run);

            int paddingEnd = decryptedSig.IndexOf("ff0030"); // Ende des Padding
            int identEnd   = paddingEnd + 10 + Datablock.getInstance().HashFunctionIdent.DERIdent.Length;
            int digestEnd  = identEnd + 2 + (Datablock.getInstance().HashFunctionIdent.digestLength / 4);

            TextRange rangePadding = UserControlHelper.GenTextRange(run, 4, paddingEnd + 2, Colors.Green);
            TextRange rangeIdent   = UserControlHelper.GenTextRange(run, paddingEnd + 8, identEnd, Colors.Blue);
            TextRange rangeDigest  = UserControlHelper.GenTextRange(run, identEnd, digestEnd, Colors.Red);

            flowDoc.Blocks.Add(para);
            richTB.Document = flowDoc;
        }
Пример #8
0
        private void bGenerate_Click(object sender, RoutedEventArgs e)
        {
            byte[] byteToHash;

            if (this.rbTextFromBox.IsChecked == true)
            {
                byteToHash = Encoding.ASCII.GetBytes(this.tbInputText.Text);
            }
            else if (this.rbTextfromFile.IsChecked == true)
            {
                FileStream fs = new FileStream(this.fileName, FileMode.Open, FileAccess.Read);
                byteToHash = new byte[fs.Length];
                fs.Read(byteToHash, 0, System.Convert.ToInt32(fs.Length));
                fs.Close();
            }
            else
            {
                byteToHash = Encoding.ASCII.GetBytes("Error!");
            }

            // Text setzen, Hash wird automatisch generiert, da in Datablock das Event getriggert wird und hier im Handling Hashgenerierung auslöst
            Datablock.getInstance().Message = byteToHash;
            OnRaiseDataBlockGenerated(ParameterChangeType.DataBlock);
        }