Skip to content

Commit

Permalink
Fixed and extended the self test feature
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Mar 5, 2016
1 parent 0d8f4b6 commit 1633fe6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions source/decryptor/selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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];
Expand All @@ -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 },
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1633fe6

Please sign in to comment.