source: trunk/PKCS1/WpfControls/Components/SigGenBleichenbControl.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: 3.2 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;
14using PKCS1.Library;
15
16namespace PKCS1.WpfControls.Components
17{
18    /// <summary>
19    /// Interaktionslogik für SigGenBleichenbControl.xaml
20    /// </summary>
21    public partial class SigGenBleichenbControl : UserControl
22    {
23        private BleichenbacherSignature m_BleichSignature = new BleichenbacherSignature();
24        //private int DataBlockPos = 0;
25
26        public SigGenBleichenbControl()
27        {
28            InitializeComponent();
29            RSAKeyManager.getInstance().RaiseKeyGeneratedEvent += handleCustomEvent; // listen
30            this.handleCustomEvent(ParameterChangeType.RsaKey);
31            this.loadComboDataBlocPos(24);
32        }
33
34        private void handleCustomEvent(ParameterChangeType type)
35        {           
36
37            this.lblPublicKeyRes.Content = RSAKeyManager.getInstance().PubExponent.ToString();
38            this.lblRsaKeySizeRes.Content = RSAKeyManager.getInstance().RsaKeySize.ToString();           
39            this.loadComboDataBlocPos(24);
40        }
41
42        private void bExecute_Click(object sender, RoutedEventArgs e)
43        {
44            Cursor = Cursors.Wait;
45
46            this.m_BleichSignature = (BleichenbacherSignature) SignatureHandler.getInstance().getBleichenbSig();
47            this.m_BleichSignature.DataBlockStartPos = (int)this.cbPosDataBlock.SelectedValue;
48
49            this.m_BleichSignature.GenerateSignature();
50            UserControlHelper.loadRtbColoredSig(this.rtbResult, this.m_BleichSignature.GetSignatureDecToHexString());
51            this.tbResultEncrypted.Text = this.m_BleichSignature.GetSignatureToHexString();
52
53            SignatureHandler.getInstance().setBleichenBSig(this.m_BleichSignature);
54            Cursor = Cursors.Arrow;
55        }
56
57        private void loadComboDataBlocPos(int start)
58        {
59            this.cbPosDataBlock.Items.Clear();
60
61            int lengthDatablock = Datablock.getInstance().HashFunctionIdent.DERIdent.Length * 4 + Datablock.getInstance().HashFunctionIdent.digestLength + 8;
62            int end = RSAKeyManager.getInstance().RsaKeySize - lengthDatablock - start;
63
64            for( int i=start; i<= end; i+=8)
65            {
66                this.cbPosDataBlock.Items.Add(i);
67
68            }
69            this.cbPosDataBlock.SelectedIndex = (end-start)/10;
70        }
71
72        private void rtbResult_TextChanged(object sender, TextChangedEventArgs e)
73        {
74            this.lblSignatureLength.Content = "(Länge: " + UserControlHelper.GetRtbTextLength(this.rtbResult) * 4 + " bit)";
75        }
76
77        private void tbResultEncrypted_TextChanged(object sender, TextChangedEventArgs e)
78        {
79            this.lblEncryptedSignatureLength.Content = "(Länge: " + this.tbResultEncrypted.Text.Length * 4 + " bit)";
80        }
81
82        private void cbPosDataBlock_SelectionChanged(object sender, SelectionChangedEventArgs e)
83        {
84
85        }
86    }
87}
Note: See TracBrowser for help on using the repository browser.