public ConfigurateEDSPage() { this.EDS = new EllipticCurve_EDS(); this.db = SupportEDS.GetMainWindow().db; SupportEDS.GetMainWindow().frame_left_column.Width = new GridLength(0); SupportEDS.GetMainWindow().back_column.Width = new GridLength(56); InitializeComponent(); List <Scheme> nist = this.db.Schemes.Where(sh => sh.Owner == "nist").ToList(); foreach (Scheme s in nist) { this.comboBox_nist.Items.Add(s.Name); } List <Scheme> sec2 = this.db.Schemes.Where(sh => sh.Owner == "sec2").ToList(); foreach (Scheme s in sec2) { this.comboBox_sec2.Items.Add(s.Name); } List <Scheme> user = this.db.Schemes.Where(sh => sh.Owner == "user").ToList(); foreach (Scheme s in user) { this.comboBox_custom.Items.Add(s.Name); } this.textBlock_info.Text = "Параметры схемы электронной цифровой подписи на основе эллиптических кривых над конечным полем Fp:\n\n" + " 1. Размер конечного поля p, где p > 3 - простое число;\n " + " 2. Два элемента a и b, которые определяют уравнение эллиптической кривой Е;\n" + " 3. Два элемента Gx и Gy, которые определяют базисную точку G = (Gx, Gy) простого порядка на E;\n" + " 4. Порядок n точки G (рекомендовано n > 2^160 и n^2 > 16p);\n" + " 5. Кофактор h = #E(Fp)/n."; }
public CreateSchemePage() { this.EDS = new EllipticCurve_EDS(); this.db = SupportEDS.GetMainWindow().db; InitializeComponent(); this.gen_textbox_p.GenButtonClick += Gen_textbox_p_GenButtonClick; this.gen_textbox_p.value_textbox.KeyDown += Textbox_KeyDigitDown; this.gen_textbox_p.value_textbox.KeyDown += Textbox_P_KeyDown; this.gen_textbox_p.down_textbox.KeyDown += Textbox_KeyDigitDown; this.gen_textbox_p.gen_button.Click += Textbox_P_KeyDown; this.gen_textbox_a.GenButtonClick += Gen_textbox_a_GenButtonClick; this.gen_textbox_a.value_textbox.KeyDown += Textbox_KeyDigitAndSubDown; this.gen_textbox_p.value_textbox.KeyDown += Textbox_A_KeyDown; this.gen_textbox_a.down_textbox.KeyDown += Textbox_KeyDigitDown; this.gen_textbox_a.gen_button.Click += Textbox_A_KeyDown; this.gen_textbox_a.value_textbox.Text = "-3"; this.gen_textbox_b.GenButtonClick += Gen_textbox_b_GenButtonClick; this.gen_textbox_b.value_textbox.KeyDown += Textbox_KeyDigitAndSubDown; this.gen_textbox_p.value_textbox.KeyDown += Textbox_B_KeyDown; this.gen_textbox_b.down_textbox.KeyDown += Textbox_KeyDigitDown; this.gen_textbox_b.gen_button.Click += Textbox_B_KeyDown; }
public void GetKeyFile(string pth) { this.filename_textblock.Text = pth; string fullpath = SupportEDS.spec_folder + "\\" + pth; var main = SupportEDS.GetMainWindow(); if (File.Exists(fullpath + ".publ")) { string[] q = File.ReadAllLines(fullpath + ".publ", Encoding.Default)[0].Split('\0'); main.EDS.Q = new EllipticCurve_Point(BigInteger.Parse(q[0]), BigInteger.Parse(q[1])); this.public_key_image.Source = new BitmapImage(new Uri("Images/ExplorerNode/Yes.png", UriKind.Relative)); } else { this.public_key_image.Source = new BitmapImage(new Uri("Images/ExplorerNode/No.png", UriKind.Relative)); } if (File.Exists(fullpath + ".priv")) { string d = File.ReadAllLines(fullpath + ".priv", Encoding.Default)[0]; main.EDS.D = BigInteger.Parse(d); this.private_key_image.Source = new BitmapImage(new Uri("Images/ExplorerNode/Yes.png", UriKind.Relative)); } else { this.private_key_image.Source = new BitmapImage(new Uri("Images/ExplorerNode/No.png", UriKind.Relative)); } }
private void Submit_button_Click(object sender, RoutedEventArgs e) { Scheme scheme = this.db.Schemes.Where(sh => sh.Name == this.select_scheme_textblock.Text).First(); var main = SupportEDS.GetMainWindow(); main.selectScheme = scheme; main.back_column.Width = new GridLength(0); main.frame_left_column.Width = new GridLength(1, GridUnitType.Star); main.frame_left.Content = new PageExplorer(); main.frame_right.Source = new Uri("PageEmpty.xaml", UriKind.Relative); }
public PageExplorer() { InitializeComponent(); this.keys_grid.Visibility = Visibility.Hidden; var main = SupportEDS.GetMainWindow(); if (main.selectScheme != null) { this.scheme_status_textblock.Text = "Схема " + main.selectScheme.Name; this.keys_grid.Visibility = Visibility.Visible; } }
private void Explorer_ListboxSelectionChanged(object sender, SelectedFileEventArgs e) { var main = SupportEDS.GetMainWindow(); if (e.FileInfo == null) { main.frame_right.Source = new Uri("PageEmpty.xaml", UriKind.Relative); } else { main.frame_right.Content = new PageFileInfo(e.FileInfo); } }
private void Node_MouseDoubleClick(object sender, MouseButtonEventArgs e) { IExplorerNode node = (IExplorerNode)sender; if (node.Type != explType.Keys) { SetDirectory(node.Path); } else { SupportEDS.GetMainWindow().GetKeyFile(node.Path); } }
private void Create_scheme_button_Click(object sender, RoutedEventArgs e) { SupportEDS.GetMainWindow().frame_right.Source = new Uri("CreateSchemePage.xaml", UriKind.Relative); }
private void CreateEDS() { var main = SupportEDS.GetMainWindow(); if (main.selectScheme != null) { if (this.big_button_text.Text == "СОЗДАТЬ ПОДПИСЬ") { if (main.EDS.D != 0) { try { main.EDS.LoadScheme(main.selectScheme); byte[] file = System.IO.File.ReadAllBytes(this.File.File.FullName); byte[] H = main.EDS.Hash.GetHash(file); string sign = main.EDS.SingGen(H, main.EDS.D); System.IO.File.WriteAllText(this.File.File.FullName + ".edsc", sign, Encoding.Default); this.File.EdsState = 1; ((PageExplorer)main.frame_left.Content).explorer.UpdateFileInfo(this.File); this.message_text.Text = "Цифровая подпись присутствует."; this.big_button_text.Text = "ПРОВЕРИТЬ"; } catch { MessageBox.Show("Подпись не соответствует выбранной схеме или ключу"); } } else { MessageBox.Show("Не выбран секретный ключ", "Внимание"); } } else if (this.big_button_text.Text == "ПРОВЕРИТЬ") { if (!main.EDS.Q.IsNull) { try { main.EDS.LoadScheme(main.selectScheme); if (System.IO.File.Exists(this.File.File.FullName + ".edsc")) { byte[] file = System.IO.File.ReadAllBytes(this.File.File.FullName); byte[] H = main.EDS.Hash.GetHash(file); string sign = System.IO.File.ReadAllLines(this.File.File.FullName + ".edsc", Encoding.Default)[0]; bool result = main.EDS.SingVer(H, sign, main.EDS.Q); if (result) { this.message_text.Text = "Подлинность цифровой подписи подтверждена."; this.File.EdsState = 2; } else { this.message_text.Text = "Подпись не соответствует документу."; this.File.EdsState = 3; } ((PageExplorer)main.frame_left.Content).explorer.UpdateFileInfo(this.File); } } catch { MessageBox.Show("Подпись не соответствует выбранной схеме или ключу"); } } else { MessageBox.Show("Не выбран открытый ключ", "Внимание"); } } } }