-
Notifications
You must be signed in to change notification settings - Fork 28
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
UNERF: Encrypted ERF (v2.2 blowfish) not working #36
Comments
Hmm, that used to work, so I guess we broke it. I need to look at that later today, Which version of xoreos-tools are you using? I.e. a release package, a recent git checkout, ... |
Ah, sorry, I should have included that! Here you go: |
Ah, yeah, I see the problem. The password, as a decimal number, is 1234567890. However, due to how the digest is calculated and how both the Neverwinter Nights premium modules and Dragon Age 2 handle their ERF encryption and digests, my thought of unifying that was that our unerf tool should expect the hexadecimal representation of the string "1234567890". So the password that our unerf tool wants is 31323334353637383930, which is the string in hexadecimal form. I.e.
Yes, that is quite confusing, I know. I guess we should at least document that better, in the --help text and in the man page? Or possibly, handle this a bit better and less confusingly. Does that sound sensible? |
Ah, that makes sense! Personally, as a user, I would probably prefer it to take password the same way as DA:O Toolset, so I wouldn't need to worry about the dec-str-hex gymnastics every time. As a programmer, I would probably want something very consistent across games / versions. A question here, is the content actually encrypted with
In any event, at least now that I know what it expects, it is not a blocker anymore. Thanks for the explanation! |
It's a bit more complicated. The MD5 digest is calculated using the string "1234567890", i.e. 0x31323334353637383930. But for the actual compression, the number 1234567890 is treated as a little-endian uint64_t, and that is the key. I.e. the decompression key is the 8-byte array containing Again, that's just for Dragon Age: Origins. Dragon Age 2 is less weird there. |
For Dragon Age 2, the key is just plain old bytes. The NWN premium key is also plain old bytes, but part of the key is the MD5 hash of the main MOD file. Basically, that's why I thought the unified password parameter would be plain old bytes as well, with the string being the "natural" form, since that's used for the digest. And it's probably the easiest specifying a plain old byte array as hex on the comment line. That was my thought-process, at least. |
I think the simplest solution would be to just keep the current behavior and treat this as a documentation improvement. I’d say a DA:O specific example in the —help and man would suffice. Conversion is easy, just adding 30 to each digit is simple enough as long as the user remembers to. |
It seems that the unerf tool is testing the password's md5 instead of the decimal string corresponding to the password, which prevents it from extracting even when using a correct password.
ERF 2.2 Format
ERF Blowfish decryption / encryption steps
Attaching an example.
Created in Dragon Age: Origins Toolset - ERF Editor
DA:O Toolset ERF Editor opens the file, shows its content and extracts just fine (hello_world.txt)
Running unerf results in error:
HelloWorld.zip
The text was updated successfully, but these errors were encountered: