[nstool] Fixed bugs in --titlekey processing.

This commit is contained in:
jakcron 2018-08-24 19:22:23 +08:00
parent 7831f5b291
commit 7b2d682203
2 changed files with 16 additions and 4 deletions

View file

@ -122,9 +122,21 @@ void EsTikProcess::displayTicket()
std::cout << " Title Key:" << std::endl; std::cout << " Title Key:" << std::endl;
std::cout << " EncMode: " << getTitleKeyPersonalisationStr(body.getTitleKeyEncType()) << std::endl; std::cout << " EncMode: " << getTitleKeyPersonalisationStr(body.getTitleKeyEncType()) << std::endl;
std::cout << " KeyGeneration: " << std::dec << (uint32_t)body.getCommonKeyId() << std::endl; std::cout << " KeyGeneration: " << std::dec << (uint32_t)body.getCommonKeyId() << std::endl;
if (body.getTitleKeyEncType() == nn::es::ticket::RSA2048)
{
std::cout << " Data:" << std::endl; std::cout << " Data:" << std::endl;
size_t size = body.getTitleKeyEncType() == nn::es::ticket::RSA2048 ? fnd::rsa::kRsa2048Size : fnd::aes::kAes128KeySize; for (size_t i = 0; i < 0x10; i++)
fnd::SimpleTextOutput::hexDump(body.getEncTitleKey(), size, 0x10, 6); std::cout << " " << fnd::SimpleTextOutput::arrayToString(body.getEncTitleKey() + 0x10*i, 0x10, true, ":") << std::endl;
}
else if (body.getTitleKeyEncType() == nn::es::ticket::AES128_CBC)
{
std::cout << " Data:" << std::endl;
std::cout << " " << fnd::SimpleTextOutput::arrayToString(body.getEncTitleKey(), 0x10, true, ":") << std::endl;
}
else
{
std::cout << " Data: <cannot display>" << std::endl;
}
std::cout << " Version: v" << _SPLIT_VER(body.getTicketVersion()); std::cout << " Version: v" << _SPLIT_VER(body.getTicketVersion());
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)) if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))

View file

@ -431,7 +431,7 @@ void UserSettings::populateKeyset(sCmdArgs& args)
{ {
fnd::aes::sAes128Key tmp_key; fnd::aes::sAes128Key tmp_key;
fnd::Vec<byte_t> tmp_raw; fnd::Vec<byte_t> tmp_raw;
fnd::SimpleTextOutput::stringToArray(args.nca_bodykey.var, tmp_raw); fnd::SimpleTextOutput::stringToArray(args.nca_titlekey.var, tmp_raw);
if (tmp_raw.size() != sizeof(fnd::aes::sAes128Key)) if (tmp_raw.size() != sizeof(fnd::aes::sAes128Key))
throw fnd::Exception(kModuleName, "Key: \"--titlekey\" has incorrect length"); throw fnd::Exception(kModuleName, "Key: \"--titlekey\" has incorrect length");
memcpy(tmp_key.key, tmp_raw.data(), 16); memcpy(tmp_key.key, tmp_raw.data(), 16);