From 64c8212ae1168e86693d05875f4284330e52f26d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 4 Aug 2018 16:52:19 -0400 Subject: aes_util: Make CalculateNintendoTweak() an internally linked function This function doesn't directly depend on class state, so it can be hidden entirely from the interface in the cpp file. --- src/core/crypto/aes_util.cpp | 20 ++++++++++---------- src/core/crypto/aes_util.h | 2 -- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp index e2dc4acb3..a9876c83e 100644 --- a/src/core/crypto/aes_util.cpp +++ b/src/core/crypto/aes_util.cpp @@ -9,6 +9,16 @@ #include "core/crypto/key_manager.h" namespace Core::Crypto { +namespace { +std::vector CalculateNintendoTweak(size_t sector_id) { + std::vector out(0x10); + for (size_t i = 0xF; i <= 0xF; --i) { + out[i] = sector_id & 0xFF; + sector_id >>= 8; + } + return out; +} +} // Anonymous namespace static_assert(static_cast(Mode::CTR) == static_cast(MBEDTLS_CIPHER_AES_128_CTR), "CTR has incorrect value."); @@ -100,16 +110,6 @@ void AESCipher::XTSTranscode(const u8* src, size_t size, u8* dest, } } -template -std::vector AESCipher::CalculateNintendoTweak(size_t sector_id) { - std::vector out(0x10); - for (size_t i = 0xF; i <= 0xF; --i) { - out[i] = sector_id & 0xFF; - sector_id >>= 8; - } - return out; -} - template class AESCipher; template class AESCipher; } // namespace Core::Crypto \ No newline at end of file diff --git a/src/core/crypto/aes_util.h b/src/core/crypto/aes_util.h index bda41b144..ce4947a04 100644 --- a/src/core/crypto/aes_util.h +++ b/src/core/crypto/aes_util.h @@ -56,7 +56,5 @@ public: private: std::unique_ptr ctx; - - static std::vector CalculateNintendoTweak(size_t sector_id); }; } // namespace Core::Crypto -- cgit v1.2.3