From 15660bd8570735139d91d0165a2614747f570202 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 3 Aug 2020 14:14:39 -0400 Subject: aes_util: Allow SetIV to be non-allocating In a few places, the data to be set as the IV is already within an array. We shouldn't require this data to be heap-allocated if it doesn't need to be. This allows certain callers to reduce heap churn. --- src/core/crypto/partition_data_manager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core/crypto/partition_data_manager.cpp') diff --git a/src/core/crypto/partition_data_manager.cpp b/src/core/crypto/partition_data_manager.cpp index 7ed71ac3a..b31a81560 100644 --- a/src/core/crypto/partition_data_manager.cpp +++ b/src/core/crypto/partition_data_manager.cpp @@ -346,10 +346,9 @@ FileSys::VirtualFile PartitionDataManager::GetPackage2Raw(Package2Type type) con } static bool AttemptDecrypt(const std::array& key, Package2Header& header) { - const std::vector iv(header.header_ctr.begin(), header.header_ctr.end()); Package2Header temp = header; AESCipher cipher(key, Mode::CTR); - cipher.SetIV(iv); + cipher.SetIV(header.header_ctr); cipher.Transcode(&temp.header_ctr, sizeof(Package2Header) - 0x100, &temp.header_ctr, Op::Decrypt); if (temp.magic == Common::MakeMagic('P', 'K', '2', '1')) { @@ -388,7 +387,7 @@ void PartitionDataManager::DecryptPackage2(const std::array& packa auto c = a->ReadAllBytes(); AESCipher cipher(package2_keys[revision], Mode::CTR); - cipher.SetIV({header.section_ctr[1].begin(), header.section_ctr[1].end()}); + cipher.SetIV(header.section_ctr[1]); cipher.Transcode(c.data(), c.size(), c.data(), Op::Decrypt); const auto ini_file = std::make_shared(c); -- cgit v1.2.3