Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dumping TSEC keys to sd card #44

Merged
merged 2 commits into from
Jul 10, 2018
Merged

Allow dumping TSEC keys to sd card #44

merged 2 commits into from
Jul 10, 2018

Conversation

tesnos6921
Copy link
Contributor

It would be useful if we could dump the TSEC keys just like the fuses and kfuses

Copy link
Owner

@CTCaer CTCaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.
Please check the comments on the code. They rectify some undefined behavior, have a more complete logic (for all possible cases) and lessen the compiled binary's size.

(I've made this review by eye and haven't compiled it to test it, so if you see anything strange tell me.)

EDIT:
And if it's possible, please squash the new changes into one commit.

ipl/main.c Outdated
@@ -665,31 +665,52 @@ void print_tsec_key()
{
EPRINTFARGS("Could not identify package1 version\nto read TSEC firmware (= '%s').",
(char *)pkg1 + 0x10);

gfx_puts(&gfx_con, "\nPress any key...\n");
btn_wait();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these 2.
Press any key is not needed anymore.
btn_wait is going to be used elsewhere.

ipl/main.c Outdated
}
else
EPRINTFARGS("ERROR %X", res);
gfx_putc(&gfx_con, '\n');
}

free(pkg1);
sdmmc_storage_end(&storage);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these 2.
They create undefined behavior when these 2 and the 2 at out label run.

gfx_puts(&gfx_con, "\nDone!\n");
sd_unmount();
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else
	goto out;

ipl/main.c Outdated
gfx_puts(&gfx_con, "\nDone!\n");
sd_unmount();
}
}

out:;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a label out_wait:; above label out
and add btn_wait() below it.

ipl/main.c Outdated
@@ -665,31 +665,52 @@ void print_tsec_key()
{
EPRINTFARGS("Could not identify package1 version\nto read TSEC firmware (= '%s').",
(char *)pkg1 + 0x10);

gfx_puts(&gfx_con, "\nPress any key...\n");
btn_wait();
goto out;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to goto out_wait

@CTCaer CTCaer added the enhancement New feature or request label Jul 9, 2018
@tesnos6921
Copy link
Contributor Author

Thank you for the comments, the requested changes have been made. Plus an additional change of moving sdmmc_storage_end(&storage); higher up in the code. This was done due to the payload freezing after dumping to the sd card and then running that line. The storage pointer is used no farther than where the new location is so it is safe and it made no change in the size of the payload. I compiled and tested it on my own switch and was able to both exit the menu without dumping and exit the menu after dumping as expected

@CTCaer CTCaer merged commit 9401897 into CTCaer:master Jul 10, 2018
@CTCaer
Copy link
Owner

CTCaer commented Jul 10, 2018

Thank you!

(Btw, sdmmc_storage_end(&storage); should always work, it's strange that it hanged.)

@fennectech
Copy link

Nice :D

Huntereb pushed a commit to Huntereb/hekate that referenced this pull request Oct 7, 2019
* Allow dumping tsec keys to sd card
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants