From f3d5788f0cbc5b4ecf607f040367563f36f7cef5 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 23 Jun 2026 04:50:35 +0200 Subject: [PATCH] FST: Look for .key file next to wud/wux file (#1961) --- src/Cafe/Filesystem/FST/FST.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Cafe/Filesystem/FST/FST.cpp b/src/Cafe/Filesystem/FST/FST.cpp index ec112b9a..1652b1fe 100644 --- a/src/Cafe/Filesystem/FST/FST.cpp +++ b/src/Cafe/Filesystem/FST/FST.cpp @@ -200,7 +200,7 @@ bool FSTVolume::FindDiscKey(const fs::path& path, NCrypto::AesKey& discTitleKey) if (dataSource->readData(0, 0, 0x18000 + 0x100, header, sizeof(header)) != sizeof(header)) return false; - // try all the keys + // try all the keys in the key cache uint8 headerDecrypted[sizeof(header)-16]; for (sint32 i = 0; i < 0x7FFFFFFF; i++) { @@ -215,7 +215,12 @@ bool FSTVolume::FindDiscKey(const fs::path& path, NCrypto::AesKey& discTitleKey) return true; } } - return false; + + // check for a key file next to the WUD file + fs::path keyPath = path; + keyPath.replace_extension("key"); + std::unique_ptr keyFile(FileStream::openFile2(keyPath)); + return keyFile && keyFile->readData(discTitleKey.b, sizeof(discTitleKey.b)) == sizeof(discTitleKey.b); } // open WUD image using key cache