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(); } } }
public SigGenBleichenbControl() { InitializeComponent(); RsaKey.Instance.RaiseKeyGeneratedEvent += handleCustomEvent; // listen Datablock.getInstance().RaiseParamChangedEvent += handleCustomEvent; this.handleCustomEvent(ParameterChangeType.RsaKey); this.loadComboDataBlocPos(24); }
// 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; }
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(); } }
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; }
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; }
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; }
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); }