diff --git a/src/ZoneCommon/Game/IW4/ZoneConstantsIW4.h b/src/ZoneCommon/Game/IW4/ZoneConstantsIW4.h index a9940448..cb36b045 100644 --- a/src/ZoneCommon/Game/IW4/ZoneConstantsIW4.h +++ b/src/ZoneCommon/Game/IW4/ZoneConstantsIW4.h @@ -26,7 +26,7 @@ namespace IW4 static_assert(std::char_traits::length(MAGIC_IW4X) == sizeof(ZoneHeader::m_magic) - sizeof(uint32_t)); 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, 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, diff --git a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp index 2b0d29df..14d46ef4 100644 --- a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp @@ -47,7 +47,6 @@ namespace std::optional InspectZoneHeaderIw4(const ZoneHeader& header) { - if (endianness::FromLittleEndian(header.m_version) == ZoneConstants::ZONE_VERSION_PC) { if (!memcmp(header.m_magic, ZoneConstants::MAGIC_IW4X, std::char_traits::length(ZoneConstants::MAGIC_IW4X))) @@ -168,21 +167,25 @@ namespace { auto rsa = cryptography::CreateRsa(cryptography::HashingAlgorithm::RSA_HASH_SHA256, cryptography::RsaPaddingMode::RSA_PADDING_PSS); + bool keySetSuccessful; if (platform == GamePlatform::PC) { - if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD))) - { - con::error("Invalid public key for signature checking"); - return nullptr; - } + keySetSuccessful = rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_PC, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_PC)); } else if (platform == GamePlatform::XBOX) { - if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON))) - { - con::error("Invalid public key for signature checking"); - return nullptr; - } + 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"); + return nullptr; } return rsa; @@ -279,10 +282,9 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH // Skip timestamp 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) - { zoneLoader->AddLoadingStep(step::CreateStepSkipZoneImageHeaders()); - } // Add steps for loading the auth header which also contain the signature of the zone if it is signed. AddAuthHeaderSteps(*inspectResult, *zoneLoader, fileName);