Ejemplo n.º 1
0
 public static void DecodeFormat(byte[] b, out string header, out string id, out byte[] dataEncrypted)
 {
     byte[] bHeader = new byte[3];
     Array.Copy(b, 0, bHeader, 0, 3);
     header = Encoding.ASCII.GetString(bHeader);
     if (header.StartsWithInv("v1"))
     {
         // Compatibility
         id            = RandomGenerator.GetRandomId64();
         dataEncrypted = new byte[b.Length - 3];
         Array.Copy(b, 3, dataEncrypted, 0, b.Length - 3);
     }
     else if (header.StartsWith("v2"))
     {
         byte[] bId = new byte[64];
         Array.Copy(b, 3, bId, 0, 64);
         id            = Encoding.ASCII.GetString(bId);
         dataEncrypted = new byte[b.Length - 3 - 64];
         Array.Copy(b, 3 + 64, dataEncrypted, 0, b.Length - 3 - 64);
     }
     else
     {
         throw new Exception("Read fail");
     }
 }
Ejemplo n.º 2
0
        public Storage()
        {
            Id = RandomGenerator.GetRandomId64();

            EnsureDefaults();

            if ((Platform.Instance.OsCredentialSystemDefault()) && (Platform.Instance.OsCredentialSystemName() != ""))
            {
                SaveFormat = "v2s";                 // Os
            }
            else
            {
                SaveFormat = "v2n";                 // None
            }

            XmlDocument xmlDoc = new XmlDocument();

            Providers = xmlDoc.CreateElement("providers");
        }
Ejemplo n.º 3
0
        // Rename AirVPN.xml (if exists) to Default.xml
        public static void FixOldProfilePath(string newPath)
        {
            if (Platform.Instance.FileExists(newPath))
            {
                return;
            }

            if ((newPath.EndsWith("default.profile")) && (Platform.Instance.FileExists(newPath.Replace("default.profile", "AirVPN.xml"))))
            {
                Platform.Instance.FileMove(newPath.Replace("default.profile", "AirVPN.xml"), newPath.Replace("default.profile", "default.xml"));
            }

            if ((newPath.EndsWith("default.profile")) && (Platform.Instance.FileExists(newPath.Replace("default.profile", "default.xml"))))
            {
                byte[] content = Platform.Instance.FileContentsReadBytes(newPath.Replace("default.profile", "default.xml"));
                Platform.Instance.FileContentsWriteBytes(newPath, Storage.EncodeFormat("v2n", RandomGenerator.GetRandomId64(), content, Constants.PasswordIfEmpty));
                Platform.Instance.FileDelete(newPath.Replace("default.profile", "default.xml"));
            }
        }