mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-18 04:42:45 +01:00
Require both keys to use the emulator
This commit is contained in:
parent
44ffa0092e
commit
8755d2bad4
5 changed files with 50 additions and 7 deletions
|
@ -643,7 +643,7 @@ void KeyManager::ReloadKeys() {
|
||||||
const auto suyu_keys_dir = Common::FS::GetSuyuPath(Common::FS::SuyuPath::KeysDir);
|
const auto suyu_keys_dir = Common::FS::GetSuyuPath(Common::FS::SuyuPath::KeysDir);
|
||||||
|
|
||||||
if (!Common::FS::CreateDir(suyu_keys_dir)) {
|
if (!Common::FS::CreateDir(suyu_keys_dir)) {
|
||||||
LOG_ERROR(Core, "Failed to create the keys directory.");
|
LOG_ERROR(Crypto, "Failed to create the keys directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::values.use_dev_keys) {
|
if (Settings::values.use_dev_keys) {
|
||||||
|
@ -668,6 +668,8 @@ static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_
|
||||||
|
|
||||||
void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys) {
|
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)) {
|
||||||
|
LOG_ERROR(Crypto, "Failed to load key file at '{}': File not found",
|
||||||
|
file_path.generic_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,9 +677,12 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_ti
|
||||||
Common::FS::OpenFileStream(file, file_path, std::ios_base::in);
|
Common::FS::OpenFileStream(file, file_path, std::ios_base::in);
|
||||||
|
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
|
LOG_ERROR(Crypto, "Failed to load key file at '{}': Can't open file",
|
||||||
|
file_path.generic_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO(Crypto, "Loading key file at '{}'", file_path.generic_string());
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
std::vector<std::string> out;
|
std::vector<std::string> out;
|
||||||
|
@ -703,6 +708,8 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_ti
|
||||||
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());
|
||||||
Key128 key = Common::HexStringToArray<16>(out[1]);
|
Key128 key = Common::HexStringToArray<16>(out[1]);
|
||||||
|
|
||||||
|
LOG_INFO(Crypto, "Successfully loaded title key");
|
||||||
s128_keys[{S128KeyType::Titlekey, rights_id[1], rights_id[0]}] = key;
|
s128_keys[{S128KeyType::Titlekey, rights_id[1], rights_id[0]}] = key;
|
||||||
} else {
|
} else {
|
||||||
out[0] = Common::ToLower(out[0]);
|
out[0] = Common::ToLower(out[0]);
|
||||||
|
@ -785,6 +792,21 @@ bool KeyManager::BaseDeriveNecessary() const {
|
||||||
return !HasKey(key_type, index1, index2);
|
return !HasKey(key_type, index1, index2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Ensure the files exists
|
||||||
|
const auto suyu_keys_dir = Common::FS::GetSuyuPath(Common::FS::SuyuPath::KeysDir);
|
||||||
|
|
||||||
|
if (!Common::FS::Exists(suyu_keys_dir /
|
||||||
|
(Settings::values.use_dev_keys ? "dev.keys" : "prod.keys"))) {
|
||||||
|
LOG_ERROR(Crypto, "No {} found",
|
||||||
|
(Settings::values.use_dev_keys ? "dev.keys" : "prod.keys"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Common::FS::Exists(suyu_keys_dir / "title.keys")) {
|
||||||
|
LOG_ERROR(Crypto, "No title.keys found");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (check_key_existence(S256KeyType::Header)) {
|
if (check_key_existence(S256KeyType::Header)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,10 @@ AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::KProcess& process, Core::S
|
||||||
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Core::Crypto::KeyManager::KeyFileExists(true)) {
|
||||||
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
|
}
|
||||||
|
|
||||||
return {ResultStatus::ErrorNAXInconvertibleToNCA, {}};
|
return {ResultStatus::ErrorNAXInconvertibleToNCA, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,10 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::KProcess& process, Core::S
|
||||||
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Core::Crypto::KeyManager::KeyFileExists(true)) {
|
||||||
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
|
}
|
||||||
|
|
||||||
return {ResultStatus::ErrorNSPMissingProgramNCA, {}};
|
return {ResultStatus::ErrorNSPMissingProgramNCA, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,10 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::KProcess& process, Core::S
|
||||||
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!xci->HasProgramNCA() && !Core::Crypto::KeyManager::KeyFileExists(true)) {
|
||||||
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
|
}
|
||||||
|
|
||||||
const auto result = nca_loader->Load(process, system);
|
const auto result = nca_loader->Load(process, system);
|
||||||
if (result.first != ResultStatus::Success) {
|
if (result.first != ResultStatus::Success) {
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1752,6 +1752,15 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ContentManager::AreKeysPresent()) {
|
||||||
|
QMessageBox::warning(this, tr("Derivation Components Missing"),
|
||||||
|
tr("Encryption keys are missing. "
|
||||||
|
"You need to provide both your own title.keys "
|
||||||
|
"and your own prod.keys "
|
||||||
|
"in order to play games"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Shutdown previous session if the emu thread is still active...
|
// Shutdown previous session if the emu thread is still active...
|
||||||
if (emu_thread != nullptr) {
|
if (emu_thread != nullptr) {
|
||||||
ShutdownGame();
|
ShutdownGame();
|
||||||
|
@ -4619,13 +4628,13 @@ void GMainWindow::OnMouseActivity() {
|
||||||
void GMainWindow::OnCheckFirmwareDecryption() {
|
void GMainWindow::OnCheckFirmwareDecryption() {
|
||||||
system->GetFileSystemController().CreateFactories(*vfs);
|
system->GetFileSystemController().CreateFactories(*vfs);
|
||||||
if (!ContentManager::AreKeysPresent()) {
|
if (!ContentManager::AreKeysPresent()) {
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(this, tr("Derivation Components Missing"),
|
||||||
this, tr("Derivation Components Missing"),
|
tr("Encryption keys are missing. "
|
||||||
tr("Encryption keys are missing. "
|
"You need to provide both your own title.keys "
|
||||||
"<br>Please follow <a href='https://suyu.dev/help/quickstart/'>the suyu "
|
"and your own prod.keys "
|
||||||
"quickstart guide</a> to get all your keys, firmware and "
|
"in order to play games"));
|
||||||
"games."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFirmwareVersion();
|
SetFirmwareVersion();
|
||||||
UpdateMenuState();
|
UpdateMenuState();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue