From 148fe3da762871c8133dd75fa5a4a2952b4f43f8 Mon Sep 17 00:00:00 2001 From: jakcron Date: Thu, 25 Oct 2018 20:44:48 +0800 Subject: [PATCH] [hac|nstool] Renamed NcaUtils to ContentArchiveUtils --- .../include/nn/hac/{NcaUtils.h => ContentArchiveUtils.h} | 2 +- lib/libhac/libhac.vcxproj | 4 ++-- lib/libhac/libhac.vcxproj.filters | 4 ++-- .../source/{NcaUtils.cpp => ContentArchiveUtils.cpp} | 8 ++++---- programs/nstool/source/KeyConfiguration.cpp | 2 +- programs/nstool/source/NcaProcess.cpp | 8 ++++---- programs/nstool/source/UserSettings.cpp | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) rename lib/libhac/include/nn/hac/{NcaUtils.h => ContentArchiveUtils.h} (94%) rename lib/libhac/source/{NcaUtils.cpp => ContentArchiveUtils.cpp} (75%) diff --git a/lib/libhac/include/nn/hac/NcaUtils.h b/lib/libhac/include/nn/hac/ContentArchiveUtils.h similarity index 94% rename from lib/libhac/include/nn/hac/NcaUtils.h rename to lib/libhac/include/nn/hac/ContentArchiveUtils.h index b5ebacc..2a55982 100644 --- a/lib/libhac/include/nn/hac/NcaUtils.h +++ b/lib/libhac/include/nn/hac/ContentArchiveUtils.h @@ -5,7 +5,7 @@ namespace nn { namespace hac { - class NcaUtils + class ContentArchiveUtils { public: static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; } diff --git a/lib/libhac/libhac.vcxproj b/lib/libhac/libhac.vcxproj index f867187..c2a16b6 100644 --- a/lib/libhac/libhac.vcxproj +++ b/lib/libhac/libhac.vcxproj @@ -65,7 +65,7 @@ - + @@ -118,7 +118,7 @@ - + diff --git a/lib/libhac/libhac.vcxproj.filters b/lib/libhac/libhac.vcxproj.filters index 116821c..58429d8 100644 --- a/lib/libhac/libhac.vcxproj.filters +++ b/lib/libhac/libhac.vcxproj.filters @@ -147,7 +147,7 @@ Header Files - + Header Files @@ -296,7 +296,7 @@ Source Files - + Source Files diff --git a/lib/libhac/source/NcaUtils.cpp b/lib/libhac/source/ContentArchiveUtils.cpp similarity index 75% rename from lib/libhac/source/NcaUtils.cpp rename to lib/libhac/source/ContentArchiveUtils.cpp index 9ad1576..88d67d4 100644 --- a/lib/libhac/source/NcaUtils.cpp +++ b/lib/libhac/source/ContentArchiveUtils.cpp @@ -1,6 +1,6 @@ -#include +#include -void nn::hac::NcaUtils::decryptContentArchiveHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key) +void nn::hac::ContentArchiveUtils::decryptContentArchiveHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key) { byte_t tweak[fnd::aes::kAesBlockSize]; @@ -19,7 +19,7 @@ void nn::hac::NcaUtils::decryptContentArchiveHeader(const byte_t* src, byte_t* d } } -byte_t nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation) +byte_t nn::hac::ContentArchiveUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation) { byte_t masterkey_rev; @@ -48,7 +48,7 @@ byte_t nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_gener return masterkey_rev; } -void nn::hac::NcaUtils::getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr) +void nn::hac::ContentArchiveUtils::getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr) { for (size_t i = 0; i < 8; i++) { diff --git a/programs/nstool/source/KeyConfiguration.cpp b/programs/nstool/source/KeyConfiguration.cpp index 7a02116..d268096 100644 --- a/programs/nstool/source/KeyConfiguration.cpp +++ b/programs/nstool/source/KeyConfiguration.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include KeyConfiguration::KeyConfiguration() { diff --git a/programs/nstool/source/NcaProcess.cpp b/programs/nstool/source/NcaProcess.cpp index e5112f9..d1fa659 100644 --- a/programs/nstool/source/NcaProcess.cpp +++ b/programs/nstool/source/NcaProcess.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -112,7 +112,7 @@ void NcaProcess::importHeader() // decrypt header block fnd::aes::sAesXts128Key header_key; mKeyCfg.getContentArchiveHeaderKey(header_key); - nn::hac::NcaUtils::decryptContentArchiveHeader((byte_t*)&mHdrBlock, (byte_t*)&mHdrBlock, header_key); + nn::hac::ContentArchiveUtils::decryptContentArchiveHeader((byte_t*)&mHdrBlock, (byte_t*)&mHdrBlock, header_key); // generate header hash fnd::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sContentArchiveHeader), mHdrHash.bytes); @@ -128,7 +128,7 @@ void NcaProcess::generateNcaBodyEncryptionKeys() memset(zero_aesctr_key.key, 0, sizeof(zero_aesctr_key)); // get key data from header - byte_t masterkey_rev = nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(mHdr.getKeyGeneration()); + byte_t masterkey_rev = nn::hac::ContentArchiveUtils::getMasterKeyRevisionFromKeyGeneration(mHdr.getKeyGeneration()); byte_t keak_index = mHdr.getKeyAreaEncryptionKeyIndex(); // process key area @@ -253,7 +253,7 @@ void NcaProcess::generatePartitionConfiguration() } // setup AES-CTR - nn::hac::NcaUtils::getNcaPartitionAesCtr(&fs_header, info.aes_ctr.iv); + nn::hac::ContentArchiveUtils::getNcaPartitionAesCtr(&fs_header, info.aes_ctr.iv); // save partition config info.reader = nullptr; diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp index 13e932b..94e0d1c 100644 --- a/programs/nstool/source/UserSettings.cpp +++ b/programs/nstool/source/UserSettings.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -506,7 +506,7 @@ void UserSettings::populateKeyset(sCmdArgs& args) fnd::aes::sAes128Key enc_title_key; memcpy(enc_title_key.key, tik.getBody().getEncTitleKey(), 16); fnd::aes::sAes128Key common_key, external_content_key; - if (mKeyCfg.getETicketCommonKey(nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(tik.getBody().getCommonKeyId()), common_key) == true) + if (mKeyCfg.getETicketCommonKey(nn::hac::ContentArchiveUtils::getMasterKeyRevisionFromKeyGeneration(tik.getBody().getCommonKeyId()), common_key) == true) { nn::hac::AesKeygen::generateKey(external_content_key.key, tik.getBody().getEncTitleKey(), common_key.key); mKeyCfg.addNcaExternalContentKey(tik.getBody().getRightsId(), external_content_key); @@ -701,14 +701,14 @@ bool UserSettings::determineValidNcaFromSample(const fnd::Vec& sample) c { // prepare decrypted NCA data byte_t nca_raw[nn::hac::nca::kHeaderSize]; - nn::hac::sContentArchiveHeader* nca_header = (nn::hac::sContentArchiveHeader*)(nca_raw + nn::hac::NcaUtils::sectorToOffset(1)); + nn::hac::sContentArchiveHeader* nca_header = (nn::hac::sContentArchiveHeader*)(nca_raw + nn::hac::ContentArchiveUtils::sectorToOffset(1)); if (sample.size() < nn::hac::nca::kHeaderSize) return false; fnd::aes::sAesXts128Key header_key; mKeyCfg.getContentArchiveHeaderKey(header_key); - nn::hac::NcaUtils::decryptContentArchiveHeader(sample.data(), nca_raw, header_key); + nn::hac::ContentArchiveUtils::decryptContentArchiveHeader(sample.data(), nca_raw, header_key); if (nca_header->st_magic.get() != nn::hac::nca::kNca2StructMagic && nca_header->st_magic.get() != nn::hac::nca::kNca3StructMagic) return false;