Skip to content

Commit

Permalink
Titlekey Dumper: general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Aug 20, 2016
1 parent 69c7da1 commit 38eb5a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions source/decryptor/titlekey.c
Expand Up @@ -23,7 +23,7 @@ u32 CryptTitlekey(TitleKeyEntry* entry, bool encrypt)

u32 CryptTitlekeysFile(u32 param)
{
EncKeysInfo *info = (EncKeysInfo*)0x20316000;
TitleKeysInfo *info = (TitleKeysInfo*)0x20316000;
char filename[64];

if (InputFileNameSelector(filename, (param & TK_ENCRYPTED) ? "decTitleKeys.bin" : "encTitleKeys.bin",
Expand Down Expand Up @@ -68,20 +68,16 @@ u32 DumpTitlekeysNand(u32 param)
{
PartitionInfo* ctrnand_info = GetPartitionInfo(P_CTRNAND);;
u8* buffer = BUFFER_ADDRESS;
EncKeysInfo *info = (EncKeysInfo*) 0x20316000;
TitleKeysInfo *info = (TitleKeysInfo*) 0x20316000;
char filename[64];

u32 nKeys = 0;
u32 nSkipped = 0;
u32 offset = 0;
u32 size = 0;

Debug("Searching for ticket.db...");
if (SeekFileInNand(&offset, &size, "DBS TICKET DB ", ctrnand_info) != 0) {
Debug("Failed!");
if (DebugSeekFileInNand(&offset, &size, "ticket.db", "DBS TICKET DB ", ctrnand_info) != 0)
return 1;
}
Debug("Found at %08X, size %uMB", offset, size / (1024 * 1024));

Debug("%s Title Keys...", (param & TK_ENCRYPTED) ? "Dumping" : "Decrypting");
memset(info, 0, 0x10);
Expand Down Expand Up @@ -121,7 +117,7 @@ u32 DumpTitlekeysNand(u32 param)
info->n_entries = nKeys;
ShowProgress(0, 0);

Debug("Decrypted %u unique Titlekeys", nKeys);
Debug("%s %u unique Titlekeys", (param & TK_ENCRYPTED) ? "Dumped" : "Decrypted", nKeys);
Debug("Skipped %u useless Titlekeys", nSkipped);

if (OutputFileNameSelector(filename, (param & TK_ENCRYPTED) ? "encTitleKeys.bin" : "decTitleKeys.bin", NULL) != 0)
Expand Down
2 changes: 1 addition & 1 deletion source/decryptor/titlekey.h
Expand Up @@ -17,7 +17,7 @@ typedef struct {
u32 n_entries;
u8 reserved[12];
TitleKeyEntry entries[MAX_ENTRIES];
} __attribute__((packed, aligned(16))) EncKeysInfo;
} __attribute__((packed, aligned(16))) TitleKeysInfo;


u32 CryptTitlekey(TitleKeyEntry* entry, bool encrypt);
Expand Down

0 comments on commit 38eb5a8

Please sign in to comment.