-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calculated text checksum is different from the header one #58
Comments
Indeed, I just stumbled upon the exact same issue. I was also writing some code to manipulate the format, and didn't succeed in getting the hash to match the original hash for all apps. I then started playing around with the code here, and I noticed that it also doesn't manage to get the original hash. So, it turns out that in my code (which is written in Rust but that's besides the point), I do pretty much the exact same thing as this tools does. What's interesting though, is that for some of the apps, calculating the hash DOES work. Using the For an example of an app I'm pretty sure you will have in your local As for now, I have not been able to notice anything obvious that stands out between the apps that don't hash well and the ones that do. I assume we might need to sanitize the textual representation of the VDF a bit more, just like was necessary for the backslash characters. Did you make any additional discoveries surrounding this @tralph3? |
Are you guys implementing parsers for the latest version of appinfo? Now all strings are stored at the end of the file, and in the metadata itself there's only indeces that relate to the string's position in the end of the gile "list of strings". That would explain why binary data works, but text vdf doesn't. Although it would be pretty clear that you're doing something wrong if you take a look at the decoded strings and just see garbage. So it's likely something else. |
Yes, I'm parsing the latest AppInfo format (v29). Parsing the binary format is very easy thanks to the people who've documented it, including yourself. Rather, I'm talking about generating the correct hash from the textual representation of the binary vdf. I can confirm that what @ktKongTong is reporting is correct. The hash you generate in this application is often incorrect as well. Here's a quick example (I'm not a Python programmer): def main():
path = os.path.join(
"/home/romatthe/.local/share/Steam", "appcache", "appinfo.vdf"
)
appinfo = Appinfo(
path, False, None
)
app = appinfo.parsedAppInfo[440]
formatted = appinfo.dict_to_text_vdf(app["sections"])
print(list(app['checksum_text']))
print(app['checksum_text'].hex())
print(list(sha1(formatted).digest()))
print(sha1(formatted).hexdigest()) Result:
To clarify: I'm just parsing the Like I pointed out above, in my code (completely separate codebase) I generate the exact same checksums as you do, but again, these appear to be incorrect. As I said, for about 10% of all the apps in my local |
For those interested, I quickly took a dump of the textual VDF of both all the apps I was able to generate a matching checksum for ( |
So after trying to wrap my head around this for a few days, I can't quite get a satisfying answer. Here's more or less what I think the conclusion is:
For the last point, I simply tested this in my own tool by parsing an existing 'clean' And from what I've seen, Steam does not reject these. It's possible that the Steam client never uses that hash to check the integrity of the file. Or it's possible it only uses it at certain points, which means it could still reject the file somewhere down the line... I don't quite know. Either way, I do think I'm fairly confident in concluding that pretty much no one actually knows how to correct generate these checksums, except some folks over at Valve. I've found no code in the public space that does it correctly ("correctly" here meaning matching Valve's method). |
Well, if Steam doesn't reject the hashes, and the changes are reflected, then it's still working, which is the important thing. I'd look to actual text VDF files, shipped by Valve, and try to spot any discrepancies between them and the ones we generate in our programs. Maybe there's an extra newline character at the end, or the beginning, or some escape sequence. Who knows. |
thank you for your great work. I am working on building another AppInfo.vdf editor(web verision). The documentation has helped me a lot.
I parse an AppInfo object into a custom object.
when I serialize it into binary format, the calculated hash matches the binary checksum in header perfectly.
but when I serialize it into text format and hash it, most of the results are different from the hash field in the binary header.
To investigate, I debugged appinfo.py and found that it also has the same issue.
it's seem that replace
\\
to\\\\
didn't solve all problems.The text was updated successfully, but these errors were encountered: