mirror of
https://github.com/shchmue/Lockpick_RCM.git
synced 2024-12-29 10:21:52 +01:00
Use cal0 struct, improve style consistency
This commit is contained in:
parent
4ffd4ce7f0
commit
bd09f5418d
@ -736,14 +736,14 @@ get_titlekeys:
|
||||
|
||||
se_aes_xts_crypt(1, 0, 0, 0, buffer, buffer, 0x4000, 1);
|
||||
|
||||
if (_read_le_u32(buffer, 0) != 0x304C4143) {
|
||||
nx_emmc_cal0_t *cal0 = (nx_emmc_cal0_t *)buffer;
|
||||
if (cal0->magic != 0x304C4143) {
|
||||
EPRINTF("CAL0 magic not found. Check BIS key 0.");
|
||||
goto dismount;
|
||||
}
|
||||
|
||||
u32 cal_version = _read_le_u32(buffer, 4);
|
||||
u32 keypair_generation = _read_le_u32(buffer, 0x3AD0);
|
||||
if (cal_version <= 8)
|
||||
u32 keypair_generation = cal0->ext_ecc_rsa2048_eticket_key_ver;
|
||||
if (cal0->version <= 8)
|
||||
keypair_generation = 0; // settings zeroes this out below cal version 9
|
||||
|
||||
if (keypair_generation) {
|
||||
@ -760,7 +760,7 @@ get_titlekeys:
|
||||
}
|
||||
|
||||
se_aes_key_set(6, temp_key, 0x10);
|
||||
se_aes_crypt_ctr(6, keypair, 0x230, buffer + 0x38a0, 0x230, buffer + 0x3890);
|
||||
se_aes_crypt_ctr(6, keypair, 0x230, cal0->ext_ecc_rsa2048_eticket_key + 0x10, 0x230, cal0->ext_ecc_rsa2048_eticket_key);
|
||||
|
||||
u8 *D = keypair, *N = keypair + 0x100, *E = keypair + 0x200;
|
||||
|
||||
|
@ -54,7 +54,8 @@ static void _gf256_mul_x_le(void *block)
|
||||
u32 *pdata = (u32 *)block;
|
||||
u32 carry = 0;
|
||||
|
||||
for (u32 i = 0; i < 4; i++) {
|
||||
for (u32 i = 0; i < 4; i++)
|
||||
{
|
||||
u32 b = pdata[i];
|
||||
pdata[i] = (b << 1) | carry;
|
||||
carry = b >> 31;
|
||||
@ -215,7 +216,8 @@ int nx_emmc_bis_read(u32 sector, u32 count, void *buff)
|
||||
return res;
|
||||
}
|
||||
|
||||
void nx_emmc_bis_cluster_cache_init() {
|
||||
void nx_emmc_bis_cluster_cache_init()
|
||||
{
|
||||
// Clear cluster lookup table and reset end index.
|
||||
memset(cluster_lookup, -1, (system_part->lba_end - system_part->lba_start + 1) / SECTORS_PER_CLUSTER * sizeof(*cluster_lookup));
|
||||
cluster_cache_end_index = 0;
|
||||
|
@ -164,7 +164,8 @@ typedef struct _nx_emmc_cal0_t
|
||||
u8 ext_ecc_b233_eticket_key[0x50];
|
||||
u8 crc16_pad37[0x10];
|
||||
u8 ext_ecc_rsa2048_eticket_key[0x240];
|
||||
u8 crc16_pad38[0x10];
|
||||
u32 ext_ecc_rsa2048_eticket_key_ver;
|
||||
u8 crc16_pad38[0xC];
|
||||
u8 ext_ssl_key[0x130];
|
||||
u8 crc16_pad39[0x10];
|
||||
u8 ext_gc_key[0x130];
|
||||
|
Loading…
Reference in New Issue
Block a user