Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
List the encryption keys of files whose names aren't known
tl;dr:
When listing files and requesting
encryption-keyorencryption-key-rawfor archives with files of unknown name, the result is just 0. If we read a single byte from these files rather than just list them, we trigger StormLib to work out the key. That's what this PR does.Longer explanation
mpqcli list -p encryption-key -p encryption-key-rawprinted00000000for encrypted files whose names aren't known, which StormLib lists asFileXXXXXXXX.<ext>.StormLib works out the key of an encrypted file from its name when the file is opened. Without the name, it can still find the key, but only on the first read. For a compressed file it uses the sector offset table, and for an uncompressed one it looks for a known file header (RIFF, MZ, XML).
listnever read the files, so their key stayed at 0.Changes
encryption-keyorencryption-key-rawis requested,listreads one byte of each encrypted file whose key is still 0, so StormLib finds the key before it is printed. Files opened by name already have their key and unencrypted files have none, so neither is read. Listings that don't print a key are unchanged.test_list_encryption_keys_of_files_listed_without_names. It lists an MPQ that has no internal listfile twice, first without names and then with an external listfile. It checks that every encrypted file gets the same non-zero keys both times.If StormLib can't find the key, for example for an uncompressed file whose content it doesn't recognise, the key is still shown as
00000000.