diff --git a/lib/libnx/include/nx/NcaUtils.h b/lib/libnx/include/nx/NcaUtils.h index 81f7163..50365b4 100644 --- a/lib/libnx/include/nx/NcaUtils.h +++ b/lib/libnx/include/nx/NcaUtils.h @@ -9,5 +9,6 @@ namespace nx static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nx::nca::kSectorSize; } static void decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key); static byte_t getMasterKeyRevisionFromKeyGeneration(byte_t key_generation); + static void getNcaPartitionAesCtr(const nx::sNcaFsHeader* hdr, byte_t* ctr); }; } \ No newline at end of file diff --git a/lib/libnx/source/NcaUtils.cpp b/lib/libnx/source/NcaUtils.cpp index 145ccdf..0ffa1ad 100644 --- a/lib/libnx/source/NcaUtils.cpp +++ b/lib/libnx/source/NcaUtils.cpp @@ -46,4 +46,12 @@ byte_t nx::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation } return masterkey_rev; +} + +void nx::NcaUtils::getNcaPartitionAesCtr(const nx::sNcaFsHeader* hdr, byte_t* ctr) +{ + for (size_t i = 0; i < 16; i++) + { + ctr[15-i] = hdr->base_ctr.iv[i]; + } } \ No newline at end of file