diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index 053d65c8cc..37c5472b8f 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -100,10 +100,23 @@ ReturnCode ES::ImportTmd(Context& context, const std::vector& tmd_bytes) // Ioctlv 0x2b writes the TMD to /tmp/title.tmd (for imports) and doesn't seem to write it // to either /import or /title. So here we simply have to set the import TMD. context.title_import.tmd.SetBytes(tmd_bytes); - // TODO: validate TMDs and return the proper error code (-1027) if the signature type is invalid. if (!context.title_import.tmd.IsValid()) return ES_EINVAL; + std::vector cert_store; + ReturnCode ret = ReadCertStore(&cert_store); + if (ret != IPC_SUCCESS) + return ret; + + ret = VerifyContainer(VerifyContainerType::TMD, VerifyMode::UpdateCertStore, + context.title_import.tmd, cert_store); + if (ret != IPC_SUCCESS) + { + // Reset the import context so that further calls consider the state as invalid. + context.title_import.tmd.SetBytes({}); + return ret; + } + if (!InitImport(context.title_import.tmd.GetTitleId())) return ES_EIO;