source: trunk/CrypPlugins/PKCS1/WpfControls/Components/SigGenBleichenbControl.xaml.cs @ 1889

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

bugfix

File size: 3.8 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;
15using PKCS1.Resources.lang.Gui;
16
17namespace PKCS1.WpfControls.Components
18{
19    /// <summary>
20    /// Interaktionslogik für SigGenBleichenbControl.xaml
21    /// </summary>
22    public partial class SigGenBleichenbControl : UserControl
23    {
24        private BleichenbacherSig m_BleichSignature = new BleichenbacherSig();
25
26        public SigGenBleichenbControl()
27        {
28            InitializeComponent();
29            RsaKey.Instance.RaiseKeyGeneratedEvent += handleCustomEvent; // listen
30            Datablock.getInstance().RaiseParamChangedEvent += handleCustomEvent;
31            this.handleCustomEvent(ParameterChangeType.RsaKey);
32            this.loadComboDataBlocPos(24);
33        }
34
35        private void handleCustomEvent(ParameterChangeType type)
36        {           
37            this.lblPublicKeyRes.Content = RsaKey.Instance.PubExponent.ToString();
38            this.lblRsaKeySizeRes.Content = RsaKey.Instance.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 = (BleichenbacherSig) SignatureHandler.getInstance().getBleichenbSig();
47            this.m_BleichSignature.DataBlockStartPos = (int)this.cbPosDataBlock.SelectedValue;
48            this.m_BleichSignature.ChangeSign = this.tbChangeSign.Text;
49
50            this.m_BleichSignature.GenerateSignature();
51            UserControlHelper.loadRtbColoredSig(this.rtbResult, this.m_BleichSignature.GetSignatureDecToHexString());
52            this.tbResultEncrypted.Text = this.m_BleichSignature.GetSignatureToHexString();
53
54            SignatureHandler.getInstance().setBleichenBSig(this.m_BleichSignature);
55            Cursor = Cursors.Arrow;
56        }
57
58        private void loadComboDataBlocPos(int start)
59        {
60            this.cbPosDataBlock.Items.Clear();
61
62            int lengthDatablock = Datablock.getInstance().HashFunctionIdent.DERIdent.Length * 4 + Datablock.getInstance().HashFunctionIdent.digestLength + 8;
63            int end = RsaKey.Instance.RsaKeySize - lengthDatablock - start;
64
65            for( int i=start; i<= end; i+=8)
66            {
67                this.cbPosDataBlock.Items.Add(i);
68
69            }
70            this.cbPosDataBlock.SelectedIndex = (end-start)/10;
71        }
72
73        private void rtbResult_TextChanged(object sender, TextChangedEventArgs e)
74        {
75            this.lblSignatureLength.Content = "(" + Common.length  +": " + UserControlHelper.GetRtbTextLength(this.rtbResult) * 4 + " " + Common.bit + ")";
76        }
77
78        private void tbResultEncrypted_TextChanged(object sender, TextChangedEventArgs e)
79        {
80            this.lblEncryptedSignatureLength.Content = "(" + Common.length + ": " + this.tbResultEncrypted.Text.Length * 4 + " " + Common.bit + ")";
81        }
82
83        private void btn_Help_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
84        {
85            if (sender == btnHelpChangeSign)
86            {
87                OnlineHelp.OnlineHelpAccess.ShowOnlineHelp(PKCS1.OnlineHelp.OnlineHelpActions.Gen_Bleichenb_ChangeSign);
88            }
89            else if (sender == btnHelpBitPos)
90            {
91                OnlineHelp.OnlineHelpAccess.ShowOnlineHelp(PKCS1.OnlineHelp.OnlineHelpActions.Gen_Bleichenb_BitPos);
92            }
93            e.Handled = true;
94        }
95    }
96}
Note: See TracBrowser for help on using the repository browser.