From 1633fe6c5c288c18b2b30b1d584fea345d1c51d8 Mon Sep 17 00:00:00 2001 From: d0k3 <tore.anon@gmail.com> Date: Sat, 5 Mar 2016 15:00:53 +0100 Subject: [PATCH] Fixed and extended the self test feature --- source/decryptor/selftest.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/decryptor/selftest.c b/source/decryptor/selftest.c index 2e807c5..cdfb959 100644 --- a/source/decryptor/selftest.c +++ b/source/decryptor/selftest.c @@ -4,6 +4,7 @@ #include "decryptor/sha.h" #include "decryptor/selftest.h" #include "decryptor/decryptor.h" +#include "decryptor/game.h" #include "decryptor/titlekey.h" #include "fatfs/sdmmc.h" @@ -29,7 +30,8 @@ #define ST_SHA 3 #define ST_AES_MODE 4 #define ST_AES_KEYSLOT 5 -#define ST_TITLEKEYS 6 +#define ST_AES_KEYSLOT_Y 6 +#define ST_TITLEKEYS 7 typedef struct { char name[16]; @@ -47,7 +49,10 @@ SubTestInfo TestList[] = { { "aes_cnt_twl", 16, ST_AES_MODE, AES_CNT_TWLNAND_MODE }, { "aes_ttk_enc", 16, ST_AES_MODE, AES_CNT_TITLEKEY_DECRYPT_MODE }, { "aes_ttk_dec", 16, ST_AES_MODE, AES_CNT_TITLEKEY_ENCRYPT_MODE }, - { "ncch_std_key", 16, ST_AES_KEYSLOT, 0x2C }, + { "ncch_std_key", 16, ST_AES_KEYSLOT_Y, 0x2C }, + { "ncch_7x_key", 16, ST_AES_KEYSLOT_Y, 0x25 }, + { "ncch_sec3_key", 16, ST_AES_KEYSLOT_Y, 0x18 }, + { "ncch_sec4_key", 16, ST_AES_KEYSLOT_Y, 0x1B }, { "nand_twl_key", 16, ST_AES_KEYSLOT, 0x03 }, { "nand_ctro_key", 16, ST_AES_KEYSLOT, 0x04 }, { "nand_ctrn_key", 16, ST_AES_KEYSLOT, 0x05 }, @@ -87,13 +92,17 @@ u32 SelfTest(u32 param) sha_init(param); sha_update(teststr, 16); sha_get(test_ptr); - } else if ((type == ST_AES_MODE) || (type == ST_AES_KEYSLOT)) { + } else if ((type == ST_AES_MODE) || (type == ST_AES_KEYSLOT) || (type == ST_AES_KEYSLOT_Y)) { CryptBufferInfo info = {.setKeyY = 0, .size = 16, .buffer = test_ptr}; if (type == ST_AES_MODE) { info.mode = param; info.keyslot = 0x11; setup_aeskey(0x11, (void*) zeroes); } else { + if (type == ST_AES_KEYSLOT_Y) { + info.setKeyY = 1; + memcpy(info.keyY, zeroes, 16); + } info.mode = AES_CNT_CTRNAND_MODE; info.keyslot = param; }