* fix wad class for dealing with backwards-ass cIOS wads

git-svn-id: http://wiiqt.googlecode.com/svn/trunk@53 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
giantpune@gmail.com 2011-01-15 22:45:32 +00:00
parent dfd31fe4ed
commit 2769d3a891

View File

@ -121,7 +121,7 @@ Wad::Wad( const QByteArray &stuff )
//is using the AES that would change the key on us //is using the AES that would change the key on us
AesSetKey( ticket.DecryptedKey() ); AesSetKey( ticket.DecryptedKey() );
QByteArray decData = AesDecrypt( i, encData ); QByteArray decData = AesDecrypt( t.BootIndex( i ), encData );
decData.resize( t.Size( i ) ); decData.resize( t.Size( i ) );
QByteArray realHash = GetSha1( decData ); QByteArray realHash = GetSha1( decData );
if( realHash != t.Hash( i ) ) if( realHash != t.Hash( i ) )
@ -171,7 +171,7 @@ Wad::Wad( const QList< QByteArray > &stuff, bool encrypted )
QByteArray decDataPadded = PaddedByteArray( stuff.at( i + 2 ), 0x40 ); QByteArray decDataPadded = PaddedByteArray( stuff.at( i + 2 ), 0x40 );
//doing this here in case there is some other object that is using the AES that would change the key on us //doing this here in case there is some other object that is using the AES that would change the key on us
AesSetKey( ticket.DecryptedKey() ); AesSetKey( ticket.DecryptedKey() );
encData = AesEncrypt( i, decDataPadded ); encData = AesEncrypt( t.BootIndex( i ), decDataPadded );
} }
partsEnc << encData; partsEnc << encData;
} }
@ -233,7 +233,7 @@ Wad::Wad( QDir dir )
} }
AesSetKey( ticket.DecryptedKey() ); AesSetKey( ticket.DecryptedKey() );
appD = PaddedByteArray( appD, 0x40 ); appD = PaddedByteArray( appD, 0x40 );
QByteArray encData = AesEncrypt( i, appD ); QByteArray encData = AesEncrypt( t.BootIndex( i ), appD );
partsEnc << encData; partsEnc << encData;
} }
//if something in the tmd changed, fakesign it //if something in the tmd changed, fakesign it
@ -311,7 +311,7 @@ const QByteArray Wad::Content( quint16 i )
AesSetKey( ticket.DecryptedKey() ); AesSetKey( ticket.DecryptedKey() );
QByteArray decData = AesDecrypt( i, encData ); QByteArray decData = AesDecrypt( t.BootIndex( i ), encData );
decData.resize( t.Size( i ) ); decData.resize( t.Size( i ) );
QByteArray realHash = GetSha1( decData ); QByteArray realHash = GetSha1( decData );
if( realHash != t.Hash( i ) ) if( realHash != t.Hash( i ) )
@ -809,7 +809,7 @@ bool Wad::ReplaceContent( quint16 idx, const QByteArray &ba )
AesSetKey( ti.DecryptedKey() ); AesSetKey( ti.DecryptedKey() );
QByteArray decDataPadded = PaddedByteArray( ba, 0x40 ); QByteArray decDataPadded = PaddedByteArray( ba, 0x40 );
QByteArray encData = AesEncrypt( idx, decDataPadded ); QByteArray encData = AesEncrypt( t.BootIndex( idx ), decDataPadded );
partsEnc.replace( idx, encData ); partsEnc.replace( idx, encData );
return true; return true;