Move keys location and check FILE instead of using exists

This commit is contained in:
Gabriel 2019-10-01 21:53:55 -07:00
parent 09f9e4242c
commit 514275fc50
No known key found for this signature in database
GPG Key ID: 875B6E78224D7E96
2 changed files with 6 additions and 4 deletions

View File

@ -191,8 +191,8 @@ namespace Common {
}
}
// support biskeydump v7 dump
if (std::filesystem::exists("/device.keys")) {
FILE *key_file = fopen("/device.keys", "r");
FILE *key_file = fopen("/device.keys", "r");
if (key_file) {
char line[0x100];
while (fgets(line, sizeof(line), key_file) && !(sbk.found() && tsec.found())) {
if (strncmp("secure_boot_key", line, 15) == 0)

View File

@ -245,10 +245,12 @@ void KeyCollection::get_keys() {
// avoid crash on CFWs that don't use /switch folder
if (!std::filesystem::exists("/switch"))
std::filesystem::create_directory("/switch");
if (!std::filesystem::exists("/switch/Lockpick"))
std::filesystem::create_directory("/switch/Lockpick");
// since Lockpick_RCM can dump newer keys, check for existing keyfile
bool Lockpick_RCM_file_found = false;
if (std::filesystem::exists("/switch/prod.keys")) {
FILE *key_file = fopen("/switch/prod.keys", "r");
FILE *key_file = fopen("/switch/Lockpick/prod.keys", "r");
if (key_file) {
char line[0x200];
while (fgets(line, sizeof(line), key_file)) {
if (strncmp("master_key_07", line, 13) == 0) {