mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
Use boolean values in unedat
This commit is contained in:
parent
4a75f44d47
commit
56488a4ac9
1 changed files with 17 additions and 18 deletions
|
@ -542,7 +542,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int validate_dev_klic(const u8* klicensee, NPD_HEADER *npd)
|
bool validate_dev_klic(const u8* klicensee, NPD_HEADER *npd)
|
||||||
{
|
{
|
||||||
unsigned char dev[0x60] = { 0 };
|
unsigned char dev[0x60] = { 0 };
|
||||||
|
|
||||||
|
@ -564,24 +564,24 @@ int validate_dev_klic(const u8* klicensee, NPD_HEADER *npd)
|
||||||
if (!klic)
|
if (!klic)
|
||||||
{
|
{
|
||||||
// Allow empty dev hash.
|
// Allow empty dev hash.
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Generate klicensee xor key.
|
|
||||||
u128 key = klic ^ std::bit_cast<u128>(NP_OMAC_KEY_2);
|
|
||||||
|
|
||||||
// Hash with generated key and compare with dev_hash.
|
// Generate klicensee xor key.
|
||||||
return cmac_hash_compare(reinterpret_cast<uchar*>(&key), 0x10, dev, 0x60, npd->dev_hash, 0x10);
|
u128 key = klic ^ std::bit_cast<u128>(NP_OMAC_KEY_2);
|
||||||
}
|
|
||||||
|
// Hash with generated key and compare with dev_hash.
|
||||||
|
return cmac_hash_compare(reinterpret_cast<uchar*>(&key), 0x10, dev, 0x60, npd->dev_hash, 0x10);
|
||||||
}
|
}
|
||||||
|
|
||||||
int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *npd, bool verbose)
|
bool validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *npd, bool verbose)
|
||||||
{
|
{
|
||||||
int title_hash_result = 0;
|
if (!file_name)
|
||||||
int dev_hash_result = 0;
|
{
|
||||||
|
fmt::throw_exception("Empty filename");
|
||||||
|
}
|
||||||
|
|
||||||
const s32 file_name_length = ::narrow<s32>(std::strlen(file_name));
|
const usz file_name_length = std::strlen(file_name);
|
||||||
const usz buf_len = 0x30 + file_name_length;
|
const usz buf_len = 0x30 + file_name_length;
|
||||||
|
|
||||||
std::unique_ptr<u8[]> buf(new u8[buf_len]);
|
std::unique_ptr<u8[]> buf(new u8[buf_len]);
|
||||||
|
@ -604,7 +604,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
|
||||||
|
|
||||||
// Hash with NPDRM_OMAC_KEY_3 and compare with title_hash.
|
// Hash with NPDRM_OMAC_KEY_3 and compare with title_hash.
|
||||||
// Try to ignore case sensivity with file extension
|
// Try to ignore case sensivity with file extension
|
||||||
title_hash_result =
|
const bool title_hash_result =
|
||||||
cmac_hash_compare(const_cast<u8*>(NP_OMAC_KEY_3), 0x10, buf.get(), buf_len, npd->title_hash, 0x10) ||
|
cmac_hash_compare(const_cast<u8*>(NP_OMAC_KEY_3), 0x10, buf.get(), buf_len, npd->title_hash, 0x10) ||
|
||||||
cmac_hash_compare(const_cast<u8*>(NP_OMAC_KEY_3), 0x10, buf_lower.get(), buf_len, npd->title_hash, 0x10) ||
|
cmac_hash_compare(const_cast<u8*>(NP_OMAC_KEY_3), 0x10, buf_lower.get(), buf_len, npd->title_hash, 0x10) ||
|
||||||
cmac_hash_compare(const_cast<u8*>(NP_OMAC_KEY_3), 0x10, buf_upper.get(), buf_len, npd->title_hash, 0x10);
|
cmac_hash_compare(const_cast<u8*>(NP_OMAC_KEY_3), 0x10, buf_upper.get(), buf_len, npd->title_hash, 0x10);
|
||||||
|
@ -617,10 +617,9 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
|
||||||
edat_log.warning("EDAT: NPD title hash is invalid!");
|
edat_log.warning("EDAT: NPD title hash is invalid!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool dev_hash_result = validate_dev_klic(klicensee, npd);
|
||||||
|
|
||||||
dev_hash_result = validate_dev_klic(klicensee, npd);
|
return title_hash_result && dev_hash_result;
|
||||||
|
|
||||||
return (title_hash_result && dev_hash_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_npd_edat_header(const fs::file* input, NPD_HEADER& NPD, EDAT_HEADER& EDAT)
|
void read_npd_edat_header(const fs::file* input, NPD_HEADER& NPD, EDAT_HEADER& EDAT)
|
||||||
|
@ -913,7 +912,7 @@ bool EDATADecrypter::ReadHeader()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// verify key
|
// verify key
|
||||||
if (validate_dev_klic(reinterpret_cast<uchar*>(&dev_key), &npdHeader) == 0)
|
if (!validate_dev_klic(reinterpret_cast<uchar*>(&dev_key), &npdHeader))
|
||||||
{
|
{
|
||||||
edat_log.error("EDAT: Failed validating klic");
|
edat_log.error("EDAT: Failed validating klic");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue