ctrtool: tmd savesize detection & smarter exheader pre check

This commit is contained in:
applestash
2014-09-22 21:42:33 +10:00
parent b240ea8045
commit c7f8b1833e
5 changed files with 38 additions and 4 deletions
+18
View File
@@ -42,6 +42,11 @@ void exheader_set_programid(exheader_context* ctx, u8 programid[8])
memcpy(ctx->programid, programid, 8);
}
void exheader_set_hash(exheader_context* ctx, u8 hash[32])
{
memcpy(ctx->hash, hash, 32);
}
void exheader_set_counter(exheader_context* ctx, u8 counter[16])
{
memcpy(ctx->counter, counter, 16);
@@ -94,6 +99,19 @@ void exheader_read(exheader_context* ctx, u32 actions)
}
}
int exheader_hash_valid(exheader_context* ctx)
{
u8 hash[32];
ctr_sha_256((u8*)&ctx->header, 0x400, hash);
if(memcmp(ctx->hash,hash,0x20)){
fprintf(stderr, "Error, exheader hash mismatch. Wrong key?\n");
return 0;
}
return 1;
}
int exheader_programid_valid(exheader_context* ctx)
{
if (!settings_get_ignore_programid(ctx->usersettings))