Load HCA encryption keys from external file (songname.extkey or .extkey)

This commit is contained in:
bnnm 2016-12-04 14:12:23 +01:00
parent 800a700b4e
commit bf7d3da39a

View File

@ -9,9 +9,8 @@ VGMSTREAM * init_vgmstream_hca(STREAMFILE *streamFile) {
}
VGMSTREAM * init_vgmstream_hca_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size) {
/* These I don't know about... */
static const unsigned int ciphKey1=0x30DBE1AB;
static const unsigned int ciphKey2=0xCC554639;
unsigned int ciphKey1;
unsigned int ciphKey2;
char filename[PATH_LIMIT];
@ -51,6 +50,20 @@ VGMSTREAM * init_vgmstream_hca_offset(STREAMFILE *streamFile, uint64_t start, ui
hca = (clHCA *)(hca_file + 1);
/* try to find key in external file */
{
uint8_t keybuf[8];
if ( read_key_file(keybuf, 8, streamFile) ) {
ciphKey2 = get_32bitBE(keybuf+0);
ciphKey1 = get_32bitBE(keybuf+4);
} else {
/* PSO2 */
ciphKey2=0xCC554639;
ciphKey1=0x30DBE1AB;
}
}
clHCA_clear(hca, ciphKey1, ciphKey2);
if (clHCA_Decode(hca, hca_data, header_size, 0) < 0) goto fail;