hactool: commit whatever I had in my working dir, 17.0.0 needs new pk2 parsing

This commit is contained in:
Michael Scire 2023-10-10 18:31:58 -07:00
parent c2c907430e
commit 8017a7a6b6
4 changed files with 75 additions and 7 deletions

View file

@ -304,7 +304,9 @@ void extkeys_initialize_settings(hactool_settings_t *settings, FILE *f) {
parse_hex_key(exponent, value, sizeof(exponent));
pki_set_beta_nca0_exponent(exponent);
matched_key = 1;
} else {
} else if (strcmp(key, "xci_t1_titlekey_kek_00") == 0) {
matched_key = 1;
} else {
char test_name[0x100] = {0};
for (unsigned int i = 0; i < 0x6 && !matched_key; i++) {
snprintf(test_name, sizeof(test_name), "keyblob_key_source_%02"PRIx32, i);

4
kip.c
View file

@ -196,7 +196,9 @@ static void *kip1_uncompress(kip1_ctx_t *ctx, uint64_t *size) {
for (unsigned int i = 0; i < 3; i++) {
// Copy in section data */
memcpy(new_kip + new_offset, (unsigned char *)ctx->header + old_offset, ctx->header->section_headers[i].compressed_size);
kip1_blz_uncompress(new_kip + new_offset + ctx->header->section_headers[i].compressed_size);
if (ctx->header->flags & (1 << i)) {
kip1_blz_uncompress(new_kip + new_offset + ctx->header->section_headers[i].compressed_size);
}
new_offset += ctx->header->section_headers[i].out_size;
old_offset += ctx->header->section_headers[i].compressed_size;
}

72
npdm.c
View file

@ -6,7 +6,7 @@
#include "rsa.h"
#include "cJSON.h"
static const char * const svc_names[0x80] = {
static const char * const svc_names[0xC0] = {
"svcUnknown",
"svcSetHeapSize",
"svcSetMemoryPermission",
@ -135,6 +135,70 @@ static const char * const svc_names[0x80] = {
"svcCreateResourceLimit",
"svcSetResourceLimitLimitValue",
"svcCallSecureMonitor"
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
"svcUnknown",
};
#define MAX_FS_PERM_RW 0x27
@ -297,7 +361,7 @@ void kac_print(const uint32_t *descriptors, uint32_t num_descriptors) {
break;
case 4: /* Syscall mask. */
syscall_base = (desc >> 24) * 0x18;
for (unsigned int sc = 0; sc < 0x18 && syscall_base + sc < 0x80; sc++) {
for (unsigned int sc = 0; sc < 0x18 && syscall_base + sc < 0xC0; sc++) {
kac.svcs_allowed[syscall_base+sc] = desc & 1;
desc >>= 1;
}
@ -382,7 +446,7 @@ void kac_print(const uint32_t *descriptors, uint32_t num_descriptors) {
}
int first_svc = 1;
for (unsigned int i = 0; i < 0x80; i++) {
for (unsigned int i = 0; i < 0xC0; i++) {
if (kac.svcs_allowed[i]) {
printf(first_svc ? " Allowed SVCs: %-35s (0x%02"PRIx32")\n" : " %-35s (0x%02"PRIx32")\n", svc_names[i], i);
first_svc = 0;
@ -811,7 +875,7 @@ cJSON *kac_get_json(const uint32_t *descriptors, uint32_t num_descriptors) {
temp = syscall_memory;
}
syscall_base = (desc >> 24) * 0x18;
for (unsigned int sc = 0; sc < 0x18 && syscall_base + sc < 0x80; sc++) {
for (unsigned int sc = 0; sc < 0x18 && syscall_base + sc < 0xC0; sc++) {
if (desc & 1) {
cJSON_AddU8ToObject(temp, strdup(svc_names[sc + syscall_base]), sc + syscall_base);
}

2
npdm.h
View file

@ -30,7 +30,7 @@ typedef struct {
uint32_t highest_thread_prio;
uint32_t lowest_cpu_id;
uint32_t highest_cpu_id;
uint8_t svcs_allowed[0x80];
uint8_t svcs_allowed[0xC0];
kac_mmio_t *mmio;
kac_irq_t *irqs;
int has_app_type;