-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add support for custom decrypted TitleKey #100
Conversation
Thank you for your pull request! I will review it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your pull request, can you please address my feedback so I can merge this :)
makerom/tik.c
Outdated
@@ -65,7 +65,7 @@ void SetupTicketHeader(tik_hdr *hdr, cia_settings *ciaset) | |||
SetLimits(hdr,ciaset); | |||
|
|||
// Crypt TitleKey | |||
if(ciaset->content.encryptCia) | |||
if(ciaset->content.encryptCia || ciaset->common.titleKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ciaset->common.titleKey
will always evaluate to true
because it's a defined as part of struct cia_settings
:
u8 titleKey[16];
You need to respect ciaset->content.encryptCia
because the common key may not be available in all target configurations (namely test
).
I know content.encryptCia
will be false by default unless otherwise specified in the RSF file. If you want to override this to true when specifying a title key, then I would do that in here:
cia.c
int GetSettingsFromUsrset(cia_settings *ciaset, user_settings *usrset)
{
//...
ciaset->content.encryptCia = usrset->common.rsfSet.Option.EnableCrypt || usrset->cia.titleKey != NULL;
//...
}
Because a few lines later the ability to encrypt is checked, and turned off if not available. So it's safer this way.
if(ciaset->keys->aes.commonKey[ciaset->keys->aes.currentCommonKey] == NULL && ciaset->content.encryptCia){
fprintf(stderr,"[CIA WARNING] Common Key could not be loaded, CIA will not be encrypted\n");
ciaset->content.encryptCia = false;
}
makerom/user_settings.c
Outdated
PrintArgReqParam(argv[i], 1); | ||
return USR_ARG_REQ_PARAM; | ||
} | ||
set->cia.titleKey = argv[i + 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please change the indentation from spaces to tabs to match the existing code?
Addressed your feedback, and made |
Looks good! Thank you for your contribution :) |
I've added the
-titlekey
option, so users can specify a decrypted TitleKey to use when encrypting a CIA.