Ejemplo n.º 1
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.º 2
0
        private void VerifyEmail(Key.PublicKey pubKey)
        {
            Outlook.Application application = Globals.ThisAddIn.Application;
            Outlook.Inspector   inspector   = application.ActiveInspector();
            Outlook.MailItem    item        = (Outlook.MailItem)inspector.CurrentItem;
            //Outlook.MailItem item = Outlook. Inspector.CurrentItem as Outlook.MailItem;
            if (item != null)
            {
                // Put Algorithm Verify Here
                string rs = item.Body.Substring(item.Body.IndexOf("<sign>"));
                rs = rs.Substring(6);
                rs = rs.Substring(0, rs.IndexOf("<sign>"));

                /*System.Windows.Forms.MessageBox.Show(rs);
                 * System.Windows.Forms.MessageBox.Show(rs.Substring(0, rs.IndexOf('-')));
                 * System.Windows.Forms.MessageBox.Show(item.Body.Substring(0, item.Body.IndexOf("\n<sign>") - 1));
                 */
                BigInteger r   = BigInteger.Parse("0" + rs.Substring(0, rs.IndexOf('-')), System.Globalization.NumberStyles.HexNumber);
                BigInteger s   = BigInteger.Parse("0" + rs.Substring(rs.IndexOf('-') + 1), System.Globalization.NumberStyles.HexNumber);
                SHA256     sha = new SHA256();
                if (SiGamalGenerator.verification(r, s, pubKey.G, sha.GetMessageDigestToBigInteger(item.Body.Substring(0, item.Body.IndexOf("\n<sign>") - 2)), pubKey.Y, pubKey.P))
                {
                    System.Windows.Forms.MessageBox.Show("TRUE : Message is Valid");
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("FALSE ; Message was edited");
                }
            }
        }
Ejemplo n.º 3
0
 private void VerifyButton_Click(object sender, EventArgs e)
 {
     isSign   = false;
     pubKey   = new Key.PublicKey();
     pubKey.P = BigInteger.Parse(pVerifyTextBox.Text);
     pubKey.G = BigInteger.Parse(gVerifyTextBox.Text);
     pubKey.Y = BigInteger.Parse(yVerifyTextBox.Text);
     Close();
 }
Ejemplo n.º 4
0
        private void LoadKeyVerifyButton_Click(object sender, EventArgs e)
        {
            // Load Key for Verify
            string fileKey = ShowOpenDialog("Public Key (*.pub)|*.pub");

            if (fileKey == null)
            {
                return;
            }

            Key.PublicKey pubkey = Key.GeneratePublicKeyFromFile(fileKey);

            gVerifyTextBox.Text = pubkey.G.ToString();
            pVerifyTextBox.Text = pubkey.P.ToString();
            yVerifyTextBox.Text = pubkey.Y.ToString();
        }