mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-27 20:41:49 +00:00
chore: small adjustments to iw4 zone loading
This commit is contained in:
@@ -26,7 +26,7 @@ namespace IW4
|
|||||||
static_assert(std::char_traits<char>::length(MAGIC_IW4X) == sizeof(ZoneHeader::m_magic) - sizeof(uint32_t));
|
static_assert(std::char_traits<char>::length(MAGIC_IW4X) == sizeof(ZoneHeader::m_magic) - sizeof(uint32_t));
|
||||||
|
|
||||||
static constexpr const char* MAGIC_AUTH_HEADER = "IWffs100";
|
static constexpr const char* MAGIC_AUTH_HEADER = "IWffs100";
|
||||||
inline static const uint8_t RSA_PUBLIC_KEY_INFINITY_WARD[]{
|
inline static const uint8_t RSA_PUBLIC_KEY_INFINITY_WARD_PC[]{
|
||||||
0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xA5, 0x86, 0xCC, 0x18, 0xA9, 0x12, 0x17, 0x4F, 0x3A, 0xC9, 0x0C, 0xD2, 0x38, 0x5D,
|
0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xA5, 0x86, 0xCC, 0x18, 0xA9, 0x12, 0x17, 0x4F, 0x3A, 0xC9, 0x0C, 0xD2, 0x38, 0x5D,
|
||||||
0xDB, 0x67, 0x62, 0xA4, 0xE3, 0xD4, 0x42, 0x05, 0x8A, 0x57, 0x0C, 0x31, 0x4E, 0x19, 0xE4, 0xBA, 0x89, 0x73, 0x13, 0xDB, 0x72, 0x25, 0x63,
|
0xDB, 0x67, 0x62, 0xA4, 0xE3, 0xD4, 0x42, 0x05, 0x8A, 0x57, 0x0C, 0x31, 0x4E, 0x19, 0xE4, 0xBA, 0x89, 0x73, 0x13, 0xDB, 0x72, 0x25, 0x63,
|
||||||
0xB1, 0x2F, 0xD7, 0xF1, 0x08, 0x48, 0x34, 0x06, 0xD7, 0x84, 0x5F, 0xC8, 0xCF, 0x2F, 0xB6, 0xA3, 0x5A, 0x8F, 0x7E, 0xAA, 0x9D, 0x51, 0xE7,
|
0xB1, 0x2F, 0xD7, 0xF1, 0x08, 0x48, 0x34, 0x06, 0xD7, 0x84, 0x5F, 0xC8, 0xCF, 0x2F, 0xB6, 0xA3, 0x5A, 0x8F, 0x7E, 0xAA, 0x9D, 0x51, 0xE7,
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ namespace
|
|||||||
|
|
||||||
std::optional<ZoneLoaderInspectionResultIW4> InspectZoneHeaderIw4(const ZoneHeader& header)
|
std::optional<ZoneLoaderInspectionResultIW4> InspectZoneHeaderIw4(const ZoneHeader& header)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (endianness::FromLittleEndian(header.m_version) == ZoneConstants::ZONE_VERSION_PC)
|
if (endianness::FromLittleEndian(header.m_version) == ZoneConstants::ZONE_VERSION_PC)
|
||||||
{
|
{
|
||||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_IW4X, std::char_traits<char>::length(ZoneConstants::MAGIC_IW4X)))
|
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_IW4X, std::char_traits<char>::length(ZoneConstants::MAGIC_IW4X)))
|
||||||
@@ -168,22 +167,26 @@ namespace
|
|||||||
{
|
{
|
||||||
auto rsa = cryptography::CreateRsa(cryptography::HashingAlgorithm::RSA_HASH_SHA256, cryptography::RsaPaddingMode::RSA_PADDING_PSS);
|
auto rsa = cryptography::CreateRsa(cryptography::HashingAlgorithm::RSA_HASH_SHA256, cryptography::RsaPaddingMode::RSA_PADDING_PSS);
|
||||||
|
|
||||||
|
bool keySetSuccessful;
|
||||||
if (platform == GamePlatform::PC)
|
if (platform == GamePlatform::PC)
|
||||||
{
|
{
|
||||||
if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD)))
|
keySetSuccessful = rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_PC, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_PC));
|
||||||
{
|
|
||||||
con::error("Invalid public key for signature checking");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (platform == GamePlatform::XBOX)
|
else if (platform == GamePlatform::XBOX)
|
||||||
{
|
{
|
||||||
if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON)))
|
keySetSuccessful = rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con::error("No public key for platform");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keySetSuccessful)
|
||||||
{
|
{
|
||||||
con::error("Invalid public key for signature checking");
|
con::error("Invalid public key for signature checking");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return rsa;
|
return rsa;
|
||||||
}
|
}
|
||||||
@@ -279,10 +282,9 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH
|
|||||||
// Skip timestamp
|
// Skip timestamp
|
||||||
zoneLoader->AddLoadingStep(step::CreateStepSkipBytes(8));
|
zoneLoader->AddLoadingStep(step::CreateStepSkipBytes(8));
|
||||||
|
|
||||||
|
// Xbox fastfiles have an additional header of all included images outside the zone data
|
||||||
if (inspectResult->m_generic_result.m_platform == GamePlatform::XBOX)
|
if (inspectResult->m_generic_result.m_platform == GamePlatform::XBOX)
|
||||||
{
|
|
||||||
zoneLoader->AddLoadingStep(step::CreateStepSkipZoneImageHeaders());
|
zoneLoader->AddLoadingStep(step::CreateStepSkipZoneImageHeaders());
|
||||||
}
|
|
||||||
|
|
||||||
// Add steps for loading the auth header which also contain the signature of the zone if it is signed.
|
// Add steps for loading the auth header which also contain the signature of the zone if it is signed.
|
||||||
AddAuthHeaderSteps(*inspectResult, *zoneLoader, fileName);
|
AddAuthHeaderSteps(*inspectResult, *zoneLoader, fileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user