Dump in the logs xbe signature info
This commit is contained in:
parent
99770ffea6
commit
96dc895916
|
@ -828,3 +828,29 @@ bool Xbe::CheckXbeSignature()
|
|||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
bool Xbe::LoadRSAkey()
|
||||
{
|
||||
bool bSuccess = false;
|
||||
FILE* fp = fopen((std::string(szFolder_CxbxReloadedData) + std::string("\\RSAkey.bin")).c_str(), "rb");
|
||||
|
||||
if (fp != nullptr) {
|
||||
// Determine the size of RSAkey.bin
|
||||
fseek(fp, 0, SEEK_END);
|
||||
long size = ftell(fp);
|
||||
rewind(fp);
|
||||
|
||||
// Ensure that RSAkey.bin is 284 bytes and has a valid magic signature
|
||||
if (size == 284) {
|
||||
UCHAR temp[284] = { 0 };
|
||||
fread(temp, 284, 1, fp);
|
||||
if (!memcmp(temp, "RSA1", 4)) {
|
||||
memcpy(xboxkrnl::XePublicKeyData, temp, 284);
|
||||
bSuccess = true;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,9 @@ class Xbe : public Error
|
|||
// Convert game region field to string
|
||||
const char *GameRegionToString();
|
||||
|
||||
// load the rsa key used to validate the signature of the xbe
|
||||
bool LoadRSAkey();
|
||||
|
||||
// Xbe header
|
||||
#include "AlignPrefix1.h"
|
||||
struct Header
|
||||
|
|
|
@ -81,6 +81,7 @@ std::string XbePrinter::GenXbeInfo()
|
|||
info.append(GenDumpHeader());
|
||||
info.append(GenXbeHeaderInfo());
|
||||
info.append(GenXbeCertificateInfo());
|
||||
info.append(ValidateXbeSignature());
|
||||
info.append(GenSectionInfo());
|
||||
info.append(GenLibraryVersions());
|
||||
info.append(GenTLS());
|
||||
|
@ -285,6 +286,18 @@ std::string XbePrinter::GenGeneralHeaderInfo2()
|
|||
return text.str();
|
||||
}
|
||||
|
||||
std::string XbePrinter::ValidateXbeSignature()
|
||||
{
|
||||
std::string text("\nMissing RSA key. Unable to verify xbe signature\n\n");
|
||||
if (Xbe_to_print->LoadRSAkey()) {
|
||||
text = "\nInvalid xbe signature. Homebrew, tampered or pirated xbe?\n\n";
|
||||
if (Xbe_to_print->CheckXbeSignature()) {
|
||||
text = "\nValid xbe signature. Xbe is legit\n\n";
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string XbePrinter::GenXbeCertificateInfo()
|
||||
{
|
||||
std::string text;
|
||||
|
|
|
@ -65,6 +65,8 @@ class XbePrinter
|
|||
std::string GenInitFlags();
|
||||
std::string GenGeneralHeaderInfo2();
|
||||
|
||||
std::string ValidateXbeSignature();
|
||||
|
||||
std::string GenXbeCertificateInfo();
|
||||
std::string GenCertificateHeader();
|
||||
std::string GenAlternateTitleIDs();
|
||||
|
|
|
@ -812,6 +812,19 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
return;
|
||||
}
|
||||
|
||||
// Check the signature of the xbe if possible
|
||||
if (CxbxKrnl_Xbe->LoadRSAkey()) {
|
||||
if (CxbxKrnl_Xbe->CheckXbeSignature()) {
|
||||
printf("[0x%X] INIT: Valid xbe signature. Xbe is legit\n", GetCurrentThreadId());
|
||||
}
|
||||
else {
|
||||
EmuWarning("Invalid xbe signature. Homebrew, tampered or pirated xbe?");
|
||||
}
|
||||
}
|
||||
else {
|
||||
EmuWarning("Missing RSA key. Unable to verify xbe signature");
|
||||
}
|
||||
|
||||
// Detect XBE type :
|
||||
g_XbeType = GetXbeType(&CxbxKrnl_Xbe->m_Header);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->CxbxKrnl->EmuRsa.cpp
|
||||
// * Cxbx->CxbxKrnl->EmuRsa.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->CxbxKrnl->EmuRsa.h
|
||||
// * Cxbx->CxbxKrnl->EmuRsa.h
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
|
@ -35,6 +35,8 @@
|
|||
#ifndef EMURSA_H
|
||||
#define EMURSA_H
|
||||
|
||||
#pragma pack(4)
|
||||
|
||||
typedef struct _RSA_PUBLIC_KEY
|
||||
{
|
||||
union
|
||||
|
@ -52,6 +54,7 @@ typedef struct _RSA_PUBLIC_KEY
|
|||
};
|
||||
}RSA_PUBLIC_KEY;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
void RSAdecrypt(unsigned char* c_number, unsigned char* cryptbuffer, RSA_PUBLIC_KEY key);
|
||||
bool Verifyhash(unsigned char* hash, unsigned char* decryptBuffer, RSA_PUBLIC_KEY key);
|
||||
|
|
Loading…
Reference in New Issue