-
Notifications
You must be signed in to change notification settings - Fork 8
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
Decrypt errors for latest ADX2 SDK ver (v2.98) #4
Comments
Thank you. From the keys you use this should be from Dragalia Lost. It seems CRI upgraded both ACB and HCA. For ACB they added a mask for byte alignment, which took me some time to figure out. Here is my guess. If HCAs created by older SDKs can be played in the lastest Atom, there are definitely some "signatures" in the file structure itself, not directly recognizable, that the new player understand and so it can decode the HCA in the old way. Well I think I can still get a latest version of the free version of the SDK but I don't know if it supports decoding encrypted audio. I'll try it later. By the way I have sent you a friend request on Steam. You can contact me there but I seldom open Steam these days, mostly because I don't have time to play those games. :/ |
All right, ADX2LE does not provide encrypting/decrypting functionalities, even in CriAtomViewer. (sigh) I'll start RE instead. |
I couldn't find any imports in CriAtomViewer that would suggest decoding functionality, I would think it is baked into the app directly I tried to sort functions by size, there were a few large ones with seemingly many float datatypes but I have no experience in sampling code :/ |
Can the new player play HCAs of previous versions? |
FYI, I'm using the "lite" version of the SDK (ADX2LE), not the full version (ADX2). It can only generate type-0 HCA (in plain text). Its player treats all HCAs as type-0; maybe it can recognize type-1. In all, lite version does not provide a way to encrypt (in Atom Craft) or decrypt (Atom Viewer). There is no place to enter encryption keys. |
You can use this file to run a test. The key is |
Okay I found an ACB of Theater Days' opening music shipped with the APK, plays properly with the correct key as well |
@hozuki I noticed that some fields in the header are XORed with 0x80 as follows: |
That's normal. When reading HCA header each header signature must be ANDed with The file I posted above is a homebrew HCA, encoded using the ADX2LE encoder and transformed by hcacc to apply encryption. Those signatures stay untouched so they are not XORed. |
After looking into |
I have a feeling there is certain new metadata inserted into the ACB that tampers with the HCA in some way; I can open the AWB wave bank file but playing the individual Wave tracks through the viewer gives noise even with the correct key set, whereas if I loaded the ACB and played it through the cues it then works normally |
Weird, acb contains an inline awb (~11KB), but it should be empty since there's a awb by the side Oops, I used another acb grabbed from ipa, attached one has ~7KB inline awb
|
I think this inline AWB in some way affects playback of the underlying HCA If you look at CpkMaker.dll of latest SDK, the AWB header inside CUtf class/CBinary initializes the Alignment field to be some large out of range number, older AWB format had it at 32 unless set |
The alignments in new versions should be masked with |
I updated ACB file parsing and extracting in two commits. I haven't pushed to the upstream yet. Here are all the files included in the ACB. Some are unnamed (not appearing in the cue table). |
I think the higher bits do not affect decryption (not decoding, sorry). If you directly play the extracted HCA (so no interference from ACB stuff) using the key it should still be OK. If so the truth will lie in HCA decoder itself. |
I just tried it, still noise, even with correct key |
Well this is interesting... two-phase keys. |
I just dropped a link to the new CriAtomViewer in your steam to try |
@FZFalzar Thanks for the tool. I did some tests, including:
Here are some results:
An example of the internal AWB is |
To be clear, if the AWB is an external one, its header also appears in |
Thanks for your analysis so far, I think it has to do with how all the assets are marked as StreamingAssets using the API |
That still didn't anwser the full question, where is the "switch" and how does it affect later prodecures. Some interesting facts observed:
I located the decoding functions in Atom Viewer. The code seems... different from known source code. There are also some new tables. Maybe it is because of many interferences. I'm not able to go through it yet. |
I so happen to have a 2017 version of the SDK, what's peculiar is that the CriAtomViewer in this version gives noise when ACB with correct key is inserted, unlike the latest one, something must have changed. I can pass you this one too |
@FZFalzar Thank you. Some time ago I was going to ask if you can send a copy. But before I reply this message here (or on Steam) the decryption was done. So it is not needed; but you can still keep it for future research purposes, I guess. Again, thank you for your kindness. Now good news: I just found out what they do to the decryption. The "garbage" higher bits are used to get the real decryption key. I reversed about 15 functions, read them thoroughly, understood nearly every line, and then this tiny mod was revealed. Well you also need some RE techniques, static and dynamic (mostly static) analyses... And yes I decrypted and decoded the audio file. Here it is, as a proof. About the ACB itself. It is composed by 3 tracks (or 2, because the last two seems to be identical), all of which are mixed in the final playback. So the file directly extracted contains only the soundtrack (w/o human voice). Thanks to VGAudio, I made sure that the encoding/decoding skeleton, as well as the tables, are very unlikely to change, so I could focus on tracing the decryption keys. I'm very tired now so I'll write an article explaining the "new" encryption soon. Hopefully tomorrow. |
Is this "garbage" unique for each AFS2? |
Not that you're wrong, but if you're posting proof it might be better to post the decrypted HCA =P |
@Thealexbarney Fair enough. :D The original tracks (3 individual, not 2, I didn't decode all at first), and their type-0 equivalents (simply using |
Yes. CRI stores them in the two unused bytes, right beside the byte alignment. |
@blueskythlikesclouds An example of different key: |
Or you could read offset 0xE in the awb file. BTW, don't know if you know already, but VGAudio has an HCA encoder. Much faster than hcaenc.dll too. |
Yes I saw that. I accidentally found it in Google when I didn't know where to go. At that time I was beginning to reverse all the decoding code. When I opened the GH repo tree and found out it can encode HCA, I was shocked. Then I tried a bit with various files. Just playing. XD |
I get the feeling @hozuki DSP is a monster for the untrained, but really good work to all involved! I do hope this applies to new ACB/AWB formats and not just a one-off event for Dragalia. I doubt this is the case though since this is an implementation only CRIWARE can control I'm looking forward to reading the write-up, and I'd send beer money if I can :D |
wanted to clarify, since sonic colors ultimate shipped its xml files: it's actually the awb hash |
Hello again, I've been trying to use your tool to do extract+decrypt but I am encountering decryption errors. The key is correct because when I loaded the ACB into v2.98 CRIWARE SDK CriAtomViewer it plays fine. I have uploaded a sample AWB+ACB and key inside. Audio format is HCA
If you need a link to the SDK I am contactable via https://steamcommunity.com/id/fzfalzar
-Falz
bgm.zip
The text was updated successfully, but these errors were encountered: