フィンガープリンタ:コマンドラインだとDLLがうまく呼び出されないので、環境変数PATHを実行前に一時的に書き換えることにした。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@264 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2009-04-17 12:32:34 +00:00
parent d456a2d4f6
commit e4c12c4dc0
13 changed files with 243 additions and 50 deletions

View File

@ -4,6 +4,7 @@
#include "Form1.h"
extern void fingerprintConsole( cli::array<System::String^> ^args );
void setpath();
using namespace FingerPrinterTWL;
@ -17,6 +18,8 @@ int main(array<System::String ^> ^args)
if( arg->StartsWith("-") && (arg->IndexOf('g') >= 0) )
{
guimode = true;
setpath();
break;
}
}
@ -31,6 +34,7 @@ int main(array<System::String ^> ^args)
}
else
{
setpath(); // コマンドライン起動のときにはPATHを設定する
try
{
fingerprintConsole( args );
@ -43,3 +47,11 @@ int main(array<System::String ^> ^args)
}
return 0;
}
// 環境変数PATHの設定
void setpath()
{
System::String ^bindir = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location );
System::Environment::SetEnvironmentVariable( "PATH", bindir );
}

View File

@ -26,8 +26,8 @@ void Form1::construct()
System::String ^example = "Input Example\r\n\r\n"
+ "(1)String of ASCII Charactors\r\n"
+ " *ABCD\r\n"
+ " => register \"41424344\" (\'A\' \'B\' \'C\' \'D\')\r\n\r\n"
+ " *AB CD\r\n"
+ " => register \"4142204344\" (\'A\' \'B\' \' \' \'C\' \'D\')\r\n\r\n"
+ "(2)Hexadecimal Numbers\r\n"
+ " *5A6B78014A235A\r\n"
+ " *5a6b78014a235a\r\n"
@ -105,6 +105,7 @@ void Form1::commonOpenRom( System::String ^srcpath )
}
memset( this->rh, 0, sizeof(ROM_Header) );
ExtractRomHeader( this->srlbin, this->rh );
AuthenticateRomHeader( this->rh );
// すでにフィンガープリントされている場合には注意書きを表示
if( this->isFingerprint() )
@ -183,6 +184,10 @@ void Form1::procSaveRomButton()
{
try
{
if( System::String::IsNullOrEmpty(this->tboxFile->Text) )
{
throw gcnew Exception("The input ROM file has not read yet.");
}
System::String ^format = nullptr;
System::String ^ext = nullptr;
if( this->rTad->Checked )
@ -248,7 +253,7 @@ void Form1::procAboutButton()
void Form1::sucMsg( System::String ^fmt, ... cli::array<System::String^> ^args )
{
System::String ^msg = System::String::Format( fmt, args ); // 書式をStringに展開
MessageBox::Show( msg, "SUCCESS", MessageBoxButtons::OK, MessageBoxIcon::Information );
MessageBox::Show( msg, "SUCCESS", MessageBoxButtons::OK, MessageBoxIcon::None );
}
void Form1::errMsg( System::String ^fmt, ... cli::array<System::String^> ^args )

View File

@ -122,6 +122,7 @@ void fingerprintConsole( cli::array<System::String^> ^args )
}
ROM_Header rh;
ExtractRomHeader( srlbin, &rh );
AuthenticateRomHeader( &rh );
// fingerprint が埋め込まれていたら表示して上書き確認をする
bool isFingerprint = false;

View File

@ -35,6 +35,9 @@ void CopyFile( System::String ^srcpath, System::String ^dstpath );
// ROMヘッダに署名をつける
void SignRomHeader( ROM_Header *rh );
// ROMヘッダの署名チェック
void AuthenticateRomHeader( ROM_Header *rh );
// ----------------------------------------------------------------------
// 変換
// ----------------------------------------------------------------------

View File

@ -269,34 +269,10 @@ void SignRomHeader( ROM_Header *rh )
ACSign_DigestUnit(
signSrc.digest,
rh,
(u32)&(rh->certificate) - (u32)rh // this->pRomHeader はマネージヒープ上にあるので実アドレスを取得できない
(u32)&(rh->certificate) - (u32)rh
);
// 鍵を選ぶ
#ifdef METWL_VER_APPTYPE_LAUNCHER
if( this->IsAppLauncher )
{
privateKey = (u8*)g_devPrivKey_DER_launcher;
publicKey = (u8*)g_devPubKey_DER_launcher;
}
else
#endif //METWL_VER_APPTYPE_LAUNCHER
#ifdef METWL_VER_APPTYPE_SECURE
if( this->IsAppSecure )
{
privateKey = (u8*)g_devPrivKey_DER_secure;
publicKey = (u8*)g_devPubKey_DER_secure;
}
else
#endif //METWL_VER_APPTYPE_SECURE
#ifdef METWL_VER_APPTYPE_SYSTEM
if( this->IsAppSystem )
{
privateKey = (u8*)g_devPrivKey_DER_system;
publicKey = (u8*)g_devPubKey_DER_system;
}
else
#endif //METWL_VER_APPTYPE_SYSTEM
#ifdef METWL_VER_APPTYPE_USER
{
privateKey = (u8*)g_devPrivKey_DER;
@ -328,6 +304,49 @@ void SignRomHeader( ROM_Header *rh )
} // ECSrlResult RCSrl::signRomHeader(void)
// ROMヘッダの署名チェック
void AuthenticateRomHeader( ROM_Header *rh )
{
u8 original[ RSA_KEY_LENGTH ]; // 署名外した後のデータ格納先
s32 pos = 0; // ブロックの先頭アドレス
u8 digest[ DIGEST_SIZE_SHA1 ]; // ROMヘッダのダイジェスト
u8 *publicKey = (u8*)g_devPubKey_DER;
// <データの流れ>
// (1) 公開鍵で復号した結果(ブロック)をローカル変数(original)に格納
// (2) ブロックから余分な部分を取り除いて引数(pDst)にコピー
#ifdef METWL_VER_APPTYPE_USER
{
publicKey = (u8*)g_devPubKey_DER;
}
#endif //METWL_VER_APPTYPE_USER
// 署名の解除 = 公開鍵で復号
if( !ACSign_Decrypto( original, publicKey, rh->signature, RSA_KEY_LENGTH ) )
{
throw gcnew System::Exception("Failed to decrypt the ROM signature.");
}
// 署名前データを復号後ブロックからゲット
for( pos=0; pos < (RSA_KEY_LENGTH-2); pos++ ) // 本来ブロックの先頭は0x00だが復号化の内部処理によって消える仕様
{
// 暗号ブロック形式 = 0x00, BlockType, Padding, 0x00, 実データ
if( original[pos] == 0x00 ) // 実データの直前の0x00をサーチ
{
break;
}
}
// ベリファイ
// ROMヘッダのダイジェストを算出(先頭から証明書領域の直前までが対象)
ACSign_DigestUnit( digest, rh, (u32)&(rh->certificate) - (u32)rh );
if( memcmp( &(original[pos+1]), digest, DIGEST_SIZE_SHA1 ) != 0 )
{
System::String ^msg =
"Failed to verify the ROM digest data.\r\n"
+"Either this is not TWL-compatible or TWL-exclusive ROM data, or the ROM data may have been modified.";
throw gcnew System::Exception(msg);
}
}
// ----------------------------------------------------------------------
// 変換

View File

@ -3,7 +3,7 @@
"VSVersion" = "3:800"
"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}"
"IsWebType" = "8:FALSE"
"ProjectName" = "8:FingerprintTWLSetup"
"ProjectName" = "8:FingerprinterTWLSetup"
"LanguageId" = "3:0"
"CodePage" = "3:1252"
"UILanguageId" = "3:0"
@ -15,13 +15,7 @@
{
"Entry"
{
"MsmKey" = "8:_3B49ADDB433A430DBABEA66B4C6F4E5F"
"OwnerKey" = "8:_3DFFDFF35E454135AD3FBE6F59C6BCA0"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_3DFFDFF35E454135AD3FBE6F59C6BCA0"
"MsmKey" = "8:_AEAD81F7D6FC43AFB5C54B548CEE51B2"
"OwnerKey" = "8:_B144741D3BBE43B9B8E91A95FE18B531"
"MsmSig" = "8:_UNDEFINED"
}
@ -33,6 +27,18 @@
}
"Entry"
{
"MsmKey" = "8:_D4ECA7596ABB498FB1CB5014C2A62F23"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F0BED259DF1F4E8FAC8CF1BA7C2C89DA"
"OwnerKey" = "8:_AEAD81F7D6FC43AFB5C54B548CEE51B2"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F83AF9653A3844EA828993912994ADDB"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@ -51,7 +57,7 @@
"DisplayName" = "8:Debug"
"IsDebugOnly" = "11:TRUE"
"IsReleaseOnly" = "11:FALSE"
"OutputFilename" = "8:Debug\\FingerprintTWLSetup.msi"
"OutputFilename" = "8:Debug\\FingerprinterTWLSetup.msi"
"PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648"
"CabType" = "3:1"
@ -88,7 +94,7 @@
"DisplayName" = "8:Release"
"IsDebugOnly" = "11:FALSE"
"IsReleaseOnly" = "11:TRUE"
"OutputFilename" = "8:Release\\FingerprintTWLSetup.msi"
"OutputFilename" = "8:Release\\FingerprinterTWLSetup.msi"
"PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648"
"CabType" = "3:1"
@ -148,6 +154,26 @@
}
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D4ECA7596ABB498FB1CB5014C2A62F23"
{
"SourcePath" = "8:..\\LICENSE.txt"
"TargetName" = "8:LICENSE.txt"
"Tag" = "8:"
"Folder" = "8:_9AD562D239AE45538903EC973D3A7011"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F83AF9653A3844EA828993912994ADDB"
{
"SourcePath" = "8:..\\README.txt"
@ -223,9 +249,9 @@
"Product"
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:FingerprintTWL"
"ProductName" = "8:FingerprinterTWL"
"ProductCode" = "8:{2DB70A66-66FE-4745-AA22-8E4B8CEAA172}"
"PackageCode" = "8:{C7186ADF-21B0-4BD0-AB86-46BEC5003DCB}"
"PackageCode" = "8:{CEA2AF13-CCD2-4A56-8F78-B6127BC766BA}"
"UpgradeCode" = "8:{7E1BDE16-5571-4BC2-8270-A59334D41679}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:FALSE"
@ -235,7 +261,7 @@
"Manufacturer" = "8:Nintendo"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
"Title" = "8:FingerprintTWLSetup"
"Title" = "8:FingerprinterTWLSetup"
"Subject" = "8:"
"ARPCONTACT" = "8:Nintendo"
"Keywords" = "8:"
@ -754,11 +780,11 @@
}
"MergeModule"
{
"{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_3B49ADDB433A430DBABEA66B4C6F4E5F"
"{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_AEAD81F7D6FC43AFB5C54B548CEE51B2"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
"SourcePath" = "8:microsoft_vc90_debugcrt_x86.msm"
"SourcePath" = "8:policy_9_0_Microsoft_VC90_CRT_x86.msm"
"Properties"
{
}
@ -768,11 +794,11 @@
"Feature" = "8:"
"IsolateTo" = "8:"
}
"{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_3DFFDFF35E454135AD3FBE6F59C6BCA0"
"{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_F0BED259DF1F4E8FAC8CF1BA7C2C89DA"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
"SourcePath" = "8:policy_9_0_Microsoft_VC90_DebugCRT_x86.msm"
"SourcePath" = "8:microsoft_vc90_crt_x86.msm"
"Properties"
{
}
@ -787,7 +813,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_B144741D3BBE43B9B8E91A95FE18B531"
{
"SourcePath" = "8:..\\Debug\\FingerPrinterTWL.exe"
"SourcePath" = "8:..\\Release\\FingerPrinterTWL.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_9AD562D239AE45538903EC973D3A7011"

View File

@ -0,0 +1,125 @@
LICENSE ISSUES
==============
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
the OpenSSL License and the original SSLeay license apply to the toolkit.
See below for the actual license texts. Actually both licenses are BSD-style
Open Source licenses. In case of any license issues related to OpenSSL
please contact openssl-core@openssl.org.
OpenSSL License
---------------
/* ====================================================================
* Copyright (c) 1998-2008 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
Original SSLeay License
-----------------------
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/

View File

@ -29,10 +29,12 @@ Required Environment
Microsoft Windows XP SP2
Microsoft .NET Framework 2.0
maketad.exe : included in TwlSDK
And following DLLs, which are not included in this package.
- cygwin1.dll
- cygcrypto-0.9.8.dll
Store following program and DLLs, which are not included in this package,
into the install folder.
- maketad.exe (included in TwlSDK)
- cygwin1.dll (included in Cygwin)
- cygcrypto-0.9.8.dll (included in OpenSSL)
=======================================================================
Using the Tool