Example #1
0
        bool checkPassword()
        {
            string password = textBox1.Text;
            bool   valid    = XMLService.checkPassword(password);

            return(valid);
        }
Example #2
0
        public static void initialSetup()
        {
            XElement xSetting = new XElement("setting");

            string newAesIv         = string.Empty;
            string newSalt          = string.Empty;
            int    newGenPassLength = 32;
            int    newRsaKeyLength  = 2048;
            bool   newAutoSignMsg   = false;
            string newAutoSignName  = string.Empty;
            string newUserPassword  = string.Empty;

            XAttribute xAesIv         = new XAttribute("aesIv", newAesIv);
            XAttribute xSalt          = new XAttribute("salt", newSalt);
            XAttribute xGenPassLength = new XAttribute("genPassLength", newGenPassLength);
            XAttribute xRsaKeyLength  = new XAttribute("rsaKeyLength", newRsaKeyLength);
            XAttribute xAutoSignMsg   = new XAttribute("autoSignMsg", newAutoSignMsg);
            XAttribute xAutoSignName  = new XAttribute("autoSignName", newAutoSignName);
            XAttribute xUserPassword  = new XAttribute("userPassword", newUserPassword);

            xSetting.Add(xAesIv);
            xSetting.Add(xSalt);
            xSetting.Add(xGenPassLength);
            xSetting.Add(xRsaKeyLength);
            xSetting.Add(xAutoSignMsg);
            xSetting.Add(xAutoSignName);
            xSetting.Add(xUserPassword);

            XMLService.addElement(path, xSetting);
        }
Example #3
0
        void openTextFile()
        {
            string ciphertext = XMLService.readImplant(loadedFileExt);

            msgSign       = XMLService.readSign(loadedFileExt);
            textBox1.Text = ciphertext;
        }
Example #4
0
        public static void get(string trustedContactName)
        {
            XElement xMyKey = XMLService.getElement(path, xElementName, xAttributeName, trustedContactName);

            name   = trustedContactName;
            pubKey = xMyKey.Attribute("pubKey").Value;
            note   = xMyKey.Attribute("note").Value;
        }
Example #5
0
        public static void get(string myKeyName)
        {
            XElement xMyKey = XMLService.getElement(path, xElementName, xAttributeName, myKeyName);

            name       = myKeyName;
            privPubKey = xMyKey.Attribute("privPubKey").Value;
            note       = xMyKey.Attribute("note").Value;
        }
Example #6
0
        void saveSettings()
        {
            getData();
            XMLService.initialSetup();
            Setting.set();
            MyKey.add();

            Dispose();
        }
Example #7
0
        void saveToOOXML()
        {
            string path       = FileService.getImplantPath(loadedFileExt);
            string ciphertext = textBox1.Text;

            XMLService.writeRels(loadedFileExt);
            XMLService.writeContentTypes(loadedFileExt);
            XMLService.writeImplant(loadedFileExt, ciphertext, msgSign);
            zipFile();
            deleteFromTemp();
        }
Example #8
0
        bool checkRSAkey()
        {
            string key   = textBox2.Text;
            bool   valid = XMLService.checkRSAkey(key);

            if (!valid)
            {
                MessageBox.Show("Podany klucz jest nieprawidłowy!" + Environment.NewLine + "Dozwolone jest używanie wyłącznie kluczy wygenerowanych przez ninejszy program.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(valid);
        }
Example #9
0
        public static List <string> getKeyNames()
        {
            List <string> names = new List <string>();

            XDocument doc       = XMLService.getDocument(path);
            var       xElements = doc.Element("root").Elements(xElementName);

            foreach (XElement element in xElements)
            {
                names.Add(element.Attribute("name").Value);
            }

            return(names);
        }
Example #10
0
        public static void add()
        {
            XElement xMyKey = new XElement(xElementName);

            XAttribute xName       = new XAttribute("name", name);
            XAttribute xPrivPubKey = new XAttribute("privPubKey", privPubKey);
            XAttribute xNote       = new XAttribute("note", note);

            xMyKey.Add(xName);
            xMyKey.Add(xPrivPubKey);
            xMyKey.Add(xNote);

            XMLService.addElement(path, xMyKey);
        }
Example #11
0
        public static void add()
        {
            XElement xTrustedContact = new XElement("trustedContact");

            XAttribute xName       = new XAttribute("name", name);
            XAttribute xPrivPubKey = new XAttribute("pubKey", pubKey);
            XAttribute xNote       = new XAttribute("note", note);

            xTrustedContact.Add(xName);
            xTrustedContact.Add(xPrivPubKey);
            xTrustedContact.Add(xNote);

            XMLService.addElement(path, xTrustedContact);
        }
Example #12
0
        public static void get()
        {
            try
            {
                XElement xSetting = XMLService.getElement(path, xElementName);

                aesIv         = xSetting.Attribute("aesIv").Value;
                salt          = xSetting.Attribute("salt").Value;
                genPassLength = Int32.Parse(xSetting.Attribute("genPassLength").Value);
                rsaKeyLength  = Int32.Parse(xSetting.Attribute("rsaKeyLength").Value);
                autoSignMsg   = Boolean.Parse(xSetting.Attribute("autoSignMsg").Value);
                autoSignName  = xSetting.Attribute("autoSignName").Value;
                userPassword  = xSetting.Attribute("userPassword").Value;
            }
            catch (Exception ex)
            {
                LogService.add(ex.ToString());
            }
        }
Example #13
0
        public static IEnumerable getData()
        {
            IEnumerable data = null;

            try
            {
                XDocument doc         = XMLService.getDocument(path);
                XElement  rootElement = doc.Element("root");
                var       xElements   = doc.Element("root").Elements(xElementName);
                var       xmlData     = xElements.Select(p => new { Nazwa = p.Attribute("name").Value, Klucz = p.Attribute("pubKey").Value, Notatka = p.Attribute("note").Value });
                data = xmlData.ToList();
            }
            catch (Exception ex)
            {
                LogService.add(ex.ToString());
                data = null;
            }

            return(data);
        }
Example #14
0
        public static void set()
        {
            XElement xSetting = new XElement("setting");

            XAttribute xAesIv         = new XAttribute("aesIv", aesIv);
            XAttribute xSalt          = new XAttribute("salt", salt);
            XAttribute xGenPassLength = new XAttribute("genPassLength", genPassLength);
            XAttribute xRsaKeyLength  = new XAttribute("rsaKeyLength", rsaKeyLength);
            XAttribute xAutoSignMsg   = new XAttribute("autoSignMsg", autoSignMsg);
            XAttribute xAutoSignName  = new XAttribute("autoSignName", autoSignName);
            XAttribute xUserPassword  = new XAttribute("userPassword", userPassword);

            xSetting.Add(xAesIv);
            xSetting.Add(xSalt);
            xSetting.Add(xGenPassLength);
            xSetting.Add(xRsaKeyLength);
            xSetting.Add(xAutoSignMsg);
            xSetting.Add(xAutoSignName);
            xSetting.Add(xUserPassword);


            XMLService.editElement(path, xElementName, xSetting);
        }
Example #15
0
        public static bool checkName(string value)
        {
            bool unique = XMLService.checkDublicates(path, xElementName, xAttributeName, value);

            return(unique);
        }
Example #16
0
 private void button2_Click_2(object sender, EventArgs e)
 {
     MessageBox.Show(XMLService.readImplant("*.docx"));
 }
Example #17
0
        //public static void update(string trustedContactName)
        //{
        //    XElement xTrustedContact = new XElement("myKey");

        //    XAttribute xName = new XAttribute("name", name);
        //    XAttribute xPubKey = new XAttribute("pubKey", pubKey);
        //    XAttribute xNote = new XAttribute("note", note);

        //    xTrustedContact.Add(xName);
        //    xTrustedContact.Add(xPubKey);
        //    xTrustedContact.Add(xNote);

        //    XMLService.editElement(path, xElementName, xAttributeName, trustedContactName, xTrustedContact);
        //}

        public static void remove(string trustedContactName)
        {
            XMLService.deleteElement(path, xElementName, xAttributeName, trustedContactName);
        }
Example #18
0
 public static void remove(string myKeyName)
 {
     XMLService.deleteElement(path, xElementName, xAttributeName, myKeyName);
 }