mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 07:21:25 +12:00
Updated the crypto engine:
- Updated AES and SHA-1 source code; - Fixed a few code warnings; - Implemented EDAT/SDAT decryption. Started SPURS implementation: - Added an internal SPURSManager class draft; - Added several drafts for cellSpurs functions. Implemented key.edat decryption in sceNpDrmIsAvailable: - NOTE: Currently, the decrypted key.edat is stored under dev_hdd1/titleID and the user must replace this file in dev_hdd0. This behavior will change in the future as it's currently intended for controlled testing only.
This commit is contained in:
parent
e6aa1a9553
commit
196c2ffe5b
20 changed files with 2891 additions and 821 deletions
|
@ -92,9 +92,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32)
|
|||
{
|
||||
ControlInfo* cinfo = new ControlInfo();
|
||||
cinfo->Load(self_f);
|
||||
|
||||
i += cinfo->size;
|
||||
|
||||
ctrlinfo_arr.Move(cinfo);
|
||||
}
|
||||
|
||||
|
@ -155,12 +153,12 @@ void SELFDecrypter::ShowHeaders(bool isElf32)
|
|||
ConLog.Write("----------------------------------------------------");
|
||||
ConLog.Write("ELF program headers");
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
for(int i = 0; i < ((isElf32) ? phdr32_arr.GetCount() : phdr64_arr.GetCount()); i++)
|
||||
for(unsigned int i = 0; i < ((isElf32) ? phdr32_arr.GetCount() : phdr64_arr.GetCount()); i++)
|
||||
isElf32 ? phdr32_arr[i].Show() : phdr64_arr[i].Show();
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
ConLog.Write("Section info");
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
for(int i = 0; i < secinfo_arr.GetCount(); i++)
|
||||
for(unsigned int i = 0; i < secinfo_arr.GetCount(); i++)
|
||||
secinfo_arr[i].Show();
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
ConLog.Write("SCE version info");
|
||||
|
@ -169,12 +167,12 @@ void SELFDecrypter::ShowHeaders(bool isElf32)
|
|||
ConLog.Write("----------------------------------------------------");
|
||||
ConLog.Write("Control info");
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
for(int i = 0; i < ctrlinfo_arr.GetCount(); i++)
|
||||
for(unsigned int i = 0; i < ctrlinfo_arr.GetCount(); i++)
|
||||
ctrlinfo_arr[i].Show();
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
ConLog.Write("ELF section headers");
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
for(int i = 0; i < ((isElf32) ? shdr32_arr.GetCount() : shdr64_arr.GetCount()); i++)
|
||||
for(unsigned int i = 0; i < ((isElf32) ? shdr32_arr.GetCount() : shdr64_arr.GetCount()); i++)
|
||||
isElf32 ? shdr32_arr[i].Show() : shdr64_arr[i].Show();
|
||||
ConLog.Write("----------------------------------------------------");
|
||||
}
|
||||
|
@ -187,7 +185,7 @@ bool SELFDecrypter::DecryptNPDRM(u8 *metadata, u32 metadata_size)
|
|||
u8 npdrm_iv[0x10];
|
||||
|
||||
// Parse the control info structures to find the NPDRM control info.
|
||||
for(int i = 0; i < ctrlinfo_arr.GetCount(); i++)
|
||||
for(unsigned int i = 0; i < ctrlinfo_arr.GetCount(); i++)
|
||||
{
|
||||
if (ctrlinfo_arr[i].type == 3)
|
||||
{
|
||||
|
@ -310,7 +308,7 @@ bool SELFDecrypter::LoadMetadata()
|
|||
|
||||
// Load the metadata section headers.
|
||||
meta_shdr.Clear();
|
||||
for (int i = 0; i < meta_hdr.section_count; i++)
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
{
|
||||
MetadataSectionHeader* m_shdr = new MetadataSectionHeader();
|
||||
m_shdr->Load(metadata_headers + sizeof(meta_hdr) + sizeof(MetadataSectionHeader) * i);
|
||||
|
@ -330,7 +328,7 @@ bool SELFDecrypter::DecryptData()
|
|||
aes_context aes;
|
||||
|
||||
// Calculate the total data size.
|
||||
for (int i = 0; i < meta_hdr.section_count; i++)
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
{
|
||||
if (meta_shdr[i].encrypted == 3)
|
||||
{
|
||||
|
@ -346,7 +344,7 @@ bool SELFDecrypter::DecryptData()
|
|||
u32 data_buf_offset = 0;
|
||||
|
||||
// Parse the metadata section headers to find the offsets of encrypted data.
|
||||
for (int i = 0; i < meta_hdr.section_count; i++)
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
{
|
||||
size_t ctr_nc_off = 0;
|
||||
u8 ctr_stream_block[0x10];
|
||||
|
@ -370,7 +368,7 @@ bool SELFDecrypter::DecryptData()
|
|||
self_f.Seek(meta_shdr[i].data_offset);
|
||||
self_f.Read(buf, meta_shdr[i].data_size);
|
||||
|
||||
// Zero out our ctr nonce
|
||||
// Zero out our ctr nonce.
|
||||
memset(ctr_stream_block, 0, sizeof(ctr_stream_block));
|
||||
|
||||
// Perform AES-CTR encryption on the data blocks.
|
||||
|
@ -414,7 +412,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
|||
for(u32 i = 0; i < elf32_hdr.e_phnum; ++i)
|
||||
WritePhdr(e, phdr32_arr[i]);
|
||||
|
||||
for (int i = 0; i < meta_hdr.section_count; i++)
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
{
|
||||
// PHDR type.
|
||||
if (meta_shdr[i].type == 2)
|
||||
|
@ -447,7 +445,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
|||
WritePhdr(e, phdr64_arr[i]);
|
||||
|
||||
// Write data.
|
||||
for (int i = 0; i < meta_hdr.section_count; i++)
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
{
|
||||
// PHDR type.
|
||||
if (meta_shdr[i].type == 2)
|
||||
|
@ -533,8 +531,8 @@ bool SELFDecrypter::GetKeyFromRap(u8 *content_id, u8 *npdrm_key)
|
|||
rap_file.Read(rap_key, 0x10);
|
||||
rap_file.Close();
|
||||
|
||||
// Call the key vault to convert the RAP key.
|
||||
key_v.RapToRif(rap_key, npdrm_key);
|
||||
// Convert the RAP key.
|
||||
rap_to_rif(rap_key, npdrm_key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue