summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/NANDImporter.cpp
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2022-07-27 01:51:19 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2022-08-01 10:00:42 -0700
commit46ad8b9d68b7eff720a6f33e6029ddd36ab8edaa (patch)
tree94d2a8dede00d833d90df390bb64a814fdf35bc1 /Source/Core/DiscIO/NANDImporter.cpp
parentfb45ed3981d4aaaaa55fcd16686bba68fed2c4f1 (diff)
Implement hw accelerated AES
Diffstat (limited to 'Source/Core/DiscIO/NANDImporter.cpp')
-rw-r--r--Source/Core/DiscIO/NANDImporter.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/Core/DiscIO/NANDImporter.cpp b/Source/Core/DiscIO/NANDImporter.cpp
index 4520930ca3..6c17303467 100644
--- a/Source/Core/DiscIO/NANDImporter.cpp
+++ b/Source/Core/DiscIO/NANDImporter.cpp
@@ -171,14 +171,13 @@ std::vector<u8> NANDImporter::GetEntryData(const NANDFSTEntry& entry)
std::vector<u8> data{};
data.reserve(remaining_bytes);
+ auto block = std::make_unique<u8[]>(NAND_FAT_BLOCK_SIZE);
while (remaining_bytes > 0)
{
- std::array<u8, 16> iv{};
- std::vector<u8> block = Common::AES::Decrypt(
- m_aes_key.data(), iv.data(), &m_nand[NAND_FAT_BLOCK_SIZE * sub], NAND_FAT_BLOCK_SIZE);
+ m_aes_ctx->CryptIvZero(&m_nand[NAND_FAT_BLOCK_SIZE * sub], block.get(), NAND_FAT_BLOCK_SIZE);
- size_t size = std::min(remaining_bytes, block.size());
- data.insert(data.end(), block.begin(), block.begin() + size);
+ size_t size = std::min(remaining_bytes, NAND_FAT_BLOCK_SIZE);
+ data.insert(data.end(), block.get(), block.get() + size);
remaining_bytes -= size;
sub = m_superblock->fat[sub];
@@ -260,7 +259,7 @@ void NANDImporter::ExportKeys()
{
constexpr size_t NAND_AES_KEY_OFFSET = 0x158;
- std::copy_n(&m_nand_keys[NAND_AES_KEY_OFFSET], m_aes_key.size(), m_aes_key.begin());
+ m_aes_ctx = Common::AES::CreateContextDecrypt(&m_nand_keys[NAND_AES_KEY_OFFSET]);
const std::string file_path = m_nand_root + "/keys.bin";
File::IOFile file(file_path, "wb");