Fixed broken code in dev branch

This commit is contained in:
Levi Akatsuki 2024-03-18 22:13:59 +00:00
parent fb326514bf
commit e0ff7d0a6e
3 changed files with 16 additions and 33 deletions

View file

@ -648,14 +648,14 @@ void KeyManager::ReloadKeys() {
if (Settings::values.use_dev_keys) { if (Settings::values.use_dev_keys) {
dev_mode = true; dev_mode = true;
LoadFromFile(suyu_keys_dir / "dev.keys", 1); LoadFromFile(suyu_keys_dir / "dev.keys", false);
} else { } else {
dev_mode = false; dev_mode = false;
LoadFromFile(suyu_keys_dir / "prod.keys", 2); LoadFromFile(suyu_keys_dir / "prod.keys", false);
} }
LoadFromFile(suyu_keys_dir / "title.keys", 3); LoadFromFile(suyu_keys_dir / "title.keys", true);
LoadFromFile(suyu_keys_dir / "console.keys", 4); LoadFromFile(suyu_keys_dir / "console.keys", false);
} }
static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) { static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) {
@ -666,26 +666,11 @@ static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_
[](u8 c) { return std::isxdigit(c); }); [](u8 c) { return std::isxdigit(c); });
} }
void KeyManager::LoadFromFile(const std::filesystem::path& file_path, int key_type) { void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys) {
if (!Common::FS::Exists(file_path)) { if (!Common::FS::Exists(file_path)) {
switch (key_type) { LOG_ERROR(Crypto, "Cannot handle key file '{}': File not found",
case 1: file_path.generic_string());
LOG_ERROR(Crypto, "Issue with Development key file at '{}': File not found", return;
file_path.generic_string());
return;
case 2:
LOG_ERROR(Crypto, "Issue with Production key file at '{}': File not found",
file_path.generic_string());
return;
case 3:
LOG_INFO(Crypto, "Issue with Title key file at '{}': File not found",
file_path.generic_string());
case 4:
LOG_INFO(Crypto, "Issue with Console key file at '{}': File not found",
file_path.generic_string());
default:
LOG_ERROR(Crypto, "Unknown Key Type");
}
} }
std::ifstream file; std::ifstream file;
@ -718,7 +703,7 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, int key_ty
continue; continue;
} }
if (key_type == 3) { if (is_title_keys) {
auto rights_id_raw = Common::HexStringToArray<16>(out[0]); auto rights_id_raw = Common::HexStringToArray<16>(out[0]);
u128 rights_id{}; u128 rights_id{};
std::memcpy(rights_id.data(), rights_id_raw.data(), rights_id_raw.size()); std::memcpy(rights_id.data(), rights_id_raw.data(), rights_id_raw.size());
@ -818,8 +803,7 @@ bool KeyManager::BaseDeriveNecessary() const {
} }
if (!Common::FS::Exists(suyu_keys_dir / "title.keys")) { if (!Common::FS::Exists(suyu_keys_dir / "title.keys")) {
LOG_ERROR(Crypto, "No title.keys found"); LOG_WARNING(Crypto, "Could not locate a title.keys file");
return true;
} }
if (check_key_existence(S256KeyType::Header)) { if (check_key_existence(S256KeyType::Header)) {
@ -1322,4 +1306,4 @@ bool KeyManager::AddTicket(const Ticket& ticket) {
SetKey(S128KeyType::Titlekey, key.value(), rights_id[1], rights_id[0]); SetKey(S128KeyType::Titlekey, key.value(), rights_id[1], rights_id[0]);
return true; return true;
} }
} // namespace Core::Crypto } // namespace Core::Crypto

View file

@ -312,7 +312,7 @@ private:
RSAKeyPair<2048> eticket_rsa_keypair{}; RSAKeyPair<2048> eticket_rsa_keypair{};
bool dev_mode; bool dev_mode;
void LoadFromFile(const std::filesystem::path& file_path, int key_type); void LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys);
void DeriveGeneralPurposeKeys(std::size_t crypto_revision); void DeriveGeneralPurposeKeys(std::size_t crypto_revision);

View file

@ -1756,8 +1756,7 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa
QMessageBox::warning(this, tr("Derivation Components Missing"), QMessageBox::warning(this, tr("Derivation Components Missing"),
tr("Encryption keys are missing. " tr("Encryption keys are missing. "
"In order to use this emulator" "In order to use this emulator"
"you need to provide your own prod.keys" "you need to provide your own encryption keys"
"Some games might also require your own title.keys as well"
"in order to play them.")); "in order to play them."));
return false; return false;
} }
@ -4631,9 +4630,9 @@ void GMainWindow::OnCheckFirmwareDecryption() {
if (!ContentManager::AreKeysPresent()) { if (!ContentManager::AreKeysPresent()) {
QMessageBox::warning(this, tr("Derivation Components Missing"), QMessageBox::warning(this, tr("Derivation Components Missing"),
tr("Encryption keys are missing. " tr("Encryption keys are missing. "
"You need to provide both your own title.keys " "In order to use this emulator"
"and your own prod.keys " "you need to provide your own encryption keys"
"in order to play games")); "in order to play them."));
} }
SetFirmwareVersion(); SetFirmwareVersion();