Beispiel #1
0
 public LocationManager(KeePassRPCExt plugin)
 {
     _plugin= plugin;
     InitializeComponent();
     button1.Enabled = false;
     button2.Enabled = false;
     Icon = global::KeePassRPC.Properties.Resources.keefox;
 }
 public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
     CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry = entry;
     InitializeComponent();
     _advancedListView = advancedListView;
     _pwEntryForm = pwEntryForm;
     _strings = strings;
 }
 public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
     CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry = entry;
     InitializeComponent();
     _pwEntryForm = pwEntryForm;
     _strings = strings;
     string json = strings.ReadSafe("KPRPC JSON");
     if (string.IsNullOrEmpty(json))
         _conf = new EntryConfig();
     else
     {
         try
         {
             _conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json);
         }
         catch (Exception)
         {
             MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KeePassRPC JSON config' advanced string. Please ask for help on http://keefox.org/help/forum if you're not sure how to fix this.", "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
 public KeeFoxGroupUserControl(KeePassRPCExt keePassRPCPlugin, PwGroup group)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _group           = group;
     InitializeComponent();
 }
Beispiel #5
0
        public OptionsForm(IPluginHost host, KeePassRPCExt plugin)
        {
            _host   = host;
            _plugin = plugin;

            InitializeComponent();
            Icon           = global::KeePassRPC.Properties.Resources.kee;
            checkBox1.Text = "Automatically save KeePass database when Kee makes changes";
            if (host.CustomConfig.GetBool("KeePassRPC.KeeFox.autoCommit", true))
            {
                checkBox1.Checked = true;
            }
            else
            {
                checkBox1.Checked = false;
            }

            checkBox2.Text = "Immediately edit entries created by Kee";
            if (host.CustomConfig.GetBool("KeePassRPC.KeeFox.editNewEntries", false))
            {
                checkBox2.Checked = true;
            }
            else
            {
                checkBox2.Checked = false;
            }

            label13.Text = "You can generate new random passwords from Kee. These are stored in your system clipboard ready for you to paste into \"new user\" or \"change password\" fields. To protect against accidents these new passwords can be automatically stored in your current KeePass database under a special \"Kee Generated Password Backups\" group. You can generate new passwords when not logged in to a KeePass database but they will not receive this extra protection. The KeePass database can NOT be automatically saved after creating these backups so some problems can still result in a lost generated password.";

            checkBox3.Text = "Store a backup of each password generated by Kee";
            if (host.CustomConfig.GetBool("KeePassRPC.KeeFox.backupNewPasswords", true))
            {
                checkBox3.Checked = true;
            }
            else
            {
                checkBox3.Checked = false;
            }

            textBoxAuthExpiry.Text = (_host.CustomConfig.GetLong("KeePassRPC.AuthorisationExpiryTime", 8760 * 3600) / 3600).ToString();

            long secLevel          = _host.CustomConfig.GetLong("KeePassRPC.SecurityLevel", 2);
            long secLevelClientMin = _host.CustomConfig.GetLong("KeePassRPC.SecurityLevelClientMinimum", 2);

            switch (secLevel)
            {
            case 1: comboBoxSecLevelKeePass.SelectedItem = "Low"; break;

            case 2: comboBoxSecLevelKeePass.SelectedItem = "Medium"; break;

            default: comboBoxSecLevelKeePass.SelectedItem = "High"; break;
            }
            switch (secLevelClientMin)
            {
            case 1: comboBoxSecLevelMinClient.SelectedItem = "Low"; break;

            case 2: comboBoxSecLevelMinClient.SelectedItem = "Medium"; break;

            default: comboBoxSecLevelMinClient.SelectedItem = "High"; break;
            }

            label6.Text      = "Listen for connections on this TCP/IP port.";
            textBoxPort.Text = _host.CustomConfig.GetLong("KeePassRPC.webSocket.port", 12546).ToString();

            UpdateAuthorisedConnections();
        }
Beispiel #6
0
        /// <summary>
        /// Generates an X509 certificate using the Mono.Security assembly.
        /// Potentially could prise out the relevant classes from the Mono
        /// source code in order to reduce plgx size and complexity... one day
        /// </summary>
        /// <param name="subject">The subject.</param>
        /// <param name="issuer">The issuer.</param>
        /// <returns></returns>
        public static PKCS12 Generate(string subject, string issuer, string password, KeePassRPCExt KeePassRPCPlugin)
        {
            byte[]   sn        = Guid.NewGuid().ToByteArray();
            DateTime notBefore = DateTime.Now;
            DateTime notAfter  = new DateTime(643445675990000000); // 12/31/2039 23:59:59Z

            subject = "CN=" + subject;
            issuer  = "CN=" + issuer;
            RSA subjectKey = (RSA)RSA.Create();
            RSA issuerKey  = (RSA)RSA.Create();

            subjectKey.KeySize = 2048;
            issuerKey.KeySize  = 2048;

            string hashName = "SHA1";

            CspParameters subjectParams = new CspParameters();
            CspParameters issuerParams  = new CspParameters();

            // serial number MUST be positive
            if ((sn[0] & 0x80) == 0x80)
            {
                sn[0] -= 0x80;
            }

            //issuer = subject;
            //RSA issuerKey = subjectKey;

            if (subject == null)
            {
                throw new Exception("Missing Subject Name");
            }

            X509CertificateBuilder cb = new X509CertificateBuilder(3);

            cb.SerialNumber     = sn;
            cb.IssuerName       = issuer;
            cb.NotBefore        = notBefore;
            cb.NotAfter         = notAfter;
            cb.SubjectName      = subject;
            cb.SubjectPublicKey = subjectKey;
            cb.Hash             = hashName;

            //X509 extensions
            KeyUsageExtension keyUsage = new KeyUsageExtension();

            keyUsage.KeyUsage = KeyUsages.keyEncipherment | KeyUsages.digitalSignature;
            cb.Extensions.Add(keyUsage);

            ExtendedKeyUsageExtension extendedKeyUsage = new ExtendedKeyUsageExtension();

            extendedKeyUsage.KeyPurpose.Add("1.3.6.1.5.5.7.3.1");
            cb.Extensions.Add(extendedKeyUsage);
            byte[] rawcert = cb.Sign(issuerKey);

            PKCS12 p12 = new PKCS12();

            p12.Password = password;

            ArrayList list = new ArrayList();

            // we use a fixed array to avoid endianess issues
            // (in case some tools requires the ID to be 1).
            list.Add(new byte[4] {
                1, 0, 0, 0
            });
            Hashtable attributes = new Hashtable(1);

            attributes.Add(PKCS9.localKeyId, list);

            p12.AddCertificate(new X509Certificate(rawcert), attributes);
            p12.AddPkcs8ShroudedKeyBag(subjectKey, attributes);

/*
 *          if (Type.GetType("Mono.Runtime") != null)
 *          {
 *              string fileName = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "KeePassRPC"), "cert.p12");
 *              if (KeePassRPCPlugin.logger != null) KeePassRPCPlugin.logger.WriteLine(fileName);
 *              try
 *              {
 *                  p12.SaveToFile(fileName);
 *              }
 *              catch (Exception)
 *              {
 *                  if (KeePassRPCPlugin.logger != null) KeePassRPCPlugin.logger.WriteLine("Could not write to " + fileName + " security between KPRPC and clients may not be established.");
 *              }
 *          }
 *
 *          return p12.GetBytes();
 */
            return(p12);
        }
Beispiel #7
0
 public static PKCS12 Generate(string subject, string issuer, KeePassRPCExt KeePassRPCPlugin)
 {
     return(Generate(subject, issuer, (string)null, KeePassRPCPlugin));
 }
Beispiel #8
0
 public KeeFoxGroupUserControl(KeePassRPCExt keePassRPCPlugin, PwGroup group)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _group = group;
     InitializeComponent();
 }