feat: crypto: Add basic AES keyslot manager

We loads keys from AppData/Alber/sysdata/aes_keys.txt.

NOTE: We do differ from other emulators by not hardcoding the generator key, it's the user responsibility to provide it in aes_keys.txt.
This commit is contained in:
Mary 2023-06-19 23:13:20 +02:00
parent bf85b405af
commit 2e5bc0cb14
6 changed files with 280 additions and 2 deletions

View file

@ -135,8 +135,15 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
// Inside that path, we be use a game-specific folder as well. Eg if we were loading a ROM called PenguinDemo.3ds, the savedata would be in
// %APPDATA%/Alber/PenguinDemo/SaveData on Windows, and so on. We do this because games save data in their own filesystem on the cart
char* appData = SDL_GetPrefPath(nullptr, "Alber");
const std::filesystem::path dataPath = std::filesystem::path(appData) / path.filename().stem();
const std::filesystem::path appDataPath = std::filesystem::path(appData);
const std::filesystem::path dataPath = appDataPath / path.filename().stem();
const std::filesystem::path aesKeysPath = appDataPath / "sysdata" / "aes_keys.txt";
IOFile::setAppDataDir(dataPath);
if (std::filesystem::exists(aesKeysPath)) {
aesEngine.loadKeys(aesKeysPath);
}
SDL_free(appData);
kernel.initializeFS();