IOS/ES: Verify containers in ImportTmd

This commit is contained in:
Léo Lam 2017-06-11 22:10:33 +02:00
parent 54025da00f
commit 36c5caacf4
1 changed files with 14 additions and 1 deletions

View File

@ -100,10 +100,23 @@ ReturnCode ES::ImportTmd(Context& context, const std::vector<u8>& 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<u8> 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;