aboutsummaryrefslogtreecommitdiff
path: root/source/KeyCollection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/KeyCollection.cpp')
-rw-r--r--source/KeyCollection.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/source/KeyCollection.cpp b/source/KeyCollection.cpp
index 897eb5b..44fb084 100644
--- a/source/KeyCollection.cpp
+++ b/source/KeyCollection.cpp
@@ -35,7 +35,6 @@
35 35
36extern "C" { 36extern "C" {
37 #include "nx/es.h" 37 #include "nx/es.h"
38 #include "nx/set_ext.h"
39} 38}
40 39
41#define TITLEKEY_BUFFER_SIZE 0x40000 40#define TITLEKEY_BUFFER_SIZE 0x40000
@@ -486,7 +485,7 @@ void KeyCollection::derive_keys() {
486 FRESULT fr; 485 FRESULT fr;
487 FIL save_file; 486 FIL save_file;
488 487
489 fsOpenBisStorage(&storage, FsBisStorageId_System); 488 fsOpenBisStorage(&storage, FsBisPartitionId_System);
490 if (f_mount(&fs, "", 1) || 489 if (f_mount(&fs, "", 1) ||
491 f_chdir("/save") || 490 f_chdir("/save") ||
492 f_open(&save_file, "8000000000000043", FA_READ | FA_OPEN_EXISTING)) 491 f_open(&save_file, "8000000000000043", FA_READ | FA_OPEN_EXISTING))
@@ -592,7 +591,7 @@ void KeyCollection::get_titlekeys() {
592 esInitialize(); 591 esInitialize();
593 esCountCommonTicket(&common_count); 592 esCountCommonTicket(&common_count);
594 esCountPersonalizedTicket(&personalized_count); 593 esCountPersonalizedTicket(&personalized_count);
595 NcmRightsId common_rights_ids[common_count], personalized_rights_ids[personalized_count]; 594 RightsId common_rights_ids[common_count], personalized_rights_ids[personalized_count];
596 esListCommonTicket(&ids_written, common_rights_ids, sizeof(common_rights_ids)); 595 esListCommonTicket(&ids_written, common_rights_ids, sizeof(common_rights_ids));
597 esListPersonalizedTicket(&ids_written, personalized_rights_ids, sizeof(personalized_rights_ids)); 596 esListPersonalizedTicket(&ids_written, personalized_rights_ids, sizeof(personalized_rights_ids));
598 esExit(); 597 esExit();
@@ -608,27 +607,27 @@ void KeyCollection::get_titlekeys() {
608 std::unordered_set<std::string> rights_ids; 607 std::unordered_set<std::string> rights_ids;
609 for (size_t i = 0; i < common_count; i++) { 608 for (size_t i = 0; i < common_count; i++) {
610 for (size_t j = 0; j < 0x10; j++) { 609 for (size_t j = 0; j < 0x10; j++) {
611 sprintf(&rights_id_string[j*2], "%02x", common_rights_ids[i].rights_id.c[j]); 610 sprintf(&rights_id_string[j*2], "%02x", common_rights_ids[i].c[j]);
612 } 611 }
613 rights_ids.insert(rights_id_string); 612 rights_ids.insert(rights_id_string);
614 } 613 }
615 for (size_t i = 0; i < personalized_count; i++) { 614 for (size_t i = 0; i < personalized_count; i++) {
616 for (size_t j = 0; j < 0x10; j++) { 615 for (size_t j = 0; j < 0x10; j++) {
617 sprintf(&rights_id_string[j*2], "%02x", personalized_rights_ids[i].rights_id.c[j]); 616 sprintf(&rights_id_string[j*2], "%02x", personalized_rights_ids[i].c[j]);
618 } 617 }
619 rights_ids.insert(rights_id_string); 618 rights_ids.insert(rights_id_string);
620 } 619 }
621 620
622 // get extended eticket RSA key from PRODINFO 621 // get extended eticket RSA key from PRODINFO
623 u8 eticket_data[0x244] = {}; 622 SetCalRsa2048DeviceKey eticket_data = {};
624 623
625 setcalInitialize(); 624 setcalInitialize();
626 setcalGetEticketDeviceKey(eticket_data); 625 setcalGetEticketDeviceKey(&eticket_data);
627 setcalExit(); 626 setcalExit();
628 627
629 byte_vector dec_keypair = eticket_rsa_kek.aes_decrypt_ctr( 628 byte_vector dec_keypair = eticket_rsa_kek.aes_decrypt_ctr(
630 byte_vector(eticket_data + 0x14, eticket_data + 0x244), 629 byte_vector(eticket_data.key + 0x10, eticket_data.key + 0x240),
631 byte_vector(eticket_data + 4, eticket_data + 0x14) 630 byte_vector(eticket_data.key, eticket_data.key + 0x10)
632 ); 631 );
633 632
634 // public exponent must be 65537 == 0x10001 (big endian) 633 // public exponent must be 65537 == 0x10001 (big endian)
@@ -646,7 +645,7 @@ void KeyCollection::get_titlekeys() {
646 // map of all found rights ids and corresponding titlekeys 645 // map of all found rights ids and corresponding titlekeys
647 std::unordered_map<std::string, std::string> titlekeys; 646 std::unordered_map<std::string, std::string> titlekeys;
648 647
649 fsOpenBisStorage(&storage, FsBisStorageId_System); 648 fsOpenBisStorage(&storage, FsBisPartitionId_System);
650 if (f_mount(&fs, "", 1) || f_chdir("/save")) return; 649 if (f_mount(&fs, "", 1) || f_chdir("/save")) return;
651 if (f_open(&save_file, "80000000000000e1", FA_READ | FA_OPEN_EXISTING)) return; 650 if (f_open(&save_file, "80000000000000e1", FA_READ | FA_OPEN_EXISTING)) return;
652 while ((common_count != 0) && (titlekeys_dumped < common_count)) { 651 while ((common_count != 0) && (titlekeys_dumped < common_count)) {