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); }
public AndroidBackup(MemoryStream backupFileStream) { this._backupFileStream = backupFileStream; this.Attributes = ExtractAttributesFromBackup(); }