From 6b8cb2ee41e6e2f861638e187a007c7f804999b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 9 May 2017 20:56:42 +0200 Subject: [PATCH] IOS/ES: Handle fake-signed tickets properly Fake-signed tickets have a bogus common key index, in which case we must assume and use the normal common key to decrypt contents. --- Source/Core/Core/IOS/ES/Formats.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 2e823bdc80..43d56b7fdf 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -289,9 +289,15 @@ std::vector TicketReader::GetTitleKey() const { u8 iv[16] = {}; std::copy_n(&m_bytes[offsetof(Ticket, title_id)], sizeof(Ticket::title_id), iv); - auto common_key_handle = m_bytes.at(offsetof(Ticket, common_key_index)) == 0 ? - HLE::IOSC::HANDLE_COMMON_KEY : - HLE::IOSC::HANDLE_NEW_COMMON_KEY; + + const u8 index = m_bytes.at(offsetof(Ticket, common_key_index)); + auto common_key_handle = + index != 1 ? HLE::IOSC::HANDLE_COMMON_KEY : HLE::IOSC::HANDLE_NEW_COMMON_KEY; + if (index != 0 && index != 1) + { + WARN_LOG(IOS_ES, "Bad common key index for title %016" PRIx64 ": %u -- using common key 0", + GetTitleId(), index); + } std::vector key(16); HLE::IOSC iosc;