source: trunk/PKCS1/WpfControls/Components/SigGenControl.xaml.cs @ 1650

Last change on this file since 1650 was 1650, checked in by schomburg, 11 years ago

initial commit of PKCS1 Plugin

File size: 2.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using System.Windows.Controls;
7using System.Windows.Data;
8using System.Windows.Documents;
9using System.Windows.Input;
10using System.Windows.Media;
11using System.Windows.Media.Imaging;
12using System.Windows.Navigation;
13using System.Windows.Shapes;
14//using Cryptool.PluginBase.Miscellaneous;
15using PKCS1.Library;
16using Org.BouncyCastle.Math;
17
18namespace PKCS1.WpfControls.Components
19{
20    /// <summary>
21    /// Interaktionslogik für SigGenControl.xaml
22    /// </summary>
23    public partial class SigGenControl : UserControl
24    {
25        private RSASignature m_RSASignature;
26       
27        public SigGenControl()
28        {
29            InitializeComponent();
30            // zeile muss weg; Signatur muss sich bei RSAKeyManager anmelden
31            RSAKeyManager.getInstance().RaiseKeyGeneratedEvent += handleCustomEvent; // bei KeyGen-Listener anmelden
32            this.handleCustomEvent(ParameterChangeType.RsaKey);
33        }
34
35        private void handleCustomEvent(ParameterChangeType type)
36        {
37            //this.tbResult.Text = String.Empty;
38            this.tbResultEncrypted.Text = String.Empty;
39            this.lblPublicKeyRes.Content = RSAKeyManager.getInstance().PubExponent.ToString();
40            this.lblRsaKeySizeRes.Content = RSAKeyManager.getInstance().RsaKeySize.ToString();
41        }
42
43        private void bExecute_Click(object sender, RoutedEventArgs e)
44        {
45            this.m_RSASignature = (RSASignature) SignatureHandler.getInstance().getSignature();
46            this.m_RSASignature.GenerateSignature();
47            //this.tbResult.Text = this.m_RSASignature.GetSignatureDecToHexString();
48            UserControlHelper.loadRtbColoredSig(this.rtbResult, this.m_RSASignature.GetSignatureDecToHexString());
49            this.tbResultEncrypted.Text = this.m_RSASignature.GetSignatureToHexString();
50
51            // nur temp
52            SignatureHandler.getInstance().setSignature(this.m_RSASignature);
53        }
54
55        private void tbResultEncrypted_TextChanged(object sender, TextChangedEventArgs e)
56        {
57            this.lblEncryptedSignatureLength.Content = "(Länge: " + this.tbResultEncrypted.Text.Length * 4 + " bit)";
58        }
59
60        private void rtbResult_TextChanged(object sender, TextChangedEventArgs e)
61        {
62            this.lblSignatureLength.Content = "(Länge: " + UserControlHelper.GetRtbTextLength(this.rtbResult) * 4 + " bit)";
63        }
64    }
65}
Note: See TracBrowser for help on using the repository browser.