Skip to content

Commit

Permalink
Add a Verify tab to game properties
Browse files Browse the repository at this point in the history
  • Loading branch information
JosJuice committed Apr 9, 2019
1 parent c885fed commit 84cbd51
Show file tree
Hide file tree
Showing 17 changed files with 1,006 additions and 32 deletions.
41 changes: 21 additions & 20 deletions Source/Core/Core/IOS/ES/ES.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ class ES final : public Device

bool CreateTitleDirectories(u64 title_id, u16 group_id) const;

enum class VerifyContainerType
{
TMD,
Ticket,
Device,
};
enum class VerifyMode
{
// Whether or not new certificates should be added to the certificate store (/sys/cert.sys).
DoNotUpdateCertStore,
UpdateCertStore,
};
// On success, if issuer_handle is non-null, the IOSC object for the issuer will be written to it.
// The caller is responsible for using IOSC_DeleteObject.
ReturnCode VerifyContainer(VerifyContainerType type, VerifyMode mode,
const IOS::ES::SignedBlobReader& signed_blob,
const std::vector<u8>& cert_chain, u32* issuer_handle = nullptr);
ReturnCode VerifyContainer(VerifyContainerType type, VerifyMode mode,
const IOS::ES::CertReader& certificate,
const std::vector<u8>& cert_chain, u32 certificate_iosc_handle);

private:
enum
{
Expand Down Expand Up @@ -308,29 +329,9 @@ class ES final : public Device
ReturnCode CheckStreamKeyPermissions(u32 uid, const u8* ticket_view,
const IOS::ES::TMDReader& tmd) const;

enum class VerifyContainerType
{
TMD,
Ticket,
Device,
};
enum class VerifyMode
{
// Whether or not new certificates should be added to the certificate store (/sys/cert.sys).
DoNotUpdateCertStore,
UpdateCertStore,
};
bool IsIssuerCorrect(VerifyContainerType type, const IOS::ES::CertReader& issuer_cert) const;
ReturnCode ReadCertStore(std::vector<u8>* buffer) const;
ReturnCode WriteNewCertToStore(const IOS::ES::CertReader& cert);
// On success, if issuer_handle is non-null, the IOSC object for the issuer will be written to it.
// The caller is responsible for using IOSC_DeleteObject.
ReturnCode VerifyContainer(VerifyContainerType type, VerifyMode mode,
const IOS::ES::SignedBlobReader& signed_blob,
const std::vector<u8>& cert_chain, u32* issuer_handle = nullptr);
ReturnCode VerifyContainer(VerifyContainerType type, VerifyMode mode,
const IOS::ES::CertReader& certificate,
const std::vector<u8>& cert_chain, u32 certificate_iosc_handle);

// Start a title import.
bool InitImport(const IOS::ES::TMDReader& tmd);
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/IOS/ES/Formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ u64 TicketReader::GetTitleId() const
return Common::swap64(m_bytes.data() + offsetof(Ticket, title_id));
}

u8 TicketReader::GetCommonKeyIndex() const
{
return m_bytes[offsetof(Ticket, common_key_index)];
}

std::array<u8, 16> TicketReader::GetTitleKey(const HLE::IOSC& iosc) const
{
u8 iv[16] = {};
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/IOS/ES/Formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class TicketReader final : public SignedBlobReader

u32 GetDeviceId() const;
u64 GetTitleId() const;
u8 GetCommonKeyIndex() const;
// Get the decrypted title key.
std::array<u8, 16> GetTitleKey(const HLE::IOSC& iosc) const;
// Same as the above version, but guesses the console type depending on the issuer
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_library(discio
Volume.cpp
VolumeFileBlobReader.cpp
VolumeGC.cpp
VolumeVerifier.cpp
VolumeWad.cpp
VolumeWii.cpp
WiiSaveBanner.cpp
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DiscIO/DiscExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ std::string NameForPartitionType(u32 partition_type, bool include_prefix)
return "UPDATE";
case PARTITION_CHANNEL:
return "CHANNEL";
case PARTITION_INSTALL:
// wit doesn't recognize the name "INSTALL", so we can't use it when naming partition folders
if (!include_prefix)
return "INSTALL";
// [[fallthrough]]
default:
const std::string type_as_game_id{static_cast<char>((partition_type >> 24) & 0xFF),
static_cast<char>((partition_type >> 16) & 0xFF),
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DiscIO/DiscExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class Volume;

constexpr u32 PARTITION_DATA = 0;
constexpr u32 PARTITION_UPDATE = 1;
constexpr u32 PARTITION_CHANNEL = 2;
constexpr u32 PARTITION_CHANNEL = 2; // Mario Kart Wii, Wii Fit, Wii Fit Plus, Rabbids Go Home
constexpr u32 PARTITION_INSTALL = 3; // Dragon Quest X only

std::string NameForPartitionType(u32 partition_type, bool include_prefix);

Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DiscIO/DiscIO.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<ClCompile Include="Volume.cpp" />
<ClCompile Include="VolumeFileBlobReader.cpp" />
<ClCompile Include="VolumeGC.cpp" />
<ClCompile Include="VolumeVerifier.cpp" />
<ClCompile Include="VolumeWad.cpp" />
<ClCompile Include="VolumeWii.cpp" />
<ClCompile Include="WbfsBlob.cpp" />
Expand All @@ -75,6 +76,7 @@
<ClInclude Include="Volume.h" />
<ClInclude Include="VolumeFileBlobReader.h" />
<ClInclude Include="VolumeGC.h" />
<ClInclude Include="VolumeVerifier.h" />
<ClInclude Include="VolumeWad.h" />
<ClInclude Include="VolumeWii.h" />
<ClInclude Include="WbfsBlob.h" />
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/DiscIO/DiscIO.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<ClCompile Include="WiiSaveBanner.cpp">
<Filter>NAND</Filter>
</ClCompile>
<ClCompile Include="VolumeVerifier.cpp">
<Filter>Volume</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="DiscScrubber.h">
Expand Down Expand Up @@ -149,6 +152,9 @@
<ClInclude Include="WiiSaveBanner.h">
<Filter>NAND</Filter>
</ClInclude>
<ClInclude Include="VolumeVerifier.h">
<Filter>Volume</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
Expand Down
Loading

0 comments on commit 84cbd51

Please sign in to comment.