Beispiel #1
0
        /// <summary>
        /// Callback function when a user clicks on CryptAndSignButton. Processes the input
        /// text from MessageTextBox control via GnuPG and displays the output into
        /// OutputTextBox control.
        ///
        /// Please note that this function reads the following keys from Web.Config and
        /// passes them to the GnuPGWrapper class: "homedirectory" and "passphrase".
        /// </summary>
        /// <param name="sender">Object that raised the Load event</param>
        /// <param name="e">The EventArgs object that contains the event data</param>
        private void CryptAndSignButton_Click(object sender, System.EventArgs e)
        {
            string inputText  = MessageTextBox.Text;
            string outputText = "";

            try
            {
                // Create GnuPG wrapping class
                GnuPGWrapper gpg = new GnuPGWrapper();

                // Set parameters from on Web.Config file
                gpg.homedirectory = Server.MapPath(ConfigurationSettings.AppSettings["homedirectory"]);
                gpg.passphrase    = ConfigurationSettings.AppSettings["passphrase"];
                gpg.originator    = FromTextBox.Text;
                gpg.recipient     = ToTextBox.Text;
                gpg.command       = Commands.SignAndEncrypt;

                // Execute GnuPG
                gpg.ExecuteCommand(inputText, out outputText);

                // Display output text
                OutputTextBox.Text    = outputText;
                OutputTextBox.Visible = true;
                ErrorMessage.Visible  = false;
                ExitCodeLabel.Text    = gpg.exitcode.ToString();
            }
            catch (GnuPGException gpge)
            {
                // Display error message
                ErrorMessage.Text     = gpge.Message;
                ErrorMessage.Visible  = true;
                OutputTextBox.Visible = false;
            }
        }
Beispiel #2
0
 public void Constructor(messagebroker.MessageBroker Broker)
 {
     this.broker = Broker;
     this.FindGnuPG("");
     this.gpg = new GnuPGWrapper();
     this.gpghomepath = Util.getApplicationPath() + Path.DirectorySeparatorChar + "gnupg";
     this.gpg.homedirectory = this.gpghomepath.Replace("file:\\","");
     this.gpg.bindirectory = this.gpgpath.Replace("file:\\","");
     if (!Directory.Exists(this.gpghomepath)) {
         Directory.CreateDirectory(this.gpghomepath.Replace("file:\\", ""));
     }
     // Find key id for UUID@Hostname
     this.gpg.command = Commands.FindKey;
     this.gpg.arguments = this.broker.UUID + "@" + this.broker.Hostname;
     string outputtext = "";
     string keyid = "";
     try
     {
         this.gpg.ExecuteCommand("", out outputtext);
         Util.log(this.ToString(), 99, outputtext);
     }
     // If keyid does not exist
     catch(GnuPGException ex)
     {
         // generate host key
     }
     // Save keyid for later
     // Download any new information for keyid from pgp.mit.edu
     // Send keyid to pgp.mit.edu (if anything needs to be sent)
     // Use keyid to sign messages from now on.
     //
 }
Beispiel #3
0
        private void VerifyButton_Click(object sender, System.EventArgs e)
        {
            string inputText = MessageTextBox.Text;
            string outputText = "";

            try
            {

                // Create GnuPG wrapping class
                GnuPGWrapper gpg = new GnuPGWrapper();

                // Set parameters from on Web.Config file
                gpg.homedirectory = Server.MapPath(ConfigurationSettings.AppSettings["homedirectory"]);
                gpg.passphrase = ConfigurationSettings.AppSettings["passphrase"];
                gpg.originator = FromTextBox.Text;
                gpg.recipient = ""; // no recipient needed for verify only
                gpg.command = Commands.Verify;

                // Execute GnuPG
                gpg.ExecuteCommand(inputText, out outputText);

                // Display output text
                OutputTextBox.Text = outputText;
                OutputTextBox.Visible = true;
                ErrorMessage.Visible = false;
                ExitCodeLabel.Text = gpg.exitcode.ToString();

            }
            catch (GnuPGException gpge)
            {
                // Display error message
                ErrorMessage.Text = gpge.Message;
                ErrorMessage.Visible = true;
                OutputTextBox.Visible = false;
            }
        }