mirror of
https://github.com/naehrwert/scetool.git
synced 2025-04-25 14:17:46 +00:00
Update sce.cpp
Last 2 bytes of IV gets altered, a deeper look is needed. Simply backup IV, run decryption and if IV has changed, restore back. This fixes the computed digest of data, that can succesfully validate a signature or not. Probably aes encrypt suffers the same.
This commit is contained in:
parent
d78d8986c9
commit
9042cc4068
1 changed files with 8 additions and 0 deletions
8
sce.cpp
8
sce.cpp
|
@ -850,6 +850,10 @@ BOOL sce_decrypt_header(sce_buffer_ctxt_t *ctxt, u8 *metadata_info, u8 *keyset)
|
|||
if(ctxt->metai->key_pad[0] != 0x00 || ctxt->metai->iv_pad[0] != 0x00)
|
||||
return FALSE;
|
||||
|
||||
//Backup IV, next aes_crypt_ctr alters last 2 bytes
|
||||
u8 biv[0x10];
|
||||
memcpy(&biv, ctxt->metai->iv, 0x10);
|
||||
|
||||
//Decrypt metadata header, metadata section headers and keys.
|
||||
nc_off = 0;
|
||||
aes_setkey_enc(&aes_ctxt, ctxt->metai->key, METADATA_INFO_KEYBITS);
|
||||
|
@ -857,6 +861,10 @@ BOOL sce_decrypt_header(sce_buffer_ctxt_t *ctxt, u8 *metadata_info, u8 *keyset)
|
|||
ctxt->sceh->header_len - (sizeof(sce_header_t) + ctxt->sceh->metadata_offset + sizeof(metadata_info_t)),
|
||||
&nc_off, ctxt->metai->iv, sblk, (u8 *)ctxt->metah, (u8 *)ctxt->metah);
|
||||
|
||||
//Restore IV from its backup if changed
|
||||
if(memcmp(ctxt->metai->iv, biv, 0x10) != 0)
|
||||
memcpy(ctxt->metai->iv, &biv, 0x10);
|
||||
|
||||
//Fixup headers.
|
||||
_es_metadata_header(ctxt->metah);
|
||||
for(i = 0; i < ctxt->metah->section_count; i++)
|
||||
|
|
Loading…
Add table
Reference in a new issue