Exemplo n.º 1
0
        public static void Generate(Person person, Organization organization)
        {
            GnuPG generatingInstance = new GnuPG();

            generatingInstance.Timeout = 120000;
            generatingInstance.GenerateKeyPair(person.Name, person.PartyEmail, organization.Name,
                                               new DateTime(DateTime.Today.Year + 2, 12, 31));

            GnuPGKeyCollection keys = new GnuPG().GetKeys();

            foreach (GnuPGKey key in keys)
            {
                if (key.UserId == person.PartyEmail)
                {
                    // Console.Write(" signing...");
                    generatingInstance.SignKey(key.Fingerprint, "*****@*****.**");
                    // Console.Write(" uploading...");
                    generatingInstance.UploadKey(key.Fingerprint.Replace(" ", ""));
                    string armorSecret = new GnuPG().GetSecretKey(key.Fingerprint.Replace(" ", ""));
                    string armorPublic = new GnuPG().GetPublicKey(key.Fingerprint.Replace(" ", ""));
                    // Console.Write(" deleting...");
                    key.Delete();

                    person.CryptoPublicKey   = armorPublic;
                    person.CryptoSecretKey   = armorSecret;
                    person.CryptoFingerprint = key.Fingerprint;
                }
            }
        }
Exemplo n.º 2
0
        private void buttonNewKey_Click(object sender, EventArgs e)
        {
            Process process;

            try
            {
                process = GnuPG.GenerateKey();
            }
            #region Error handling
            catch (IOException ex)
            {
                Log.Error(ex);
                Msg.Inform(this, ex.Message, MsgSeverity.Error);
                return;
            }
            #endregion

            ThreadUtils.StartBackground(() =>
            {
                process.WaitForExit();

                // Update key list when done
                try
                {
                    this.Invoke(ListKeys);
                }
                #region Sanity checks
                catch (InvalidOperationException)
                {
                    // Ignore if window has been dispoed
                }
                #endregion
            }, name: "WaitForOpenPgp");
        }
Exemplo n.º 3
0
    private void OutlookGnuPG_Startup(object sender, EventArgs e)
    {
      _settings = new Properties.Settings();

      if (string.IsNullOrEmpty(_settings.GnuPgPath))
      {
        _gnuPg = new GnuPG();
        Settings(); // Prompt for GnuPG Path
      }
      else
      {
        _gnuPg = new GnuPG(null, _settings.GnuPgPath);
        if (!_gnuPg.BinaryExists())
        {
          _settings.GnuPgPath = string.Empty;
          Settings(); // Prompt for GnuPG Path
        }
      }
      _gnuPg.OutputType = OutputTypes.AsciiArmor;

      _WrappedObjects = new Dictionary<Guid, object>();

      // Initialize command bar.
      // Must be saved/closed in Explorer Close event.
      // See http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/df53276b-6b44-448f-be86-7dd46c3786c7/
      AddGnuPGCommandBar(this.Application.ActiveExplorer());

      // Register an event for ItemSend
      Application.ItemSend += Application_ItemSend;
#if VSTO2008
      ((ApplicationEvents_11_Event)Application).Quit += OutlookGnuPG_Quit;
#endif

      // Initialize the outlook explorers
      _explorers = this.Application.Explorers;
      _explorers.NewExplorer += new Outlook.ExplorersEvents_NewExplorerEventHandler(OutlookGnuPG_NewExplorer);
      for (int i = _explorers.Count; i >= 1; i--)
      {
        WrapExplorer(_explorers[i]);
      }

      // Initialize the outlook inspectors
      _inspectors = this.Application.Inspectors;
      _inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(OutlookGnuPG_NewInspector);
    }
Exemplo n.º 4
0
        public GnuPgpProcessor()
        {
            var path = new GpgPath();

            _gpg = new GnuPG(path.GetHomeFolderPath(), path.GetExeFolder());
        }