From abd949fea1e5ed3ec5da7387380fc5682207c628 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Fri, 2 Jun 2023 19:16:48 -0700 Subject: [PATCH] qt: Add NCCH secure 1/2 to keys needed for system titles download. (#6586) --- src/citra_qt/configuration/configure_system.cpp | 5 +++-- src/core/hw/aes/key.cpp | 4 ++++ src/core/hw/aes/key.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp index 25a18ce6f..bf2b46ce9 100644 --- a/src/citra_qt/configuration/configure_system.cpp +++ b/src/citra_qt/configuration/configure_system.cpp @@ -247,9 +247,10 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) ui->combo_download_set->setCurrentIndex(0); // set to Minimal ui->combo_download_region->setCurrentIndex(0); // set to the base region - bool keys_available = true; HW::AES::InitKeys(true); - for (u8 i = 0; i < HW::AES::MaxCommonKeySlot; i++) { + bool keys_available = HW::AES::IsKeyXAvailable(HW::AES::KeySlotID::NCCHSecure1) && + HW::AES::IsKeyXAvailable(HW::AES::KeySlotID::NCCHSecure2); + for (u8 i = 0; i < HW::AES::MaxCommonKeySlot && keys_available; i++) { HW::AES::SelectCommonKeyIndex(i); if (!HW::AES::IsNormalKeyAvailable(HW::AES::KeySlotID::TicketCommonKey)) { keys_available = false; diff --git a/src/core/hw/aes/key.cpp b/src/core/hw/aes/key.cpp index 5cd5d8214..991fa5a5e 100644 --- a/src/core/hw/aes/key.cpp +++ b/src/core/hw/aes/key.cpp @@ -573,6 +573,10 @@ void SetNormalKey(std::size_t slot_id, const AESKey& key) { key_slots.at(slot_id).SetNormalKey(key); } +bool IsKeyXAvailable(std::size_t slot_id) { + return key_slots.at(slot_id).x.has_value(); +} + bool IsNormalKeyAvailable(std::size_t slot_id) { return key_slots.at(slot_id).normal.has_value(); } diff --git a/src/core/hw/aes/key.h b/src/core/hw/aes/key.h index 33232dceb..5131882d7 100644 --- a/src/core/hw/aes/key.h +++ b/src/core/hw/aes/key.h @@ -76,6 +76,7 @@ void SetKeyX(std::size_t slot_id, const AESKey& key); void SetKeyY(std::size_t slot_id, const AESKey& key); void SetNormalKey(std::size_t slot_id, const AESKey& key); +bool IsKeyXAvailable(std::size_t slot_id); bool IsNormalKeyAvailable(std::size_t slot_id); AESKey GetNormalKey(std::size_t slot_id);