示例#1
0
        private BackupAttributes ExtractAttributesFromBackup()
        {
            this._backupFileStream.Position = 0;

            var backupAttributes = new BackupAttributes
            {
                Header        = this._backupFileStream.ReadOneLine(),                      // 1. Line
                BackupVersion = this._backupFileStream.ReadOneLine(),                      // 2. Line
                IsCompressed  = this._backupFileStream.ReadOneLine() == "1" ? true : false // 3. Line
            };

            var encryptionType = this._backupFileStream.ReadOneLine(); // 4. Line

            backupAttributes.EncryptionType = encryptionType switch
            {
                "none" => EncryptionType.None,
                "AES-256" => EncryptionType.AES256,
                _ => EncryptionType.Unknown,
            };

            if (backupAttributes.EncryptionType == EncryptionType.AES256)
            {
                backupAttributes.UserPasswordSalt   = this._backupFileStream.ReadOneLine();            // 5. Line
                backupAttributes.MasterKeySalt      = this._backupFileStream.ReadOneLine();            // 6. Line
                backupAttributes.Iterations         = int.Parse(this._backupFileStream.ReadOneLine()); // 7. Line
                backupAttributes.UserIVKey          = this._backupFileStream.ReadOneLine();            // 8. Line
                backupAttributes.MasterKeyEncrypted = this._backupFileStream.ReadOneLine();            // 9. Line
            }

            return(backupAttributes);
        }
示例#2
0
        public AndroidBackup(MemoryStream backupFileStream)
        {
            this._backupFileStream = backupFileStream;

            this.Attributes = ExtractAttributesFromBackup();
        }