mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@412 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
39332a2bcb
commit
6b3c8b39b3
49
build/tools/sctools/common/src/my_keys.c
Normal file
49
build/tools/sctools/common/src/my_keys.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include <twl.h>
|
||||
|
||||
#include "my_aes.h"
|
||||
#include "my_keys.h"
|
||||
|
||||
/*
|
||||
makesdtd/my_sign.c‚Æ‘Î
|
||||
*/
|
||||
|
||||
u8 my_sign_aes_key[AES_KEY_BYTE_LEN] = {
|
||||
0x02,0xB6,0x01,0xD8,0x01,0x80,0x01,0x77,0xB4,0x01,0xCB,0x01,0xBD,0x5F,0x18,0x0F,
|
||||
0xF6,0x39,0x9C,0xC6,0x90,0xAC,0xC1,0x0D,0x03,0x74,0x6E,0x8D,0xD1,0xBA,0x37,0x46
|
||||
};
|
||||
|
||||
u8 my_sign_aes_iv[AES_BLOCK_SIZE] = {
|
||||
0xC3,0x85,0x93,0xFE,0xA8,0x2D,0xBF,0xFB,0xED,0x42,0xE0,0x42,0xFD,0x17,0x04,0xB0
|
||||
};
|
||||
|
||||
|
||||
#ifdef CHINA_LIMITED
|
||||
|
||||
const unsigned char rsa_key_pub[0x8c]={
|
||||
0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xd4,0x7d,0x51,0x2c,0x32,0xd7,0xe5,0x18,0x16,
|
||||
0xde,0x67,0xe8,0x5f,0x62,0x87,0x95,0xa3,0x2e,0xf7,0x07,0x51,0x7a,0xa9,0x2d,0xd9,
|
||||
0x0e,0x95,0x5a,0xd4,0x0e,0x0e,0x46,0x7c,0x25,0xf9,0xc4,0x71,0x6f,0x68,0x0d,0x91,
|
||||
0xb3,0x78,0x0c,0x3e,0x6a,0xce,0xc3,0x9e,0xed,0x9a,0xf8,0xb1,0x35,0x3e,0xdc,0x89,
|
||||
0x21,0x2f,0x38,0x4f,0x1e,0x83,0xd9,0x39,0x4d,0x3f,0x15,0xbf,0x5e,0xfd,0x3d,0x81,
|
||||
0xcc,0x2e,0xeb,0x14,0x6e,0x60,0xb9,0x78,0xa7,0x0b,0x49,0xb0,0x1e,0x02,0xa8,0x8d,
|
||||
0x4e,0x42,0x6e,0x6c,0x62,0xa1,0xf5,0xa9,0x79,0x73,0xc4,0x36,0xb7,0x33,0x6c,0xef,
|
||||
0x96,0x2c,0xfd,0xd6,0x1c,0x22,0xd4,0x62,0xe4,0xa5,0x30,0xc9,0xe3,0x0c,0xaa,0xf4,
|
||||
0xcf,0x4f,0xb5,0xfa,0xbb,0x22,0xed,0x02,0x03,0x01,0x00,0x01
|
||||
};
|
||||
|
||||
#else /* CHINA_LIMITED */
|
||||
|
||||
const unsigned char rsa_key_pub[0x8c]={
|
||||
0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xeb,0x72,0xe2,0x05,0x45,0x37,0xd9,0x78,0x35,
|
||||
0xb5,0x8d,0x70,0x9a,0xe7,0x17,0x42,0xe9,0xf3,0x26,0x73,0x4e,0xdf,0x5e,0x96,0x5f,
|
||||
0xcf,0xf2,0xf1,0x2d,0xc0,0x41,0x31,0xb6,0x3b,0xe8,0xa4,0xd7,0x70,0xdb,0x3c,0xfd,
|
||||
0x66,0x0d,0xea,0x2f,0xb8,0x7b,0xf0,0x2d,0x70,0xe0,0xf1,0x05,0x55,0xe6,0x33,0x8f,
|
||||
0x3a,0xde,0x79,0xce,0xd0,0x11,0xbf,0xda,0x78,0xe1,0xef,0x8b,0x0e,0x2e,0xa7,0xe2,
|
||||
0x61,0x88,0x58,0x90,0x1d,0x0c,0x6d,0x5b,0x40,0xbf,0x6f,0xc7,0x18,0xde,0xe8,0xfd,
|
||||
0xd9,0xd9,0x1e,0xb9,0xe4,0xa3,0x4d,0x04,0x39,0x4b,0x8f,0x5b,0x13,0xad,0x14,0x0b,
|
||||
0xf8,0x53,0xbc,0xae,0x72,0x91,0x6b,0xcd,0xf9,0x39,0x8d,0x17,0x3d,0xc8,0xee,0xc9,
|
||||
0xcc,0x95,0x35,0x38,0xb0,0x80,0x53,0x02,0x03,0x01,0x00,0x01
|
||||
};
|
||||
|
||||
|
||||
#endif /* CHINA_LIMITED */
|
||||
24
build/tools/sctools/common/src/my_keys.h
Normal file
24
build/tools/sctools/common/src/my_keys.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef _MY_KEYS_H_
|
||||
#define _MY_KEYS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define AES_KEY_BIT_LEN 256
|
||||
#define AES_KEY_BYTE_LEN (AES_KEY_BIT_LEN/8)
|
||||
|
||||
|
||||
extern u8 my_sign_aes_key[AES_KEY_BYTE_LEN];
|
||||
|
||||
extern u8 my_sign_aes_iv[AES_BLOCK_SIZE];
|
||||
|
||||
extern const unsigned char rsa_key_pub[0x8c];
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MY_KEYS_H_ */
|
||||
@ -14,6 +14,7 @@
|
||||
#include "mprintf.h"
|
||||
#endif /* MY_RSA_SIGN_DEBUG */
|
||||
|
||||
|
||||
#include "my_rsa_sign.h"
|
||||
#include "my_sha.h"
|
||||
|
||||
@ -25,6 +26,10 @@
|
||||
#include <berobj.h>
|
||||
#include <ber.h>
|
||||
|
||||
#include "my_aes.h"
|
||||
#include "my_keys.h"
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
int R_CDECL CRYPTOi__RSA_public_decrypt(int flen, unsigned char *from, unsigned char *to,
|
||||
@ -120,37 +125,11 @@ static s32 miya_CRYPTO_RSA_Decrypt(CRYPTORSAContext *context,
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
static const unsigned char rsa512_pub[]={
|
||||
0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xeb,0x72,0xe2,0x05,0x45,0x37,0xd9,0x78,0x35,
|
||||
0xb5,0x8d,0x70,0x9a,0xe7,0x17,0x42,0xe9,0xf3,0x26,0x73,0x4e,0xdf,0x5e,0x96,0x5f,
|
||||
0xcf,0xf2,0xf1,0x2d,0xc0,0x41,0x31,0xb6,0x3b,0xe8,0xa4,0xd7,0x70,0xdb,0x3c,0xfd,
|
||||
0x66,0x0d,0xea,0x2f,0xb8,0x7b,0xf0,0x2d,0x70,0xe0,0xf1,0x05,0x55,0xe6,0x33,0x8f,
|
||||
0x3a,0xde,0x79,0xce,0xd0,0x11,0xbf,0xda,0x78,0xe1,0xef,0x8b,0x0e,0x2e,0xa7,0xe2,
|
||||
0x61,0x88,0x58,0x90,0x1d,0x0c,0x6d,0x5b,0x40,0xbf,0x6f,0xc7,0x18,0xde,0xe8,0xfd,
|
||||
0xd9,0xd9,0x1e,0xb9,0xe4,0xa3,0x4d,0x04,0x39,0x4b,0x8f,0x5b,0x13,0xad,0x14,0x0b,
|
||||
0xf8,0x53,0xbc,0xae,0x72,0x91,0x6b,0xcd,0xf9,0x39,0x8d,0x17,0x3d,0xc8,0xee,0xc9,
|
||||
0xcc,0x95,0x35,0x38,0xb0,0x80,0x53,0x02,0x03,0x01,0x00,0x01
|
||||
};
|
||||
#else
|
||||
|
||||
static const unsigned char rsa512_pub[]={
|
||||
0x30,0x81,0x9f,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,
|
||||
0x05,0x00,0x03,0x81,0x8d,0x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xeb,0x72,0xe2,
|
||||
0x05,0x45,0x37,0xd9,0x78,0x35,0xb5,0x8d,0x70,0x9a,0xe7,0x17,0x42,0xe9,0xf3,0x26,
|
||||
0x73,0x4e,0xdf,0x5e,0x96,0x5f,0xcf,0xf2,0xf1,0x2d,0xc0,0x41,0x31,0xb6,0x3b,0xe8,
|
||||
0xa4,0xd7,0x70,0xdb,0x3c,0xfd,0x66,0x0d,0xea,0x2f,0xb8,0x7b,0xf0,0x2d,0x70,0xe0,
|
||||
0xf1,0x05,0x55,0xe6,0x33,0x8f,0x3a,0xde,0x79,0xce,0xd0,0x11,0xbf,0xda,0x78,0xe1,
|
||||
0xef,0x8b,0x0e,0x2e,0xa7,0xe2,0x61,0x88,0x58,0x90,0x1d,0x0c,0x6d,0x5b,0x40,0xbf,
|
||||
0x6f,0xc7,0x18,0xde,0xe8,0xfd,0xd9,0xd9,0x1e,0xb9,0xe4,0xa3,0x4d,0x04,0x39,0x4b,
|
||||
0x8f,0x5b,0x13,0xad,0x14,0x0b,0xf8,0x53,0xbc,0xae,0x72,0x91,0x6b,0xcd,0xf9,0x39,
|
||||
0x8d,0x17,0x3d,0xc8,0xee,0xc9,0xcc,0x95,0x35,0x38,0xb0,0x80,0x53,0x02,0x03,0x01,
|
||||
0x00,0x01
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static const int rsa512_pub_len = sizeof rsa512_pub;
|
||||
|
||||
static const int rsa_key_pub_len = sizeof rsa_key_pub;
|
||||
|
||||
|
||||
static void* MyAlloc(u32 size)
|
||||
@ -239,16 +218,16 @@ int RsaTestDecrypt(char *input, int in_len, char *output, int outlen)
|
||||
|
||||
メンバ keyで指定したアドレスにはDER形式のRSA秘密鍵イメージ全体を格納してください。
|
||||
*/
|
||||
key = (void *)OS_Alloc(rsa512_pub_len);
|
||||
key = (void *)OS_Alloc(rsa_key_pub_len);
|
||||
if( key == NULL ) {
|
||||
OS_TPrintf("Error:alloc %s %d",__FUNCTION__,__LINE__);
|
||||
return 0;
|
||||
}
|
||||
memcpy(key, (void*)rsa512_pub, rsa512_pub_len);
|
||||
memcpy(key, (void*)rsa_key_pub, rsa_key_pub_len);
|
||||
|
||||
// decinitparam.key = (void*)rsa512_sec;
|
||||
decinitparam.key = key;
|
||||
decinitparam.key_len = rsa512_pub_len;
|
||||
decinitparam.key_len = rsa_key_pub_len;
|
||||
result = miya_CRYPTO_RSA_DecryptInit(&context, &decinitparam);
|
||||
|
||||
CheckAndPrintErr(result, "CRYPTO_RSA_DecryptInit");
|
||||
|
||||
@ -5,19 +5,7 @@
|
||||
#include "my_aes.h"
|
||||
#include "my_sha.h"
|
||||
#include "my_sign.h"
|
||||
|
||||
#define AES_KEY_BIT_LEN 256
|
||||
#define AES_KEY_BYTE_LEN (AES_KEY_BIT_LEN/8)
|
||||
|
||||
static u8 my_sign_aes_key[AES_KEY_BYTE_LEN] = {
|
||||
0x02,0xB6,0x01,0xD8,0x01,0x80,0x01,0x77,0xB4,0x01,0xCB,0x01,0xBD,0x5F,0x18,0x0F,
|
||||
0xF6,0x39,0x9C,0xC6,0x90,0xAC,0xC1,0x0D,0x03,0x74,0x6E,0x8D,0xD1,0xBA,0x37,0x46
|
||||
};
|
||||
|
||||
static u8 my_sign_aes_iv[AES_BLOCK_SIZE] = {
|
||||
0xC3,0x85,0x93,0xFE,0xA8,0x2D,0xBF,0xFB,0xED,0x42,0xE0,0x42,0xFD,0x17,0x04,0xB0
|
||||
};
|
||||
|
||||
#include "my_keys.h"
|
||||
|
||||
|
||||
static BOOL my_sign_check(MY_SIGN_SIGNATURE *encrypted_sign, u8 *buf, int buf_size)
|
||||
|
||||
@ -26,7 +26,6 @@ static PRE_INSTALL_FILE *pre_install_file_list = NULL;
|
||||
|
||||
|
||||
#if 1
|
||||
//char *pre_install_search_tid(u64 tid, FSFile *log_fd);
|
||||
static void pre_install_print_list(FSFile *log_fd);
|
||||
static BOOL pre_install_discard_list(void);
|
||||
static BOOL pre_install_load_file(char *path, FSFile *log_fd, BOOL encrypt_flag);
|
||||
@ -195,7 +194,7 @@ static BOOL pre_install_add_list(u64 tid, u16 version, u16 groupid, char *temp_f
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *pre_install_search_tid(u64 tid, FSFile *log_fd, BOOL *is_in_sd)
|
||||
static char *pre_install_search_tid(u64 tid, FSFile *log_fd, BOOL *is_in_sd, u16 *version)
|
||||
{
|
||||
PRE_INSTALL_FILE *temp_list;
|
||||
PRE_INSTALL_FILE *latest_list;
|
||||
@ -230,12 +229,18 @@ static char *pre_install_search_tid(u64 tid, FSFile *log_fd, BOOL *is_in_sd)
|
||||
|
||||
|
||||
if( latest_list ) {
|
||||
if( !STD_StrNCmp( latest_list->file_name, "sdmc:" , STD_StrLen("sdmc:")) ) {
|
||||
*is_in_sd = TRUE;
|
||||
if( is_in_sd ) {
|
||||
if( !STD_StrNCmp( latest_list->file_name, "sdmc:" , STD_StrLen("sdmc:")) ) {
|
||||
*is_in_sd = TRUE;
|
||||
}
|
||||
else {
|
||||
*is_in_sd = FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*is_in_sd = FALSE;
|
||||
if( version ) {
|
||||
*version = latest_list->version;
|
||||
}
|
||||
|
||||
miya_log_fprintf(log_fd,"\ntad file entry tid=0x%08x%08x\n%s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), latest_list->file_name );
|
||||
|
||||
@ -758,7 +763,7 @@ BOOL pre_install_command(FSFile *log_fd, u64 *tid_array, int tid_count, int com
|
||||
case 1:
|
||||
mprintf("IA ");
|
||||
miya_log_fprintf(log_fd, "IA ");
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd);
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd, NULL);
|
||||
if( tad_file_name ) {
|
||||
if( is_in_sd == TRUE ) {
|
||||
ret_flag = myImportTad_sign( tad_file_name , org_version, log_fd );
|
||||
@ -775,7 +780,7 @@ BOOL pre_install_command(FSFile *log_fd, u64 *tid_array, int tid_count, int com
|
||||
case 2:
|
||||
mprintf("TO ");
|
||||
miya_log_fprintf(log_fd, "TO ");
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd);
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd, NULL);
|
||||
if( tad_file_name ) {
|
||||
if( is_in_sd == TRUE ) {
|
||||
ret_flag = my_NAM_ImportTadTicketOnly_sign( tad_file_name );
|
||||
@ -856,6 +861,7 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
BOOL ret_flag = TRUE;
|
||||
BOOL is_in_sd = FALSE;
|
||||
int version;
|
||||
u16 version_in_tad;
|
||||
|
||||
if( development_version_flag ) {
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_DEV_FILE_SD, log_fd, TRUE);
|
||||
@ -880,7 +886,7 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
continue;
|
||||
}
|
||||
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd);
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd, &version_in_tad);
|
||||
if( tad_file_name ) {
|
||||
if( is_in_sd == TRUE ) {
|
||||
ret_flag = my_NAM_ImportTadTicketOnly_sign( tad_file_name );
|
||||
@ -925,9 +931,12 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
pTitleIds[i].is_personalized = 1 -> common (pre installed)
|
||||
pTitleIds[i].is_personalized = 2 -> personalized
|
||||
*/
|
||||
if( (title_id_buf_ptr[i].is_personalized == 1 /* commonの場合 */) &&
|
||||
(title_id_buf_ptr[i].common_and_download == 0 ) ) {
|
||||
/* commonだけどユーザーが最新バージョンを持ってる場合はダウンロードに切り替えてる。 */
|
||||
|
||||
|
||||
// (title_id_buf_ptr[i].common_and_download == 0 )
|
||||
|
||||
if( (title_id_buf_ptr[i].is_personalized == 1 /* commonの場合 */) ) {
|
||||
|
||||
/*
|
||||
0x00030004484E474A "rom:/tads/TWL-KGUJ-v257.tad.out"
|
||||
0x000300044B32444A "rom:/tads/TWL-K2DJ-v0.tad.out"
|
||||
@ -938,41 +947,83 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
|
||||
|
||||
(void)my_fs_Tid_To_GameCode(tid, game_code_buf);
|
||||
mprintf(" AP %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " AP %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd);
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd, &is_in_sd, &version_in_tad);
|
||||
if( tad_file_name ) {
|
||||
/* commonだけどユーザーが最新バージョンを持ってる場合はダウンロードに切り替えてる。 */
|
||||
|
||||
if( is_in_sd == TRUE ) {
|
||||
ret_flag = myImportTad_sign( tad_file_name , version, log_fd);
|
||||
if( version > version_in_tad ) {
|
||||
|
||||
// miya....
|
||||
|
||||
mprintf(" AP %08x %08x [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " AP %08x %08x [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
|
||||
|
||||
if( is_in_sd == TRUE ) {
|
||||
ret_flag = my_NAM_ImportTadTicketOnly_sign( tad_file_name );
|
||||
}
|
||||
else {
|
||||
ret_flag = my_NAM_ImportTadTicketOnly( tad_file_name );
|
||||
}
|
||||
|
||||
if( ret_flag == TRUE ) {
|
||||
title_id_buf_ptr[i].common_and_download = 1; /* あとでダウンロードするようにチェックをつける。 */
|
||||
miya_log_fprintf(log_fd, "OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
miya_log_fprintf(log_fd," Pre->Dwn usr.ver=0x%04x tad.ver=0x%04x\n", version, version_in_tad );
|
||||
mprintf(" Pre->Dwn usr.ver=0x%04x tad.ver=0x%04x\n", version, version_in_tad );
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
miya_log_fprintf(log_fd, "error: import ticket only tid=0x%08x%08x %s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), tad_file_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret_flag = myImportTad( tad_file_name , version, log_fd);
|
||||
}
|
||||
if( FALSE == ret_flag ) {
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
miya_log_fprintf(log_fd, "error: import tid=0x%08x%08x %s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), tad_file_name);
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, "OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
title_id_buf_ptr[i].install_success_flag = TRUE; /* これを入れとかないと後でセーブデータを復活しない */
|
||||
mprintf(" AP %08x %08x [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " AP %08x %08x [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
|
||||
if( is_in_sd == TRUE ) {
|
||||
ret_flag = myImportTad_sign( tad_file_name , version, log_fd);
|
||||
}
|
||||
else {
|
||||
ret_flag = myImportTad( tad_file_name , version, log_fd);
|
||||
}
|
||||
|
||||
if( ret_flag == TRUE ) {
|
||||
title_id_buf_ptr[i].install_success_flag = TRUE; /* これを入れとかないと後でセーブデータを復活しない */
|
||||
miya_log_fprintf(log_fd, "OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
miya_log_fprintf(log_fd, "error: import tid=0x%08x%08x %s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), tad_file_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, " AP %08x %08x [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, "No file\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */
|
||||
|
||||
mprintf(" AP %08x %08x [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
|
||||
mprintf("No file\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
miya_log_fprintf(log_fd, "error: no file\n");
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
}
|
||||
@ -985,7 +1036,7 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int pre_install_check_tad_version(FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int title_id_count,
|
||||
BOOL development_version_flag )
|
||||
{
|
||||
@ -1050,28 +1101,18 @@ int pre_install_check_tad_version(FSFile *log_fd, MY_USER_APP_TID *title_id_buf_
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), version, latest_list->version );
|
||||
|
||||
ret_flag = FALSE;
|
||||
#if 1 /* miya 20091021 */
|
||||
#define ONLY_TICKET 1
|
||||
|
||||
/* とりあえずEチケットだけインストール? */
|
||||
/* とりあえずEチケットだけインストール */
|
||||
tad_file_name = latest_list->file_name;
|
||||
if( tad_file_name ) {
|
||||
if( !STD_StrNCmp( tad_file_name, "sdmc:" , STD_StrLen("sdmc:")) ) {
|
||||
#ifdef ONLY_TICKET
|
||||
ret_flag = my_NAM_ImportTadTicketOnly_sign( tad_file_name );
|
||||
#else
|
||||
ret_flag = myImportTad_sign( tad_file_name , 0, log_fd);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef ONLY_TICKET
|
||||
ret_flag = my_NAM_ImportTadTicketOnly( tad_file_name );
|
||||
#else
|
||||
ret_flag = myImportTad( tad_file_name , 0, log_fd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ret_flag == TRUE ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
@ -1099,3 +1140,5 @@ int pre_install_check_tad_version(FSFile *log_fd, MY_USER_APP_TID *title_id_buf_
|
||||
miya_log_fprintf(log_fd, "%s end: num=%d\n",__FUNCTION__,ret_count);
|
||||
return ret_count;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -25,9 +25,10 @@ BOOL pre_install_get_version(u64 tid, u16 *version);
|
||||
BOOL pre_install_debug(FSFile *log_fd, BOOL development_version_flag );
|
||||
BOOL pre_install_command(FSFile *log_fd, u64 *tid_array, int tid_count, int command, BOOL development_version_flag );
|
||||
|
||||
#if 0
|
||||
int pre_install_check_tad_version(FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr,
|
||||
int title_id_count, BOOL development_version_flag );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ SRCS = main.c mfiler.c key.c font.c text.c mprintf.c logprintf.c \
|
||||
sitedefs.c wcm_control.c netconnect.c mywlan.c \
|
||||
mynuc.c nuc_error_msg.c stream.c myfilename.c menu_version.c \
|
||||
ntp.c myimport.c pre_install.c \
|
||||
my_rsa_sign.c my_aes.c my_sha.c my_sign.c
|
||||
my_rsa_sign.c my_aes.c my_sha.c my_sign.c my_keys.c
|
||||
|
||||
|
||||
TARGET_BIN = copy_dst.srl
|
||||
|
||||
@ -61,6 +61,8 @@
|
||||
|
||||
#include <twl/ltdmain_begin.h>
|
||||
|
||||
|
||||
// #define CHINA_LIMITED 1
|
||||
// #define PRE_INSTALL 1
|
||||
|
||||
//================================================================================
|
||||
@ -742,13 +744,50 @@ static BOOL RestoreFromSDCard7(void)
|
||||
/* ECDownload の前準備,終わり。*/
|
||||
|
||||
|
||||
#if 0
|
||||
/* miya 2009/10/12 */
|
||||
/* TitleIDLoadの後、title_id_buf_ptr, title_id_countに書き込む */
|
||||
/* title_id_buf_ptr[i].common_and_download == 1 のときはダウンロードするように。 */
|
||||
miya_log_fprintf(log_fd,"Internal data version check.\n");
|
||||
mprintf("Internal data version check.\n");
|
||||
(void)pre_install_check_tad_version(log_fd, title_id_buf_ptr, title_id_count, development_console_flag );
|
||||
#endif
|
||||
|
||||
if( no_network_flag == TRUE ) {
|
||||
miya_log_fprintf(log_fd,"no network flag ON\n");
|
||||
goto pre_install_label;
|
||||
|
||||
pre_install_label:
|
||||
|
||||
if( (mydata.num_of_user_pre_installed_app > 0) ||
|
||||
(mydata.num_of_user_pre_installed_eticket_only > 0) ) {
|
||||
/* プリンストール対応 */
|
||||
miya_log_fprintf(log_fd,"Import Pre-installed apps.\n");
|
||||
mprintf("Import Pre-installed apps.\n");
|
||||
if( mydata.num_of_user_pre_installed_eticket_only > 0 ) {
|
||||
if( FALSE == UserTitleIDLoadETicketOnly( MyFile_GetUserTitleIDTicketOnlyFileName(),
|
||||
&eticket_only_id_buf, &num_of_eticket_only_titles,
|
||||
MyFile_GetUserTitleIDTicketOnlyRestoreLogFileName()) ) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/* pre_install_process関数の中でEチケットだけのやつもやりたい。 */
|
||||
if( FALSE == pre_install_process( log_fd, title_id_buf_ptr, title_id_count,
|
||||
eticket_only_id_buf,
|
||||
mydata.num_of_user_pre_installed_eticket_only ,
|
||||
development_console_flag ) ) {
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
|
||||
if( eticket_only_id_buf ) {
|
||||
OS_Free(eticket_only_id_buf );
|
||||
eticket_only_id_buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( no_network_flag == TRUE ) {
|
||||
miya_log_fprintf(log_fd,"no network flag ON\n");
|
||||
goto network_connection_end;
|
||||
}
|
||||
|
||||
if( mydata.shop_record_flag == FALSE ) {
|
||||
/* ネットワークにつながなくていいか? */
|
||||
@ -758,13 +797,6 @@ static BOOL RestoreFromSDCard7(void)
|
||||
else {
|
||||
|
||||
|
||||
/* miya 2009/10/12 */
|
||||
/* TitleIDLoadの後、title_id_buf_ptr, title_id_countに書き込む */
|
||||
/* title_id_buf_ptr[i].common_and_download == 1 のときはダウンロードするように。 */
|
||||
miya_log_fprintf(log_fd,"Internal data version check.\n");
|
||||
mprintf("Internal data version check.\n");
|
||||
(void)pre_install_check_tad_version(log_fd, title_id_buf_ptr, title_id_count, development_console_flag );
|
||||
|
||||
|
||||
miya_log_fprintf(log_fd,"EC download\n");
|
||||
mprintf("EC download\n");
|
||||
@ -878,35 +910,7 @@ static BOOL RestoreFromSDCard7(void)
|
||||
}
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
pre_install_label:
|
||||
|
||||
if( (mydata.num_of_user_pre_installed_app > 0) ||
|
||||
(mydata.num_of_user_pre_installed_eticket_only > 0) ) {
|
||||
/* プリンストール対応 */
|
||||
miya_log_fprintf(log_fd,"Import Pre-installed apps.\n");
|
||||
mprintf("Import Pre-installed apps..\n");
|
||||
if( mydata.num_of_user_pre_installed_eticket_only > 0 ) {
|
||||
if( FALSE == UserTitleIDLoadETicketOnly( MyFile_GetUserTitleIDTicketOnlyFileName(),
|
||||
&eticket_only_id_buf, &num_of_eticket_only_titles,
|
||||
MyFile_GetUserTitleIDTicketOnlyRestoreLogFileName()) ) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/* pre_install_process関数の中でEチケットだけのやつもやりたい。 */
|
||||
if( FALSE == pre_install_process( log_fd, title_id_buf_ptr, title_id_count,
|
||||
eticket_only_id_buf,
|
||||
mydata.num_of_user_pre_installed_eticket_only ,
|
||||
development_console_flag ) ) {
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
|
||||
if( eticket_only_id_buf ) {
|
||||
OS_Free(eticket_only_id_buf );
|
||||
eticket_only_id_buf = NULL;
|
||||
}
|
||||
}
|
||||
network_connection_end:
|
||||
|
||||
hatamotolib_log_end();
|
||||
|
||||
@ -949,12 +953,6 @@ static BOOL RestoreFromSDCard8(void)
|
||||
mprintf("Original app. save data saving failed\n");
|
||||
}
|
||||
|
||||
if( title_id_buf_ptr != NULL ) {
|
||||
OS_Free( title_id_buf_ptr );
|
||||
title_id_buf_ptr = NULL;
|
||||
}
|
||||
title_id_count = 0;
|
||||
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
|
||||
|
||||
if( TRUE == Error_Report_Display(tc[0]) ) {
|
||||
@ -968,6 +966,16 @@ static BOOL RestoreFromSDCard8(void)
|
||||
}
|
||||
|
||||
|
||||
static BOOL RestoreFromSDCard9(void)
|
||||
{
|
||||
if( title_id_buf_ptr != NULL ) {
|
||||
OS_Free( title_id_buf_ptr );
|
||||
title_id_buf_ptr = NULL;
|
||||
}
|
||||
title_id_count = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
typedef BOOL (*function_ptr)(void);
|
||||
|
||||
@ -980,7 +988,8 @@ static function_ptr function_table[] =
|
||||
RestoreFromSDCard5,
|
||||
RestoreFromSDCard6,
|
||||
RestoreFromSDCard7,
|
||||
RestoreFromSDCard8
|
||||
RestoreFromSDCard8,
|
||||
RestoreFromSDCard9,
|
||||
};
|
||||
|
||||
static int function_table_max = sizeof(function_table) / sizeof(*function_table);
|
||||
@ -1305,6 +1314,9 @@ void TwlMain(void)
|
||||
u16 BatterylevelBuf = 0;
|
||||
BOOL isAcConnectedBuf = FALSE;
|
||||
|
||||
#ifdef CHINA_LIMITED
|
||||
BOOL isIgnoreKeyInput = FALSE;
|
||||
#endif
|
||||
|
||||
OS_Init();
|
||||
OS_InitThread();
|
||||
@ -1358,8 +1370,6 @@ void TwlMain(void)
|
||||
SEA_Init();
|
||||
|
||||
reboot_flag = OS_IsRebooted();
|
||||
/* OS_IsRebootedなんかおかしい・・ */
|
||||
|
||||
|
||||
MIYA_MCU_Init();
|
||||
|
||||
@ -1446,10 +1456,25 @@ void TwlMain(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// region
|
||||
org_region = LCFG_THW_GetRegion();
|
||||
// ES Device ID
|
||||
|
||||
#ifdef CHINA_LIMITED
|
||||
mprintf("This software has limited use\n");
|
||||
mprintf(" of China region. - ");
|
||||
|
||||
if( org_region != OS_TWL_REGION_CHINA ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED );
|
||||
mprintf("Invalid\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
isIgnoreKeyInput = TRUE;
|
||||
}
|
||||
else {
|
||||
mprintf("Valid\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// 国が選択されていないなら適当に設定
|
||||
if( LCFG_TSD_GetCountry() == LCFG_TWL_COUNTRY_UNDEFINED ) {
|
||||
@ -1508,10 +1533,9 @@ void TwlMain(void)
|
||||
#define LCFGi_GetTSD() ( &s_settings )
|
||||
#define LCFGi_GetTSD_OS() ( (OSTWLSettingsData*)HW_PARAM_TWL_SETTINGS_DATA )
|
||||
|
||||
|
||||
|
||||
*******************/
|
||||
|
||||
// ES Device ID
|
||||
|
||||
org_fuseId = SCFG_ReadFuseData();
|
||||
OS_TPrintf("eFuseID: %08X%08X\n", (u32)(org_fuseId >> 32), (u32)(org_fuseId));
|
||||
@ -1637,14 +1661,23 @@ void TwlMain(void)
|
||||
OS_WaitVBlankIntr();
|
||||
(void)RTC_GetDate( &rtc_date );
|
||||
(void)RTC_GetTime( &rtc_time );
|
||||
|
||||
#ifdef CHINA_LIMITED
|
||||
if( isIgnoreKeyInput == FALSE ) {
|
||||
keyData = m_get_key_trigger();
|
||||
}
|
||||
#else
|
||||
keyData = m_get_key_trigger();
|
||||
|
||||
#endif
|
||||
|
||||
// ARM7コマンド応答受信
|
||||
while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL)
|
||||
{
|
||||
}
|
||||
// コマンドフラッシュ(フラッシュして即座に実行を要求)
|
||||
(void)SND_FlushCommand(SND_COMMAND_NOBLOCK | SND_COMMAND_IMMEDIATE);
|
||||
|
||||
|
||||
if ( keyData & PAD_BUTTON_R ) {
|
||||
vram_num_main++;
|
||||
if( vram_num_main > (MAX_VRAM_NUM-1) ) {
|
||||
@ -1924,6 +1957,8 @@ void TwlMain(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* メイン表示部 */
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mfprintf(tc[1], "\fRepaire Tool RESTORE");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
/* cryptopc *.der infile outfile
|
||||
cryptopc miya1024.der main.c main.enc
|
||||
|
||||
openssl rsa -inform DER -in tad1024.der -text
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -7,6 +7,14 @@
|
||||
makesdtd.exe -indir [inputdir] -odir sdtads
|
||||
makesdtd.exe -indir test-tad -odir sdtads
|
||||
|
||||
|
||||
|
||||
|
||||
openssl genrsa -out tad1024miya.der 1024 -outform DER
|
||||
|
||||
|
||||
rsa_keysrcgen.exe -in tad1024miya.der
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -77,6 +77,14 @@ static FILE *fp_key = NULL;
|
||||
static int rsaSize = 0;
|
||||
static RSA *rsa_key = NULL;
|
||||
|
||||
|
||||
/*
|
||||
#ifdef CHINA_LIMITED
|
||||
#endif CHINA_LIMITED
|
||||
|
||||
common/src/my_keys.cと対
|
||||
|
||||
*/
|
||||
static u8 my_sign_aes_key[AES_KEY_BYTE_LEN] = {
|
||||
0x02,0xB6,0x01,0xD8,0x01,0x80,0x01,0x77,0xB4,0x01,0xCB,0x01,0xBD,0x5F,0x18,0x0F,
|
||||
0xF6,0x39,0x9C,0xC6,0x90,0xAC,0xC1,0x0D,0x03,0x74,0x6E,0x8D,0xD1,0xBA,0x37,0x46
|
||||
|
||||
Loading…
Reference in New Issue
Block a user