mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-23 03:05:27 +00:00
[nstool] Fix titlekey decryption.
This commit is contained in:
parent
a2aefc2827
commit
c7e79b1d55
|
@ -102,18 +102,16 @@ void NcaProcess::generateNcaBodyEncryptionKeys()
|
||||||
// if the titlekey_kek is available
|
// if the titlekey_kek is available
|
||||||
if (mKeyset->ticket.titlekey_kek[masterkey_rev] != zero_aesctr_key)
|
if (mKeyset->ticket.titlekey_kek[masterkey_rev] != zero_aesctr_key)
|
||||||
{
|
{
|
||||||
crypto::aes::sAesIvCtr iv;
|
|
||||||
iv.set(mHdr.getRightsId());
|
|
||||||
// the title key is provided (sourced from ticket)
|
// the title key is provided (sourced from ticket)
|
||||||
if (mKeyset->nca.manual_title_key_aesctr != zero_aesctr_key)
|
if (mKeyset->nca.manual_title_key_aesctr != zero_aesctr_key)
|
||||||
{
|
{
|
||||||
crypto::aes::AesCbcDecrypt(mKeyset->nca.manual_title_key_aesctr.key, 16, mKeyset->ticket.titlekey_kek[masterkey_rev].key, iv.iv, mBodyKeys.aes_ctr.var.key);
|
nx::AesKeygen::generateKey(mBodyKeys.aes_ctr.var.key, mKeyset->nca.manual_title_key_aesctr.key, mKeyset->ticket.titlekey_kek[masterkey_rev].key);
|
||||||
mBodyKeys.aes_ctr.isSet = true;
|
mBodyKeys.aes_ctr.isSet = true;
|
||||||
}
|
}
|
||||||
if (mKeyset->nca.manual_title_key_aesxts != zero_aesxts_key)
|
if (mKeyset->nca.manual_title_key_aesxts != zero_aesxts_key)
|
||||||
{
|
{
|
||||||
crypto::aes::AesCbcDecrypt(mKeyset->nca.manual_title_key_aesxts.key[0], 16, mKeyset->ticket.titlekey_kek[masterkey_rev].key, iv.iv, mBodyKeys.aes_xts.var.key[0]);
|
nx::AesKeygen::generateKey(mBodyKeys.aes_xts.var.key[0], mKeyset->nca.manual_title_key_aesxts.key[0], mKeyset->ticket.titlekey_kek[masterkey_rev].key);
|
||||||
crypto::aes::AesCbcDecrypt(mKeyset->nca.manual_title_key_aesxts.key[1], 16, mKeyset->ticket.titlekey_kek[masterkey_rev].key, iv.iv, mBodyKeys.aes_xts.var.key[1]);
|
nx::AesKeygen::generateKey(mBodyKeys.aes_xts.var.key[1], mKeyset->nca.manual_title_key_aesxts.key[1], mKeyset->ticket.titlekey_kek[masterkey_rev].key);
|
||||||
mBodyKeys.aes_xts.isSet = true;
|
mBodyKeys.aes_xts.isSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,6 +140,19 @@ void NcaProcess::generateNcaBodyEncryptionKeys()
|
||||||
{
|
{
|
||||||
mBodyKeys.aes_xts = mKeyset->nca.manual_body_key_aesxts;
|
mBodyKeys.aes_xts = mKeyset->nca.manual_body_key_aesxts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mBodyKeys.aes_ctr.isSet)
|
||||||
|
{
|
||||||
|
printf("AES-CTR Key: ");
|
||||||
|
fnd::SimpleTextOutput::hexDump(mBodyKeys.aes_ctr.var.key, sizeof(mBodyKeys.aes_ctr.var));
|
||||||
|
}
|
||||||
|
if (mBodyKeys.aes_xts.isSet)
|
||||||
|
{
|
||||||
|
printf("AES-XTS Key0: ");
|
||||||
|
fnd::SimpleTextOutput::hexDump(mBodyKeys.aes_xts.var.key[0], sizeof(mBodyKeys.aes_ctr.var));
|
||||||
|
printf("AES-XTS Key1: ");
|
||||||
|
fnd::SimpleTextOutput::hexDump(mBodyKeys.aes_xts.var.key[1], sizeof(mBodyKeys.aes_ctr.var));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NcaProcess::generatePartitionConfiguration()
|
void NcaProcess::generatePartitionConfiguration()
|
||||||
|
|
Loading…
Reference in a new issue