mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Auto-populate bis_key_source_03 from bis_key_source_02
This commit is contained in:
parent
474e1e031e
commit
d157619ad5
1 changed files with 11 additions and 7 deletions
|
@ -250,9 +250,6 @@ namespace LibHac
|
||||||
|
|
||||||
// Derive BIS keys
|
// Derive BIS keys
|
||||||
if (DeviceKey.IsEmpty()
|
if (DeviceKey.IsEmpty()
|
||||||
|| BisKeySource[0].IsEmpty()
|
|
||||||
|| BisKeySource[1].IsEmpty()
|
|
||||||
|| BisKeySource[2].IsEmpty()
|
|
||||||
|| BisKekSource.IsEmpty()
|
|| BisKekSource.IsEmpty()
|
||||||
|| AesKekGenerationSource.IsEmpty()
|
|| AesKekGenerationSource.IsEmpty()
|
||||||
|| AesKeyGenerationSource.IsEmpty()
|
|| AesKeyGenerationSource.IsEmpty()
|
||||||
|
@ -261,14 +258,21 @@ namespace LibHac
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user doesn't provide bis_key_source_03 we can assume it's the same as bis_key_source_02
|
||||||
|
if (BisKeySource[3].IsEmpty() && !BisKeySource[2].IsEmpty())
|
||||||
|
{
|
||||||
|
Array.Copy(BisKeySource[2], BisKeySource[3], 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
Crypto.DecryptEcb(DeviceKey, RetailSpecificAesKeySource, kek, 0x10);
|
Crypto.DecryptEcb(DeviceKey, RetailSpecificAesKeySource, kek, 0x10);
|
||||||
Crypto.DecryptEcb(kek, BisKeySource[0], BisKeys[0], 0x20);
|
if (!BisKeySource[0].IsEmpty()) Crypto.DecryptEcb(kek, BisKeySource[0], BisKeys[0], 0x20);
|
||||||
|
|
||||||
Crypto.GenerateKek(DeviceKey, BisKekSource, kek, AesKekGenerationSource, AesKeyGenerationSource);
|
Crypto.GenerateKek(DeviceKey, BisKekSource, kek, AesKekGenerationSource, AesKeyGenerationSource);
|
||||||
|
|
||||||
Crypto.DecryptEcb(kek, BisKeySource[1], BisKeys[1], 0x20);
|
for (int i = 1; i < 4; i++)
|
||||||
Crypto.DecryptEcb(kek, BisKeySource[2], BisKeys[2], 0x20);
|
{
|
||||||
Crypto.DecryptEcb(kek, BisKeySource[3], BisKeys[3], 0x20);
|
if (!BisKeySource[i].IsEmpty()) Crypto.DecryptEcb(kek, BisKeySource[i], BisKeys[i], 0x20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DerivePerFirmwareKeys()
|
private void DerivePerFirmwareKeys()
|
||||||
|
|
Loading…
Reference in a new issue