Ejemplo n.º 1
0
        private void SaveKeys(object sender, RoutedEventArgs e)
        {
            try
            {
                // Fetch ingredients for private key
                BigInteger p = BigInteger.Parse(pTextBox.Text);
                BigInteger g = BigInteger.Parse(gTextBox.Text);
                BigInteger x = BigInteger.Parse(xTextBox.Text);

                // Generate key
                SiGamalEngine.Key            k   = new SiGamalEngine.Key(p, g, x);
                SiGamalEngine.Key.PrivateKey pri = k.GeneratePrivateKey();
                SiGamalEngine.Key.PublicKey  pub = k.GeneratePublicKey();

                SaveFileDialog fileBrowser = new SaveFileDialog();

                Nullable <bool> result = fileBrowser.ShowDialog();

                if (result == true)
                {
                    string fileName = fileBrowser.FileName;
                    k.saveToFile(fileName);
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void GeneratePrivateKey(object sender, RoutedEventArgs e)
        {
            try
            {
                // Fetch ingredients for private key

                /*BigInteger p = BigInteger.Parse(pTextBox.Text);
                *  BigInteger g = BigInteger.Parse(gTextBox.Text);
                *  BigInteger x = BigInteger.Parse(xTextBox.Text);*/

                // Generate key
                SiGamalEngine.Key            k   = SiGamalEngine.Key.GenerateRandomKey();
                SiGamalEngine.Key.PrivateKey pri = k.GeneratePrivateKey();
                SiGamalEngine.Key.PublicKey  pub = k.GeneratePublicKey();

                xTextBox.Text = pri.X.ToString();
                yTextBox.Text = pub.Y.ToString();
                pTextBox.Text = pub.P.ToString();
                gTextBox.Text = pub.G.ToString();
            }
            catch (Exception ex)
            {
                ShowMessageBox(ex.Message);
            }
        }
Ejemplo n.º 3
0
        private void SaveKeySignButton_Click(object sender, EventArgs e)
        {
            // Save Key
            try
            {
                // Fetch ingredients for private key
                BigInteger p = BigInteger.Parse(pSignTextBox.Text);
                BigInteger g = BigInteger.Parse(gSignTextBox.Text);
                BigInteger x = BigInteger.Parse(xSignTextBox.Text);

                // Generate key
                Key k = new Key(p, g, x);
                Key.PrivateKey pri = k.GeneratePrivateKey();
                Key.PublicKey pub = k.GeneratePublicKey();

                SaveFileDialog fileBrowser = new SaveFileDialog();

                DialogResult result = fileBrowser.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string fileName = fileBrowser.FileName;
                    k.saveToFile(fileName);
                }
            }
            catch (Exception ex)
            {
                //ShowMessageBox("Key generation failed.");
            }
        }
Ejemplo n.º 4
0
 private void RandomKeySignButton_Click(object sender, EventArgs e)
 {
     // Generate Random Key
     key = Key.GenerateRandomKey();
     Key.PrivateKey pKey = key.GeneratePrivateKey();
     pSignTextBox.Text = pKey.P.ToString();
     gSignTextBox.Text = pKey.G.ToString();
     xSignTextBox.Text = pKey.X.ToString();
 }
Ejemplo n.º 5
0
        private void SaveKeys(object sender, RoutedEventArgs e)
        {
            try
            {
                // Fetch ingredients for private key
                BigInteger p = BigInteger.Parse(pTextBox.Text);
                BigInteger g = BigInteger.Parse(gTextBox.Text);
                BigInteger x = BigInteger.Parse(xTextBox.Text);

                // Generate key
                SiGamalEngine.Key k = new SiGamalEngine.Key(p, g, x);
                SiGamalEngine.Key.PrivateKey pri = k.GeneratePrivateKey();
                SiGamalEngine.Key.PublicKey pub = k.GeneratePublicKey();

                SaveFileDialog fileBrowser = new SaveFileDialog();

                Nullable<bool> result = fileBrowser.ShowDialog();

                if (result == true)
                {
                    string fileName = fileBrowser.FileName;
                    k.saveToFile(fileName);
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox(ex.Message);
            }
        }