diff --git a/include/crypto/aes_engine.hpp b/include/crypto/aes_engine.hpp index 96ec900e..324f4adf 100644 --- a/include/crypto/aes_engine.hpp +++ b/include/crypto/aes_engine.hpp @@ -105,6 +105,7 @@ namespace Crypto { AESEngine() {} void loadKeys(const std::filesystem::path& path); bool haveKeys() { return keysLoaded; } + bool haveGenerator() { return m_generator.has_value(); } constexpr bool hasKeyX(std::size_t slotId) { if (slotId >= AesKeySlotCount) { diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 26134cd0..82148541 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -131,6 +131,13 @@ bool NCCH::loadFromHeader(Crypto::AESEngine &aesEngine, IOFile& file, const FSIn return false; } + if (!aesEngine.haveGenerator()) { + Helpers::panic( + "Loading an encrypted ROM but your AES keys don't seem to provide the \"generator\" constant which Panda3DS requires for decryption\n" + "Please add it to your aes_keys.txt in a line like \"generator=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" where the Xs are replaced with the actual generator constant value" + ); + } + if (!gotCryptoKeys) { Helpers::panic("ROM is encrypted but it seems we couldn't get either the primary or the secondary key"); return false;