Allow deriving package1_key from keyblob alone

This commit is contained in:
roblabla 2018-05-10 00:48:28 +02:00
parent dfff070d45
commit a762ff9e99

9
pki.c
View file

@ -914,6 +914,13 @@ void pki_derive_keys(nca_keyset_t *keyset) {
aes_setiv(keyblob_ctx, &keyset->encrypted_keyblobs[i][0x10], 0x10);
aes_decrypt(keyblob_ctx, &keyset->keyblobs[i], &keyset->encrypted_keyblobs[i][0x20], sizeof(keyset->keyblobs[i]));
free_aes_ctx(keyblob_ctx);
}
for (unsigned int i = 0; i < 0x20; i++) {
/* We only need 0x70:0x80 in the blob. */
if (memcmp(keyset->keyblobs[i] + 0x70, zeroes, 0x10) == 0) {
continue;
}
/* Package1 key is at the end of the keyblob. */
memcpy(&keyset->package1_keys[i], &keyset->keyblobs[i][0x80], 0x10);
}
@ -1083,4 +1090,4 @@ void pki_initialize_keyset(nca_keyset_t *keyset, keyset_variant_t variant) {
}
pki_derive_keys(keyset);
}
}