MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / decrypt_self

Function decrypt_self

rpcs3/Crypto/unself.cpp:1359–1414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357}
1358
1359fs::file decrypt_self(const fs::file& elf_or_self, const u8* klic_key, SelfAdditionalInfo* out_info)
1360{
1361 if (out_info)
1362 {
1363 *out_info = {};
1364 }
1365
1366 if (!elf_or_self)
1367 {
1368 return fs::file{};
1369 }
1370
1371 elf_or_self.seek(0);
1372
1373 // Check SELF header first. Check for a debug SELF.
1374 if (elf_or_self.size() >= 4 && elf_or_self.read<u32>() == "SCE\0"_u32)
1375 {
1376 if (fs::file res = CheckDebugSelf(elf_or_self))
1377 {
1378 // TODO: Decrypt
1379 return res;
1380 }
1381
1382 // Check the ELF file class (32 or 64 bit).
1383 const bool isElf32 = IsSelfElf32(elf_or_self);
1384
1385 // Start the decrypter on this SELF file.
1386 SELFDecrypter self_dec(elf_or_self);
1387
1388 // Load the SELF file headers.
1389 if (!self_dec.LoadHeaders(isElf32, out_info))
1390 {
1391 self_log.error("Failed to load SELF file headers!");
1392 return fs::file{};
1393 }
1394
1395 // Load and decrypt the SELF file metadata.
1396 if (!self_dec.LoadMetadata(klic_key))
1397 {
1398 (klic_key ? self_log.notice : self_log.error)("Failed to load SELF file metadata!");
1399 return fs::file{};
1400 }
1401
1402 // Decrypt the SELF file data.
1403 if (!self_dec.DecryptData())
1404 {
1405 (klic_key ? self_log.notice : self_log.error)("Failed to decrypt SELF file data!");
1406 return fs::file{};
1407 }
1408
1409 // Make a new ELF file from this SELF.
1410 return self_dec.MakeElf(isElf32);
1411 }
1412
1413 return {};
1414}
1415
1416bool verify_npdrm_self_headers(const fs::file& self, u8* klic_key, NPD_HEADER* npd_out)

Callers 15

fetchGameInfoFunction · 0.85
implMethod · 0.85
installRapFunction · 0.85
LoadMethod · 0.85
ppu_precompileFunction · 0.85
ppu_initializeFunction · 0.85
ppu_load_execFunction · 0.85
decryptMethod · 0.85
overlay_load_moduleFunction · 0.85
loadMethod · 0.85
sys_spu_image_openFunction · 0.85

Calls 9

CheckDebugSelfFunction · 0.85
IsSelfElf32Function · 0.85
LoadHeadersMethod · 0.80
errorMethod · 0.80
LoadMetadataMethod · 0.80
DecryptDataMethod · 0.80
MakeElfMethod · 0.80
seekMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected