FakeRomHeader:製品技術部向けの機能制限版をビルドできるようにした。ビルドオプションで指定するので、ビルド方法.txtを参照すること。Readmeを製品技術部向けに加筆。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2901 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
nishikawa_takeshi 2009-08-18 11:14:43 +00:00
parent 0c120f87f8
commit e3349fb239
5 changed files with 815 additions and 41 deletions

View File

@ -21,7 +21,7 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
TARGETS = FakeRomHeader$(SUFFIX).exe
TARGETS = $(PREFIX)$(SUFFIX).exe
SOURCES_C = main.c keys.c
@ -62,6 +62,13 @@ endif
endif
endif
ifeq ($(FOR_RED),TRUE)
MACROS += -DFOR_RED
PREFIX = FakeRomHeader
else
PREFIX = RomVersionChanger
endif
LDIRT_CLEAN = $(OBJECTS) $(TARGETS) *.BAK $(REVISION_H)
include $(TWLSDK_ROOT)/build/buildtools/twl/modulerules.x86

View File

@ -0,0 +1,532 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
<title>ROMバージョンつけかえツール</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id$
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
color: #ffffff;
background-color: #8dc63f;
padding: 0.5em;
font-size: 24px;
font-weight: bold;
border-style: double;
border-width: 3px 5px;
border-color: #009900;
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left {
clear: left }
img.align-right {
clear: right }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font-family: serif ;
font-size: 100% }
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em }
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
ailgn : center;
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
/*** added by seiki ***/
/** common settings *********************************/
body {
font-size : 12px;
text-align : center;
line-height : 140%;
color : #330000;
background-color : #e3e5e6;
}
td, th {
font-size : 12px;
color : #336600;
}
a:link {
text-decoration : none;
color : #339966;
}
a:visited {
text-decoration : none;
color : #666633;
}
a:active {
text-decoration : underline;
color : #ff6600;
}
a:hover {
text-decoration : underline;
color : #ff6600;
}
/** general styles *******************************/
h1 {
color : #009900;
background-color : #ccff66;
padding : 4px;
font-size : 16px;
font-weight : bold;
text-align : left;
margin-top : 1.5em;
border-style : solid;
border-width : 1px 3px;
border-color : #009900;
}
h1 a:hover {
text-decoration : none;
color : #009900;
}
h2 {
color : #336633;
font-size : 16px;
margin-left : 0.5em;
margin-top : 1.5em;
border-style : solid;
border-width : 0 0 1px 5px;
border-color : #339933;
padding-left : 4px;
}
h2 a:hover {
text-decoration : none;
color : #336633;
}
h3 {
color : #339933;
font-size : 12px;
margin-left : 2.0em;
border-style : dotted;
border-width : 0 0 1px 0;
border-color : #66cc66;
}
h3 a:hover {
text-decoration : none;
color : #339933;
}
h4 {
color : #339933;
font-size : 12px;
margin-left : 2.0em;
border-style : dotted;
border-width : 0 0 1px 0;
border-color : #66cc66;
}
h3 a:hover {
text-decoration : none;
color : #339933;
}
p {
margin-left : 3em;
margin-top : 3px;
margin-bottom : 6px;
text-indent : 0em;
line-height : 150%;
}
dt {
font-weight: bold;
margin-top: 0.5em;
margin-left: 2em;
}
dd {
margin-left: 4em;
}
dd p {
margin-left: 0;
text-indent: 0;
line-height: 140%;
}
.author {
font-weight: bold;
text-align: right;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
ul.author li {
list-style-type: none;
}
div.document {
border : solid 1px #666666;
margin : 0pt auto;
padding : 1em 1.5em 1em 1em;
background-color : #ffffff;
text-align : left;
width : 800px;
}
</style>
</head>
<body>
<div class="document" id="rom">
<h1 class="title">ROMバージョンつけかえツール</h1>
<ul class="simple">
<li>目次<ul>
<li><a class="reference internal" href="#id1">ROMバージョンつけかえツールとは?</a></li>
<li><a class="reference internal" href="#id2">非対応なROM形式</a></li>
<li><a class="reference internal" href="#id3">使用上の注意</a></li>
<li><a class="reference internal" href="#id4">実行方法</a></li>
<li><a class="reference internal" href="#id7">エラー</a></li>
<li><a class="reference internal" href="#id8">変更履歴</a></li>
</ul>
</li>
</ul>
<div class="section" id="id1">
<h1>ROMバージョンつけかえツールとは?</h1>
<p>本ツールは、TWL向けSRLのROMバージョンを変更するPCツールです。</p>
</div>
<div class="section" id="id2">
<h1>非対応なROM形式</h1>
<ol class="arabic simple">
<li>クローンブート対応タイトル</li>
</ol>
<p>クローンブート対応タイトルに対して本ツールを使用すると、
出力SRLではクローンブートができなくなります。
TWL Hybridタイトルの場合には、警告が出力されますので、
クローンブート対応でないかを確認してください。</p>
<ol class="arabic simple" start="2">
<li>TAD形式</li>
</ol>
<p>本ツールは SRL 形式のみ対応しています。
本ツールに TAD を入力すると、エラーとなります。
あらかじめ TAD⇒SRL 変換をしてから、本ツールをご使用ください。</p>
<ol class="arabic simple" start="3">
<li>NTR専用ROM</li>
</ol>
<p>TWL向けROM (TWL Hybrid/TWL Limited) のみ入力可能です。</p>
</div>
<div class="section" id="id3">
<h1>使用上の注意</h1>
<p>本ツールは、再ビルドなしにROMバージョンをつけかえるという、
一般開発者が行なうことができないROM設定を可能にするツールです。
したがって、再配布しないようにしてください。
もし部外に配布する必要が生じた場合には、開発技術部にご確認ください。</p>
</div>
<div class="section" id="id4">
<h1>実行方法</h1>
<p>WindowsXP付属のコマンドプロンプト、もしくはcygwinで以下の形式をタイプしてください。</p>
<blockquote>
<ul class="simple">
<li>./RomVersionChecker.exe [オプション] (入力SRLファイル名) (出力SRLファイル名) (ROMバージョン)</li>
</ul>
</blockquote>
<p>たとえば、input.srl のROMバージョンを &quot;0F&quot; にしたい場合、以下のようにタイプしてください。</p>
<blockquote>
<ul class="simple">
<li>./RomVersionChecker.exe input.srl output.srl 0F</li>
</ul>
</blockquote>
<div class="section" id="id5">
<h2>注意</h2>
<p>「ROMバージョン」に入力する値は <strong>16進数</strong> です。 <strong>10進数での入力には対応していません。</strong></p>
<p>たとえば、ROMバージョンを &quot;0C&quot; に設定したい場合には、
&quot;12&quot; ではなく、&quot;0C&quot; と入力してください。</p>
</div>
<div class="section" id="id6">
<h2>オプション</h2>
<ul class="simple">
<li>-h : 使用方法を表示します。</li>
<li>-f : 通常、出力SRLファイルがすでに存在する場合、上書き確認をしますが、
この上書き確認をスキップし、強制的に上書きします。</li>
</ul>
</div>
</div>
<div class="section" id="id7">
<h1>エラー</h1>
<p>プログラムにエラーがあった場合、エラーメッセージが出力されます。</p>
<p>また、通常は、プログラムの返り値は &quot;0&quot; ですが、
エラーが発生した場合には、返り値は &quot;1&quot; となります。</p>
<p>返り値は、Windowsコマンドプロンプトの場合、
%ERRORLEVEL%環境変数に格納されますので、
バッチファイルなどの分岐に利用することができます。</p>
<p>cygwinの場合、返り値の格納先は、
%ERRORLEVEL%環境変数ではなく、シェル変数 $? となります。</p>
</div>
<div class="section" id="id8">
<h1>変更履歴</h1>
<ul class="simple">
<li>ver.1.0 (2009/08/18)</li>
</ul>
<p>初版</p>
</div>
</div>
</body>
</html>

View File

@ -1,35 +1,103 @@
ROMヘッダ偽装ツール
=============================================================================
ROMバージョンつけかえツール
=============================================================================
○What?
* 目次
・PC用コマンドラインツール
・入出力
- 入力: SRL
- 出力: SRL
- 両者の違い: 出力SRLには新たなヘッダCRCと署名がついている
(つまり、署名チェックが通る)
* `ROMバージョンつけかえツールとは?`_
* `非対応なROM形式`_
* `使用上の注意`_
* `実行方法`_
* `エラー`_
* `変更履歴`_
○ビルド方法
ふつうに make すると、署名の鍵がユーザアプリ用になります。
鍵を変えたいとき、以下のオプションをつけて make してください。
ROMバージョンつけかえツールとは?
=============================================================================
make KEY_SYSTEM=TRUE システムアプリ用の鍵が選択される
make KEY_SECURE=TRUE セキュアアプリ用の鍵が選択される
make KEY_LAUNCHER=TRUE ランチャアプリ用の鍵が選択される
本ツールは、TWL向けSRLのROMバージョンを変更するPCツールです。
○実行方法
./fakeRomHeader [Option] input_file output_file
非対応なROM形式
=============================================================================
・オプション
-p: プラットフォームコードを0x01にします。
-s: 署名有効フラグをOffにします。
-d: 新・開発用暗号フラグを0にして、旧・開発用暗号フラグを1にします。
1. クローンブート対応タイトル
・他にもROMヘッダをいじりたいとき
-> バイナリエディタなどでROMヘッダをいじった後に、
本ツールをオプションなしで実行すると、
そのROMヘッダからヘッダCRCと署名を再計算してつけ直します。
クローンブート対応タイトルに対して本ツールを使用すると、
出力SRLではクローンブートができなくなります。
TWL Hybridタイトルの場合には、警告が出力されますので、
クローンブート対応でないかを確認してください。
2. TAD形式
本ツールは SRL 形式のみ対応しています。
本ツールに TAD を入力すると、エラーとなります。
あらかじめ TAD⇒SRL 変換をしてから、本ツールをご使用ください。
3. NTR専用ROM
TWL向けROM (TWL Hybrid/TWL Limited) のみ入力可能です。
使用上の注意
=============================================================================
本ツールは、再ビルドなしにROMバージョンをつけかえるという、
一般開発者が行なうことができないROM設定を可能にするツールです。
したがって、再配布しないようにしてください。
もし部外に配布する必要が生じた場合には、開発技術部にご確認ください。
実行方法
=============================================================================
WindowsXP付属のコマンドプロンプト、もしくはcygwinで以下の形式をタイプしてください。
* ./RomVersionChecker.exe [オプション] (入力SRLファイル名) (出力SRLファイル名) (ROMバージョン)
たとえば、input.srl のROMバージョンを "0F" にしたい場合、以下のようにタイプしてください。
* ./RomVersionChecker.exe input.srl output.srl 0F
注意
------------------------------------------------------------------------------
「ROMバージョン」に入力する値は **16進数** です。 **10進数での入力には対応していません。**
たとえば、ROMバージョンを "0C" に設定したい場合には、
"12" ではなく、"0C" と入力してください。
オプション
------------------------------------------------------------------------------
* -h : 使用方法を表示します。
* -f : 通常、出力SRLファイルがすでに存在する場合、上書き確認をしますが、
この上書き確認をスキップし、強制的に上書きします。
エラー
=============================================================================
プログラムにエラーがあった場合、エラーメッセージが出力されます。
また、通常は、プログラムの返り値は "0" ですが、
エラーが発生した場合には、返り値は "1" となります。
返り値は、Windowsコマンドプロンプトの場合、
%ERRORLEVEL%環境変数に格納されますので、
バッチファイルなどの分岐に利用することができます。
cygwinの場合、返り値の格納先は、
%ERRORLEVEL%環境変数ではなく、シェル変数 $? となります。
変更履歴
=============================================================================
* ver.1.0 (2009/08/18)
初版
以上

View File

@ -78,6 +78,7 @@ SContext;
static BOOL iMain( SContext *pContext );
u16 CalcCRC16(u16 start, u8 *data, int size);
BOOL SignRomHeader( ROM_Header *prh );
BOOL DecryptSignRomHeader( ROM_Header *prh );
static void SetRomSpeedByIndex(ROM_Header * header, tRomSpeedType idx);
/*---------------------------------------------------------------------------*
@ -101,11 +102,19 @@ BOOL DebugMode = FALSE;
void usage()
{
printf( "-----------------------------------------------------------------------------\n" );
#ifdef FOR_RED
printf( "Usage: fakeRomHeader.exe input_file output_file\n" );
printf( " input_file : a ROM data file (generated by makerom.TWL).\n" );
printf( " output_file : a destination file.\n" );
#else
printf( "Usage: fakeRomHeader.exe input_file output_file new_version\n" );
printf( " input_file : a ROM data file (generated by makerom.TWL).\n" );
printf( " output_file : a destination file.\n" );
printf( " ROM_version : a new ROM version.\n" );
#endif
printf( "\nOption:\n" );
printf( "-h : print help only.\n" );
#ifdef FOR_RED
printf( "-p : write invalid platform code in a ROM Header.\n" );
printf( "-s : negate flag for the signature in a ROM Header.\n" );
printf( "-d : negate a new developer encrypt flag, and assert an old one.\n" );
@ -113,7 +122,8 @@ void usage()
printf( "-m : [Only NTR limited ROM] Rom speed type replace 1TROM from MROM.\n" );
printf( "-D : assert a disable flag of debugger alalysis.\n" );
printf( "-c : assert a check(inspection) card flag.\n" );
printf( "-N : skip sign [using for NTR limited ROM]" );
#endif
printf( "-N : skip appending signature [using for NTR limited ROM]" );
printf( "-f : force to overwrite a output_file.\n" );
printf( "-----------------------------------------------------------------------------\n" );
}
@ -130,14 +140,21 @@ int main(int argc, char *argv[])
BOOL bForceOverwrite = FALSE;
printf( "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" );
printf( " fakeRomHeader [%s-%s]\n", SDK_REVISION, IPL_REVISION );
#ifdef FOR_RED
printf( " FakeRomHeader [%s-%s]\n", SDK_REVISION, IPL_REVISION );
#else
printf( " RomVersionChanger [%s-%s]\n", SDK_REVISION, IPL_REVISION );
#endif
printf( "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" );
// context の初期化
memset( &context, 0, sizeof(SContext) );
// オプション
#ifdef FOR_RED
while( (opt = getopt(argc, argv, "hpsdmv:DcfN")) >= 0 )
#endif
while( (opt = getopt(argc, argv, "hfN")) >= 0 )
{
switch( opt )
{
@ -146,6 +163,7 @@ int main(int argc, char *argv[])
return 0;
break;
#ifdef FOR_RED
case 'p':
context.bPlatform = TRUE;
break;
@ -160,7 +178,7 @@ int main(int argc, char *argv[])
case 'v':
context.bVerFlag = TRUE;
context.verNum = atoi(optarg);
context.verNum = strtol(optarg, NULL, 16);
break;
case 'm':
@ -174,7 +192,7 @@ int main(int argc, char *argv[])
case 'c':
context.bCheckCard = TRUE;
break;
#endif
case 'N':
context.bNTR = TRUE;
break;
@ -194,6 +212,7 @@ int main(int argc, char *argv[])
argv = argv + optind;
// 引数処理
#ifdef FOR_RED
if( argc != 2 )
{
usage();
@ -205,6 +224,31 @@ int main(int argc, char *argv[])
pSrc = argv[0];
pDst = argv[1];
}
#else
if( argc != 3 ) // 一般版はROMバージョンを引数として受け取る
{
usage();
printf( "error arguments\n" );
exit(1);
}
else
{
pSrc = argv[0];
pDst = argv[1];
context.bVerFlag = TRUE;
context.verNum = strtol(argv[2], NULL, 16);
}
#endif
// ROMバージョンが1バイトで収まるかチェック
if( context.bVerFlag )
{
if( (context.verNum < 0) || (255 < context.verNum) )
{
printf("Error: ROM version (arg 3) must be within [0, 0xFF].\n");
return -1;
}
}
printf( "input_file: %s\n", pSrc );
printf( "output_file: %s\n", pDst );
@ -266,7 +310,7 @@ FINALIZE:
{
unlink( pDst ); // 出力ファイルを削除する
}
return 0;
return ((bResult)?0:1);
}
/*---------------------------------------------------------------------------*
@ -288,32 +332,79 @@ static BOOL iMain( SContext *pContext )
return FALSE;
}
#ifndef FOR_RED
// 署名の検証
if( !(pContext->bNTR) )
{
if( !DecryptSignRomHeader(&rh) )
{
printf( "Decrypt Sign: Failed\n" );
return FALSE;
}
printf( "Decrypt Sign: Succeeded\n" );
}
else if( rh.s.platform_code == PLATFORM_CODE_NTR )
{
printf( "\n*** Error: required -N option for NTR Limited application. ***\n" );
return FALSE;
}
// Hybridのとき警告
if( rh.s.platform_code == PLATFORM_CODE_TWL_HYBLID)
{
printf("\n");
printf("******************** Warning *******************\n");
printf("* *\n");
printf("* Platform is TWL/NTR Hybrid. *\n");
printf("* *\n");
printf("* Clone-boot application is not supported. *\n");
printf("* *\n");
printf("************************************************\n");
printf("\n");
}
// NTRのときも念のため警告
if( rh.s.platform_code == PLATFORM_CODE_NTR )
{
printf("\n");
printf("******************** Warning *******************\n");
printf("* *\n");
printf("* Platform is NTR Limited. *\n");
printf("* *\n");
printf("* Clone-boot application is not supported. *\n");
printf("* *\n");
printf("************************************************\n");
printf("\n");
}
#endif //#ifndef FOR_RED
// ROMヘッダをいじる
{
if( pContext->bPlatform )
{
printf( "platform_code: 0x%02x -> 0x01\n", rh.s.platform_code );
printf( "Platform Code: 0x%02x -> 0x01\n", rh.s.platform_code );
rh.s.platform_code = 0x01;
}
if( pContext->bSignFlag )
{
printf( "enable_signature: 0x%02x -> 0x00\n", rh.s.enable_signature );
printf( "Enable Signature: 0x%02x -> 0x00\n", rh.s.enable_signature );
rh.s.enable_signature = 0x0;
}
if( pContext->bDevFlag )
{
printf( "old dev. encrypt: 0x%02x -> 0x01x\n", rh.s.developer_encrypt_old );
printf( "new dev. encrypt: 0x%02x -> 0x00x\n", rh.s.exFlags.developer_encrypt );
printf( "Old Dev. Encrypt: 0x%02x -> 0x01x\n", rh.s.developer_encrypt_old );
printf( "Oew Dev. Encrypt: 0x%02x -> 0x00x\n", rh.s.exFlags.developer_encrypt );
rh.s.developer_encrypt_old = 0x1;
rh.s.exFlags.developer_encrypt = 0x0;
}
if( pContext->bVerFlag )
{
printf( "ROM version: 0x%02x -> 0x%02x\n", rh.s.rom_version, pContext->verNum );
rh.s.rom_version = pContext->verNum;
u8 old = rh.s.rom_version;
rh.s.rom_version = (u8)(pContext->verNum & 0xFF);
printf( "ROM version: 0x%02x -> 0x%02X\n", old, rh.s.rom_version );
}
if( pContext->bMROM )
@ -362,17 +453,20 @@ static BOOL iMain( SContext *pContext )
// ヘッダCRC計算
rh.s.header_crc16 = CalcCRC16( CRC16_INIT_VALUE, (u8*)&rh, CALC_CRC16_SIZE );
// <EFBFBD><EFBFBD>¼
// 再署名
if( !(pContext->bMROM) && !(pContext->bNTR) ) // NTR専用オプションのときは署名しない
{
if( !SignRomHeader( &rh ) )
{
printf( "Encrypt Sign: Failed\n" );
printf("\n*** Error: Failed to encrypt the sigunature. ***\n\n");
return FALSE;
}
printf( "Encrypt Sign: Succeeded\n" );
}
else
{
printf( "skip sign\n" );
printf( "Encrypt Sign: Skip\n" );
}
// ファイルをコピる
@ -483,7 +577,7 @@ BOOL SignRomHeader( ROM_Header *prh )
result = ACSign_Encrypto( signDst, g_devPrivKey_DER, &signSrc, sizeof(SignatureData) );
if( !result )
{
printf( "ACSign_Encrypto encryption failed.\n" );
printf( "\n*** Error: failed to ACSign_Encrypto. ***\n\n" );
return FALSE;
}
@ -496,7 +590,7 @@ BOOL SignRomHeader( ROM_Header *prh )
}
if( !result || (memcmp( &signSrc, &(decryptBlock[pos+1]), sizeof(SignatureData) ) != 0) )
{
printf( "Verification a signature failed.\n" );
printf( "\n*** Error: failed to verify the signature. ***\n\n" );
return FALSE;
}
@ -506,6 +600,57 @@ BOOL SignRomHeader( ROM_Header *prh )
return TRUE;
} // ECSrlResult RCSrl::signRomHeader(void)
// 署名を外す
BOOL DecryptSignRomHeader( ROM_Header *prh )
{
u8 original[ RSA_KEY_LENGTH ]; // 署名外した後のデータ格納先
s32 pos = 0; // ブロックの先頭アドレス
u8 digest[ DIGEST_SIZE_SHA1 ]; // ROMヘッダのダイジェスト
// <データの流れ>
// (1) 公開鍵で復号した結果(ブロック)をローカル変数(original)に格納
// (2) ブロックから余分な部分を取り除いて引数(pDst)にコピー
// 鍵選択
#ifdef KEY_USER
printf( "Decryption Key: USER\n" );
#endif
#ifdef KEY_SYSTEM
printf( "Decryption Key: SYSTEM\n" );
#endif
#ifdef KEY_SECURE
printf( "Decryption Key: SECURE\n" );
#endif
#ifdef KEY_LAUNCHER
printf( "Decryption Key: LAUNCHER\n" );
#endif
// 署名の解除 = 公開鍵で復号
if( !ACSign_Decrypto( original, g_devPubKey_DER, prh->signature, RSA_KEY_LENGTH ) )
{
printf( "\n*** Error: failed to decrypt the signature. ***\n\n" );
return FALSE;
}
// 署名前データを復号後ブロックからゲット
for( pos=0; pos < (RSA_KEY_LENGTH-2); pos++ ) // 本来ブロックの先頭は0x00だが復号化の内部処理によって消える仕様
{
// 暗号ブロック形式 = 0x00, BlockType, Padding, 0x00, 実データ
if( original[pos] == 0x00 ) // 実データの直前の0x00をサーチ
{
break;
}
}
// ベリファイ
// ROMヘッダのダイジェストを算出(先頭から証明書領域の直前までが対象)
ACSign_DigestUnit( digest, prh, (u32)&(prh->certificate) - (u32)prh );
if( memcmp( &(original[pos+1]), digest, DIGEST_SIZE_SHA1 ) != 0 )
{
printf( "\n*** Error: failed to verify the signature. ***\n\n" );
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*

View File

@ -0,0 +1,22 @@
ビルド方法
=============
1. 機能制限
ふつうに make すると、製品技術部向けの機能制限版になります。
(バイナリ名が RomVersionChanger.*.exe となります。)
機能制限を解除するには、以下のオプションをつけて make してください。
make FOR_RED=TRUE
2. 鍵の変更
ふつうに make すると、署名の鍵がユーザアプリ用になります。
鍵を変えたいとき、以下のオプションをつけて make してください。
make KEY_SYSTEM=TRUE システムアプリ用の鍵が選択される
make KEY_SECURE=TRUE セキュアアプリ用の鍵が選択される
make KEY_LAUNCHER=TRUE ランチャアプリ用の鍵が選択される