Exemple #1
0
        /// <summary>
        /// Creates a signed byte array from the given CSV text with the specified XML format parameters.
        /// </summary>
        public static XmlCsvSByteArray CreateFromCsv(string csv, string xmlIndent, int xmlBytesPerRow)
        {
            XmlCsvSByteArray result = new XmlCsvSByteArray(xmlIndent, xmlBytesPerRow);

            result.FromCsv(csv);
            return(result);
        }
        private void btnRandomizePrivateSalt_Click(object sender, EventArgs e)
        {
            byte[] randomBytes           = new byte[16];
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

            rng.GetNonZeroBytes(randomBytes);
            sbyte[] sbytes = new sbyte[randomBytes.Length];
            for (int i = 0; i < randomBytes.Length; ++i)
            {
                sbytes[i] = (sbyte)randomBytes[i];
            }
            AndroidMetadata.PrivateSalt = XmlCsvSByteArray.CreateFromBytes(sbytes);
            txtPrivateSalt.Text         = AndroidMetadata.PrivateSalt.ToCsv();
        }
 internal void SaveMetadata()
 {
     AndroidMetadata.PackageName           = txtPackageName.Text;
     AndroidMetadata.VersionCode           = (int)nmbVersionCode.Value;
     AndroidMetadata.VersionName           = txtVersionName.Text;
     AndroidMetadata.KeyStorePath          = txtKeyStorePath.Text;
     AndroidMetadata.KeyStorePassword      = txtKeyStorePassword.Text;
     AndroidMetadata.KeyStoreAlias         = txtKeyStoreAlias.Text;
     AndroidMetadata.KeyStoreAliasPassword = txtKeyStoreAliasPassword.Text;
     AndroidMetadata.AppName      = txtAppName.Text;
     AndroidMetadata.ObbVersion   = (int)nmbObbVersion.Value;
     AndroidMetadata.RsaPublicKey = txtRsaPublicKey.Text;
     AndroidMetadata.PrivateSalt  = XmlCsvSByteArray.CreateFromCsv(txtPrivateSalt.Text
                                                                   .Replace("\r", "").Replace("\n", ""));
     AndroidMetadata.LauncherIconsZip = txtLauncherIconZip.Text;
 }
Exemple #4
0
        private static void ReadPrivateSettings()
        {
            string localStaticPropertiesPath = BuildTargetAndroid.Instance.GetCompiledPath(BuildTargetAndroid.STUDIO_PROJECT_DIR, "local.static.properties");

            if (File.Exists(localStaticPropertiesPath))
            {
                string[] lines = File.ReadAllLines(localStaticPropertiesPath);
                int      pos;
                string   rol;
                foreach (string line in lines)
                {
                    pos = line.IndexOf('=');
                    if (pos == -1)
                    {
                        continue;
                    }
                    rol = pos == (line.Length - 1) ? "" : line.Substring(pos + 1);
                    if (line.StartsWith("storeFile"))
                    {
                        if (rol == TemplateTag.KEY_STORE_PATH.Tag)
                        {
                            continue;
                        }
                        keyStorePath = rol.Replace("\\\\", "\\");
                    }
                    else if (line.StartsWith("storePassword"))
                    {
                        if (rol == TemplateTag.KEY_STORE_PASSWORD.Tag)
                        {
                            continue;
                        }
                        keyStorePassword = rol;
                    }
                    else if (line.StartsWith("keyAlias"))
                    {
                        if (rol == TemplateTag.KEY_STORE_ALIAS.Tag)
                        {
                            continue;
                        }
                        keyStoreAlias = rol;
                    }
                    else if (line.StartsWith("keyPassword"))
                    {
                        if (rol == TemplateTag.KEY_STORE_ALIAS_PASSWORD.Tag)
                        {
                            continue;
                        }
                        keyStoreAliasPassword = rol;
                    }
                }
            }
            string privateXmlPath = BuildTargetAndroid.Instance.GetCompiledPath(BuildTargetAndroid.STUDIO_PROJECT_DIR,
                                                                                "app", "src", "main", "res", "values", "private.xml");

            if (File.Exists(privateXmlPath))
            {
                XmlDocument doc = new XmlDocument();
                doc.PreserveWhitespace = false;
                doc.Load(privateXmlPath);
                XmlNode root     = doc.DocumentElement;
                XmlNode rsaNode  = root.SelectSingleNode("string[@name='RSA_public_key']");
                XmlNode saltNode = root.SelectSingleNode("integer-array[@name='ExpansionDownloaderServiceSALT']");
                if (rsaNode != null)
                {
                    if (rsaNode.InnerText != TemplateTag.RSA_PUBLIC_KEY.Tag)
                    {
                        rsaPublicKey = rsaNode.InnerText;
                    }
                }
                if ((saltNode != null) && (saltNode.InnerText != TemplateTag.PRIVATE_SALT.Tag))
                {
                    privateSalt = XmlCsvSByteArray.CreateFromXml(saltNode.InnerXml);
                }
            }
        }