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

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

corrected and completed helpfiles

File size: 3.7 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            this.handleCustomEvent(ParameterChangeType.RsaKey);
31            this.loadComboDataBlocPos(24);
32        }
33
34        private void handleCustomEvent(ParameterChangeType type)
35        {           
36            this.lblPublicKeyRes.Content = RsaKey.Instance.PubExponent.ToString();
37            this.lblRsaKeySizeRes.Content = RsaKey.Instance.RsaKeySize.ToString();           
38            this.loadComboDataBlocPos(24);
39        }
40
41        private void bExecute_Click(object sender, RoutedEventArgs e)
42        {
43            Cursor = Cursors.Wait;
44
45            this.m_BleichSignature = (BleichenbacherSig) SignatureHandler.getInstance().getBleichenbSig();
46            this.m_BleichSignature.DataBlockStartPos = (int)this.cbPosDataBlock.SelectedValue;
47            this.m_BleichSignature.ChangeSign = this.tbChangeSign.Text;
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 = RsaKey.Instance.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 = "(" + Common.length  +": " + UserControlHelper.GetRtbTextLength(this.rtbResult) * 4 + " " + Common.bit + ")";
75        }
76
77        private void tbResultEncrypted_TextChanged(object sender, TextChangedEventArgs e)
78        {
79            this.lblEncryptedSignatureLength.Content = "(" + Common.length + ": " + this.tbResultEncrypted.Text.Length * 4 + " " + Common.bit + ")";
80        }
81
82        private void btn_Help_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
83        {
84            if (sender == btnHelpChangeSign)
85            {
86                OnlineHelp.OnlineHelpAccess.ShowOnlineHelp(PKCS1.OnlineHelp.OnlineHelpActions.Gen_Bleichenb_ChangeSign);
87            }
88            else if (sender == btnHelpBitPos)
89            {
90                OnlineHelp.OnlineHelpAccess.ShowOnlineHelp(PKCS1.OnlineHelp.OnlineHelpActions.Gen_Bleichenb_BitPos);
91            }
92            e.Handled = true;
93        }
94    }
95}
Note: See TracBrowser for help on using the repository browser.