From 584edf1f3d307ef9344707d8e1a8a1def4a772f1 Mon Sep 17 00:00:00 2001 From: jakcron Date: Sat, 7 Apr 2018 16:03:39 +0800 Subject: [PATCH] [tiktool] Behind the scenes formating changes. --- programs/tiktool/source/main.cpp | 50 ++++++++++---------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/programs/tiktool/source/main.cpp b/programs/tiktool/source/main.cpp index 171e68d..478d5b2 100644 --- a/programs/tiktool/source/main.cpp +++ b/programs/tiktool/source/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include const std::string kTitleKeyPersonalisation[2] = @@ -13,12 +14,12 @@ const std::string kTitleKeyPersonalisation[2] = const std::string kLicenseType[6] = { - "PERMANENT", - "DEMO", - "TRIAL", - "RENTAL", - "SUBSCRIPTION", - "SERVICE" + "Permanent", + "Demo", + "Trial", + "Rental", + "Subscription", + "Service" }; const std::string kBooleanStr[2] = @@ -29,6 +30,7 @@ const std::string kBooleanStr[2] = const byte_t eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key + int main(int argc, char** argv) { if (argc < 2) @@ -51,16 +53,9 @@ int main(int argc, char** argv) printf(" Title Key:\n"); printf(" EncMode: %s\n", kTitleKeyPersonalisation[body.getTitleKeyEncType()].c_str()); printf(" CommonKeyId: %02X\n", body.getCommonKeyId()); - printf(" EncData:"); + printf(" EncData:\n"); size_t size = body.getTitleKeyEncType() == es::ETicketBody_V2::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize; - for (uint32_t i = 0; i < size; i++) - { - if (i % 16 == 0) - { - printf("\n "); - } - printf("%02X%s", body.getEncTitleKey()[i], (i+1 != size) ? "" : "\n"); - } + fnd::SimpleTextOutput::hexDump(body.getEncTitleKey(), size, 0x10, 6); if (body.getTitleKeyEncType() == es::ETicketBody_V2::AES128_CBC && body.getCommonKeyId() == 0) { @@ -69,15 +64,8 @@ int main(int argc, char** argv) memcpy(iv, body.getRightsId(), crypto::aes::kAesBlockSize); crypto::aes::AesCbcDecrypt(body.getEncTitleKey(), crypto::aes::kAes128KeySize, eticket_common_key, iv, key); size = crypto::aes::kAes128KeySize; - printf(" TitleKey:"); - for (uint32_t i = 0; i < size; i++) - { - if (i % 16 == 0) - { - printf("\n "); - } - printf("%02X%s", key[i], (i + 1 != size) ? "" : "\n"); - } + printf(" TitleKey:\n"); + fnd::SimpleTextOutput::hexDump(key, size, 0x10, 6); } printf(" Version: v%d\n", body.getTicketVersion()); printf(" License Type: %s\n", kLicenseType[body.getLicenseType()].c_str()); @@ -85,18 +73,12 @@ int main(int argc, char** argv) printf(" PreInstall: %s\n", kBooleanStr[body.isPreInstall()].c_str()); printf(" SharedTitle: %s\n", kBooleanStr[body.isSharedTitle()].c_str()); printf(" AllContent: %s\n", kBooleanStr[body.allowAllContent()].c_str()); - printf(" Reserved Region:"); - for (uint32_t i = 0; i < 8; i++) - { - if (i % 16 == 0) - { - printf("\n "); - } - printf("%02X%s", body.getReservedRegion()[i], (i + 1 != 8) ? "" : "\n"); - } + printf(" Reserved Region:\n"); + fnd::SimpleTextOutput::hexDump(body.getReservedRegion(), 8, 0x10, 4); printf(" TicketId: 0x%016" PRIx64 "\n", body.getTicketId()); printf(" DeviceId: 0x%016" PRIx64 "\n", body.getDeviceId()); - + printf(" RightsId: "); + fnd::SimpleTextOutput::hexDump(body.getRightsId(), 16); } catch (const fnd::Exception& e) {