From 3291d06082e9d567b3647a2ba3ec717644c86305 Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 1 May 2018 13:21:28 +0800 Subject: [PATCH] [nx] Add getNcaPartititionAesCtr() --- lib/libnx/include/nx/NcaUtils.h | 1 + lib/libnx/source/NcaUtils.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) 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