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:
Hykem 2014-03-30 21:09:49 +01:00
parent e6aa1a9553
commit 196c2ffe5b
20 changed files with 2891 additions and 821 deletions

View file

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "Crypto/unedat.h"
#include "sceNp.h"
void sceNp_init();
@ -23,8 +23,8 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr)
{
sceNp.Warning("sceNpDrmIsAvailable(k_licensee_addr=0x%x, drm_path_addr=0x%x)", k_licensee_addr, drm_path_addr);
wxString k_licensee_str;
wxString drm_path = Memory.ReadString(drm_path_addr);
wxString k_licensee_str;
u8 k_licensee[0x10];
for(int i = 0; i < 0x10; i++)
{
@ -35,6 +35,41 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr)
sceNp.Warning("sceNpDrmIsAvailable: Found DRM license file at %s", drm_path.wx_str());
sceNp.Warning("sceNpDrmIsAvailable: Using k_licensee 0x%s", k_licensee_str.wx_str());
// Set the necessary file paths.
wxString drm_file_name = drm_path.AfterLast('/');
wxString titleID = drm_path.AfterFirst('/').AfterFirst('/').AfterFirst('/').BeforeFirst('/');
wxString enc_drm_path = wxGetCwd() + drm_path;
wxString dec_drm_path = wxGetCwd() + "/dev_hdd1/" + titleID + "/" + drm_file_name;
wxString rap_dir_path = wxGetCwd() + "/dev_usb000/";
wxString rap_file_path = rap_dir_path;
// Search dev_usb000 for a compatible RAP file.
vfsDir *raps_dir = new vfsDir(rap_dir_path);
if (!raps_dir->IsOpened())
sceNp.Warning("sceNpDrmIsAvailable: Can't find RAP file for DRM!");
else
{
Array<DirEntryInfo> entries = raps_dir->GetEntries();
for (unsigned int i = 0; i < entries.GetCount(); i++)
{
if (entries[i].name.Contains(titleID))
{
rap_file_path += entries[i].name;
break;
}
}
}
// Create a new directory under dev_hdd1/titleID to hold the decrypted data.
wxString tmp_dir = wxGetCwd() + "/dev_hdd1/" + titleID;
if (!wxDir::Exists(tmp_dir))
wxMkdir(wxGetCwd() + "/dev_hdd1/" + titleID);
// Decrypt this EDAT using the supplied k_licensee and matching RAP file.
DecryptEDAT(enc_drm_path.ToStdString(), dec_drm_path.ToStdString(), 8, rap_file_path.ToStdString(), k_licensee, false);
return CELL_OK;
}