From 43883c1a174e2fcc535954836847a94bad4f1ce6 Mon Sep 17 00:00:00 2001 From: jakcron Date: Fri, 8 Oct 2021 18:52:57 +0800 Subject: [PATCH] Update VisualStudio project files and silence warnings. --- build/visualstudio/nstool/nstool.vcxproj | 10 +-- .../nstool/nstool.vcxproj.filters | 76 ++++++++----------- deps/libnintendo-hac | 2 +- deps/libtoolchain | 2 +- src/FsProcess.cpp | 8 +- src/KeyBag.cpp | 66 ++++++++-------- 6 files changed, 74 insertions(+), 90 deletions(-) diff --git a/build/visualstudio/nstool/nstool.vcxproj b/build/visualstudio/nstool/nstool.vcxproj index 05e9c1e..7eeb132 100644 --- a/build/visualstudio/nstool/nstool.vcxproj +++ b/build/visualstudio/nstool/nstool.vcxproj @@ -154,8 +154,10 @@ + + @@ -181,18 +183,12 @@ + - - - - - - - diff --git a/build/visualstudio/nstool/nstool.vcxproj.filters b/build/visualstudio/nstool/nstool.vcxproj.filters index 4aa666c..7358652 100644 --- a/build/visualstudio/nstool/nstool.vcxproj.filters +++ b/build/visualstudio/nstool/nstool.vcxproj.filters @@ -15,39 +15,33 @@ - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files Header Files + + Header Files + Header Files Header Files + + Header Files + Header Files Header Files + + Header Files + Header Files @@ -84,20 +78,20 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files @@ -110,36 +104,24 @@ Source Files + + Source Files + Source Files - + Source Files - - Source Files - - + Source Files Source Files - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - Source Files @@ -152,5 +134,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/deps/libnintendo-hac b/deps/libnintendo-hac index e2fb1f3..6a6f57c 160000 --- a/deps/libnintendo-hac +++ b/deps/libnintendo-hac @@ -1 +1 @@ -Subproject commit e2fb1f3ad788533631d8855d484d14bec33ac961 +Subproject commit 6a6f57c66b56daeebc1631e639ea88e474965cb7 diff --git a/deps/libtoolchain b/deps/libtoolchain index 7948f58..3d15a0e 160000 --- a/deps/libtoolchain +++ b/deps/libtoolchain @@ -1 +1 @@ -Subproject commit 7948f581d32ebbfdf5a872b96c37938690f665e7 +Subproject commit 3d15a0eb1eff3c36fb4ac8a64196627e46e105ab diff --git a/src/FsProcess.cpp b/src/FsProcess.cpp index 78e2aee..d148336 100644 --- a/src/FsProcess.cpp +++ b/src/FsProcess.cpp @@ -137,7 +137,7 @@ void nstool::FsProcess::extractFs() continue; - } catch (tc::io::DirectoryNotFoundException& e) { + } catch (tc::io::DirectoryNotFoundException&) { // acceptable exception, just means directory didn't exist } @@ -168,7 +168,7 @@ void nstool::FsProcess::extractFs() writeStreamToFile(file_stream, itr->extract_path, mDataCache); continue; - } catch (tc::io::DirectoryNotFoundException& e) { + } catch (tc::io::DirectoryNotFoundException&) { // acceptable exception, just means the parent directory didn't exist } @@ -178,7 +178,7 @@ void nstool::FsProcess::extractFs() tc::io::PathUtil::pathToUnixUTF8(itr->extract_path, literal_extract_path_str); fmt::print("[WARNING] Extract path was invalid, and was skipped: {:s}\n", literal_extract_path_str); continue; - } catch (tc::io::FileNotFoundException& e) { + } catch (tc::io::FileNotFoundException&) { // acceptable exception, just means file didn't exist } @@ -195,7 +195,7 @@ void nstool::FsProcess::extractFs() // directory extract successful, continue to next job continue; - } catch (tc::io::DirectoryNotFoundException& e) { + } catch (tc::io::DirectoryNotFoundException&) { // acceptable exception, just means directory didn't exist } diff --git a/src/KeyBag.cpp b/src/KeyBag.cpp index 684ddf1..3938e5a 100644 --- a/src/KeyBag.cpp +++ b/src/KeyBag.cpp @@ -153,7 +153,7 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa const std::string kPrivateStr = "private"; std::vector kNcaKeyAreaKeyIndexStr = { "application", "ocean", "system" }; - static const size_t kMasterKeyMax = 0x20; + static const size_t kKeyGenerationNum = 0x100; /**/ // import key data @@ -162,11 +162,11 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa /* internal key sources */ if (name_idx < kMasterBase.size()) { - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { // std::map master_key; - //fmt::print("{:s}_key_{:02x}\n", kMasterBase[name_idx], mkey_rev); - _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kMasterBase[name_idx], kKeyStr, mkey_rev), master_key[mkey_rev]); + //fmt::print("{:s}_key_{:02x}\n", kMasterBase[name_idx], keygen_rev); + _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kMasterBase[name_idx], kKeyStr, keygen_rev), master_key[(byte_t)keygen_rev]); } } @@ -227,10 +227,10 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa // package1_key_xx if (name_idx < kPkg1Base.size()) { - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { - //fmt::print("{:s}_key_{:02x}\n", kPkg1Base[name_idx], mkey_rev); - _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kPkg1Base[name_idx], kKeyStr, mkey_rev), pkg1_key[mkey_rev]); + //fmt::print("{:s}_key_{:02x}\n", kPkg1Base[name_idx], keygen_rev); + _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kPkg1Base[name_idx], kKeyStr, keygen_rev), pkg1_key[(byte_t)keygen_rev]); } } @@ -238,10 +238,10 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa if (name_idx < kPkg2Base.size()) { // package2_key_xx - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { - //fmt::print("{:s}_key_{:02x}\n", kPkg2Base[name_idx], mkey_rev); - _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kPkg2Base[name_idx], kKeyStr, mkey_rev), pkg2_key[mkey_rev]); + //fmt::print("{:s}_key_{:02x}\n", kPkg2Base[name_idx], keygen_rev); + _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kPkg2Base[name_idx], kKeyStr, keygen_rev), pkg2_key[(byte_t)keygen_rev]); } // package2_sign_key @@ -254,10 +254,10 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa // ticket common key if (name_idx < kTicketCommonKeyBase.size()) { - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { - //fmt::print("{:s}_{:02x}\n", kTicketCommonKeyBase[name_idx], mkey_rev); - _SAVE_AES128KEY(fmt::format("{:s}_{:02x}", kTicketCommonKeyBase[name_idx], mkey_rev), etik_common_key[mkey_rev]); + //fmt::print("{:s}_{:02x}\n", kTicketCommonKeyBase[name_idx], keygen_rev); + _SAVE_AES128KEY(fmt::format("{:s}_{:02x}", kTicketCommonKeyBase[name_idx], keygen_rev), etik_common_key[(byte_t)keygen_rev]); } } @@ -269,11 +269,11 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa //_SAVE_AES128XTSKEY(fmt::format("{:s}_{:s}", kContentArchiveHeaderBase[name_idx], kKeyStr), nca_header_key); // nca header sign0 key (generations) - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { - //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kContentArchiveHeaderBase[name_idx], kSignKey, mkey_rev, kPrivateStr); - //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kContentArchiveHeaderBase[name_idx], kSignKey, mkey_rev, kModulusStr); - _SAVE_RSAKEY(fmt::format("{:s}_{:s}_{:02x}", kContentArchiveHeaderBase[name_idx], kSignKey, mkey_rev), nca_header_sign0_key[mkey_rev], 2048); + //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kContentArchiveHeaderBase[name_idx], kSignKey, keygen_rev, kPrivateStr); + //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kContentArchiveHeaderBase[name_idx], kSignKey, keygen_rev, kModulusStr); + _SAVE_RSAKEY(fmt::format("{:s}_{:s}_{:02x}", kContentArchiveHeaderBase[name_idx], kSignKey, keygen_rev), nca_header_sign0_key[(byte_t)keygen_rev], 2048); } // nca header sign0 key (generation 0) //fmt::print("{:s}_{:s}_{:s}\n", kContentArchiveHeaderBase[name_idx], kSignKey, kPrivateStr); @@ -287,24 +287,24 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa // nca key area encryption keys if (name_idx < kNcaKeyAreaEncKeyBase.size()) { - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { for (size_t keak_idx = 0; keak_idx < kNcaKeyAreaKeyIndexStr.size(); keak_idx++) { - //fmt::print("{:s}_{:s}_{:02x}\n", kNcaKeyAreaEncKeyBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], mkey_rev); - _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kNcaKeyAreaEncKeyBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], mkey_rev), nca_key_area_encryption_key[keak_idx][mkey_rev]); + //fmt::print("{:s}_{:s}_{:02x}\n", kNcaKeyAreaEncKeyBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], keygen_rev); + _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kNcaKeyAreaEncKeyBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], keygen_rev), nca_key_area_encryption_key[keak_idx][(byte_t)keygen_rev]); } } } // nca key area "hw" encryption keys if (name_idx < kNcaKeyAreaEncKeyHwBase.size()) { - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { for (size_t keak_idx = 0; keak_idx < kNcaKeyAreaKeyIndexStr.size(); keak_idx++) { - //fmt::print("{:s}_{:s}_{:02x}\n", kNcaKeyAreaEncKeyHwBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], mkey_rev); - _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kNcaKeyAreaEncKeyHwBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], mkey_rev), nca_key_area_encryption_key_hw[keak_idx][mkey_rev]); + //fmt::print("{:s}_{:s}_{:02x}\n", kNcaKeyAreaEncKeyHwBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], keygen_rev); + _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kNcaKeyAreaEncKeyHwBase[name_idx], kNcaKeyAreaKeyIndexStr[keak_idx], keygen_rev), nca_key_area_encryption_key_hw[keak_idx][(byte_t)keygen_rev]); } } } @@ -313,11 +313,11 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa if (name_idx < kAcidBase.size()) { // acid sign key (generations) - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { - //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kAcidBase[name_idx], kSignKey, mkey_rev, kPrivateStr); - //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kAcidBase[name_idx], kSignKey, mkey_rev, kModulusStr); - _SAVE_RSAKEY(fmt::format("{:s}_{:s}_{:02x}", kAcidBase[name_idx], kSignKey, mkey_rev), acid_sign_key[mkey_rev], 2048); + //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kAcidBase[name_idx], kSignKey, keygen_rev, kPrivateStr); + //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kAcidBase[name_idx], kSignKey, keygen_rev, kModulusStr); + _SAVE_RSAKEY(fmt::format("{:s}_{:s}_{:02x}", kAcidBase[name_idx], kSignKey, keygen_rev), acid_sign_key[(byte_t)keygen_rev], 2048); } // acid sign key (generation 0) //fmt::print("{:s}_{:s}_{:s}\n", kAcidBase[name_idx], kSignKey, kPrivateStr); @@ -329,11 +329,11 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa if (name_idx < kNrrCertBase.size()) { // nrr certificate sign key (generations) - for (size_t mkey_rev = 0; mkey_rev < kMasterKeyMax; mkey_rev++) + for (size_t keygen_rev = 0; keygen_rev < kKeyGenerationNum; keygen_rev++) { - //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kNrrCertBase[name_idx], kSignKey, mkey_rev, kPrivateStr); - //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kNrrCertBase[name_idx], kSignKey, mkey_rev, kModulusStr); - _SAVE_RSAKEY(fmt::format("{:s}_{:s}_{:02x}", kNrrCertBase[name_idx], kSignKey, mkey_rev), nrr_certificate_sign_key[mkey_rev], 2048); + //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kNrrCertBase[name_idx], kSignKey, keygen_rev, kPrivateStr); + //fmt::print("{:s}_{:s}_{:02x}_{:s}\n", kNrrCertBase[name_idx], kSignKey, keygen_rev, kModulusStr); + _SAVE_RSAKEY(fmt::format("{:s}_{:s}_{:02x}", kNrrCertBase[name_idx], kSignKey, keygen_rev), nrr_certificate_sign_key[(byte_t)keygen_rev], 2048); } // nrr certificate sign key (generation 0) //fmt::print("{:s}_{:s}_{:s}\n", kNrrCertBase[name_idx], kSignKey, kPrivateStr); @@ -345,7 +345,7 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa if (name_idx < kXciHeaderBase.size()) { // xci header key (based on index) - for (size_t kek_index = 0; kek_index < 8; kek_index++) + for (byte_t kek_index = 0; kek_index < 8; kek_index++) { //fmt::print("{:s}_{:s}_{:02x}\n", kXciHeaderBase[name_idx], kKeyStr, kek_index); _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kXciHeaderBase[name_idx], kKeyStr, kek_index), xci_header_key[kek_index]); @@ -364,7 +364,7 @@ void nstool::KeyBagInitializer::importBaseKeyFile(const tc::io::Path& keyfile_pa if (name_idx < kXciInitialDataBase.size()) { // xci initial data key (based on index) - for (size_t kek_index = 0; kek_index < 8; kek_index++) + for (byte_t kek_index = 0; kek_index < 8; kek_index++) { //fmt::print("{:s}_{:s}_{:02x}\n", kXciInitialDataBase[name_idx], kKekStr, kek_index); _SAVE_AES128KEY(fmt::format("{:s}_{:s}_{:02x}", kXciInitialDataBase[name_idx], kKekStr, kek_index), xci_initial_data_kek[kek_index]);