Esempio n. 1
0
        private void Decrypt(String filename, String passphrase, String outfile)
        {
            try
            {
                core.InitializeKeys(passphrase);
            }
            catch
            {
                Console.Error.WriteLine("Invalid passphrase");
                return;
            }

            Message message = new Message(File.ReadAllText(filename));

            message.Decrypt(core.PrivateKey);

            if (Util.Write(outfile, message.Cleartext))
            {
                Console.Error.WriteLine("Output written to {0}", outfile);
            }
        }
Esempio n. 2
0
        private void preNext()
        {
            currentPanel.Enabled = false;

            core = new Core("", false);

            if (File.Exists(Path.Combine(core.ApplicationDataFolder, "server.key")))
            {
                if (File.Exists(core.KeyFile))
                {
                    if (
                        MessageBox.Show("Are you ABSOLUTELY sure that you want to delete your existing keys FOREVER?",
                                        "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                        DialogResult.Yes)
                    {
                        File.Delete(core.KeyFile);
                    }
                    else
                    {
                        currentPanel.Enabled = true;
                        return;
                    }
                }

                SetStatus("Reading Server Key...");
                serverKey = File.ReadAllText(Path.Combine(core.ApplicationDataFolder, "server.key"));

                SetStatus("Initializing Keys...");
                String passphrase = "";

                if (currentPanel == initializationPanel)
                    passphrase = Passphrase.Text;
                else if (currentPanel == passphrasePanel)
                    passphrase = genericPassphrase.Text;

                core.InitializeKeys(passphrase);

                if (currentPanel == initializationPanel)
                {
                    SetStatus("Writing Identity...");
                    username = Username.Text;
                    email = Email.Text;

                    StreamWriter sw = new StreamWriter(Path.Combine(core.ApplicationDataFolder, "identity"));
                    sw.WriteLine(username);
                    sw.WriteLine(email);
                    sw.Close();
                }
                else if(currentPanel == passphrasePanel)
                {
                    SetStatus("Reading Identity...");
                    StreamReader sr = new StreamReader(Path.Combine(core.ApplicationDataFolder, "identity"));
                    username = sr.ReadLine();
                    email = sr.ReadLine();
                    sr.Close();
                }

                SetStatus("Connecting to Server...");
                server = (IServer)Activator.GetObject(typeof(IServer), "http://" + serverURL + "/PractiSES");
            }
            else
            {
                MessageBox.Show("Server key not installed. Please download server key and install it.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                currentPanel.Enabled = true;
                return;
            }
        }
Esempio n. 3
0
        private void preNext()
        {
            currentPanel.Enabled = false;

            core = new Core("", false);

            if (File.Exists(Path.Combine(core.ApplicationDataFolder, "server.key")))
            {
                if (File.Exists(core.KeyFile))
                {
                    if (
                        MessageBox.Show("Are you ABSOLUTELY sure that you want to delete your existing keys FOREVER?",
                                        "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                        DialogResult.Yes)
                    {
                        File.Delete(core.KeyFile);
                    }
                    else
                    {
                        currentPanel.Enabled = true;
                        return;
                    }
                }

                SetStatus("Reading Server Key...");
                serverKey = File.ReadAllText(Path.Combine(core.ApplicationDataFolder, "server.key"));

                SetStatus("Initializing Keys...");
                String passphrase = "";

                if (currentPanel == initializationPanel)
                {
                    passphrase = Passphrase.Text;
                }
                else if (currentPanel == passphrasePanel)
                {
                    passphrase = genericPassphrase.Text;
                }

                core.InitializeKeys(passphrase);

                if (currentPanel == initializationPanel)
                {
                    SetStatus("Writing Identity...");
                    username = Username.Text;
                    email    = Email.Text;

                    StreamWriter sw = new StreamWriter(Path.Combine(core.ApplicationDataFolder, "identity"));
                    sw.WriteLine(username);
                    sw.WriteLine(email);
                    sw.Close();
                }
                else if (currentPanel == passphrasePanel)
                {
                    SetStatus("Reading Identity...");
                    StreamReader sr = new StreamReader(Path.Combine(core.ApplicationDataFolder, "identity"));
                    username = sr.ReadLine();
                    email    = sr.ReadLine();
                    sr.Close();
                }

                SetStatus("Connecting to Server...");
                server = (IServer)Activator.GetObject(typeof(IServer), "http://" + serverURL + "/PractiSES");
            }
            else
            {
                MessageBox.Show("Server key not installed. Please download server key and install it.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                currentPanel.Enabled = true;
                return;
            }
        }