Skip to content

List the encryption keys of files with unknown names - #186

Open
sjoblomj wants to merge 1 commit into
thegraydot:mainfrom
sjoblomj:encryption-key
Open

sjoblomj wants to merge 1 commit into
thegraydot:mainfrom
sjoblomj:encryption-key

Conversation

@sjoblomj

@sjoblomj sjoblomj commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

List the encryption keys of files whose names aren't known

tl;dr:

When listing files and requesting encryption-key or encryption-key-raw for 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-raw printed 00000000 for encrypted files whose names aren't known, which StormLib lists as FileXXXXXXXX.<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). list never read the files, so their key stayed at 0.

Changes

  • When encryption-key or encryption-key-raw is requested, list reads 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.
  • New test 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant