mirror of
https://github.com/martravi/wiiqt.git
synced 2024-11-22 09:09:18 +01:00
* remember the ticket decrypted key and dont calculate it every time it is requested
This commit is contained in:
parent
30f8070e81
commit
374699c434
@ -214,6 +214,23 @@ Ticket::Ticket( QByteArray stuff )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SetPointer();
|
SetPointer();
|
||||||
|
|
||||||
|
quint8 iv[ 16 ];
|
||||||
|
quint8 keyin[ 16 ];
|
||||||
|
quint8 keyout[ 16 ];
|
||||||
|
quint8 commonkey[ 16 ] = COMMON_KEY;
|
||||||
|
|
||||||
|
quint8 *enc_key = (quint8 *)&p_tik->cipher_title_key;
|
||||||
|
memcpy( keyin, enc_key, sizeof keyin );
|
||||||
|
memset( keyout, 0, sizeof keyout );
|
||||||
|
memset( iv, 0, sizeof iv);
|
||||||
|
memcpy( iv, &p_tik->titleid, sizeof p_tik->titleid );
|
||||||
|
|
||||||
|
aes_set_key( commonkey );
|
||||||
|
aes_decrypt( iv, keyin, keyout, sizeof( keyin ) );
|
||||||
|
|
||||||
|
decKey = QByteArray( (const char*)&keyout, 16 );
|
||||||
|
|
||||||
if( (quint32)data.size() != SignedSize() )
|
if( (quint32)data.size() != SignedSize() )
|
||||||
{
|
{
|
||||||
data.resize( SignedSize() );
|
data.resize( SignedSize() );
|
||||||
@ -232,29 +249,17 @@ bool Ticket::SetTid( quint64 tid )
|
|||||||
{
|
{
|
||||||
if( !p_tik )
|
if( !p_tik )
|
||||||
return false;
|
return false;
|
||||||
|
//hexdump( data, payLoadOffset, data.size() - payLoadOffset );
|
||||||
|
|
||||||
p_tik->titleid = qFromBigEndian( tid );
|
quint64 t = qFromBigEndian( tid );
|
||||||
|
p_tik->titleid = t;
|
||||||
|
//hexdump( data, payLoadOffset, data.size() - payLoadOffset );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Ticket::DecryptedKey()
|
QByteArray Ticket::DecryptedKey()
|
||||||
{
|
{
|
||||||
quint8 iv[ 16 ];
|
return decKey;
|
||||||
quint8 keyin[ 16 ];
|
|
||||||
quint8 keyout[ 16 ];
|
|
||||||
static quint8 commonkey[ 16 ] = COMMON_KEY;
|
|
||||||
|
|
||||||
quint8 *enc_key = (quint8 *)&p_tik->cipher_title_key;
|
|
||||||
memcpy( keyin, enc_key, sizeof keyin );
|
|
||||||
memset( keyout, 0, sizeof keyout );
|
|
||||||
memset( iv, 0, sizeof iv);
|
|
||||||
memcpy( iv, &p_tik->titleid, sizeof p_tik->titleid );
|
|
||||||
|
|
||||||
aes_set_key( commonkey );
|
|
||||||
aes_decrypt( iv, keyin, keyout, sizeof( keyin ) );
|
|
||||||
|
|
||||||
return QByteArray( (const char*)&keyout, 16 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 Ticket::SignedSize()
|
quint32 Ticket::SignedSize()
|
||||||
@ -274,7 +279,7 @@ void Ticket::SetPointer()
|
|||||||
else if( data.startsWith( "\x0\x1\x0\x2" ) )
|
else if( data.startsWith( "\x0\x1\x0\x2" ) )
|
||||||
payLoadOffset = sizeof( sig_ecdsa );
|
payLoadOffset = sizeof( sig_ecdsa );
|
||||||
|
|
||||||
p_tik = (tik*)((quint8*)data.data() + payLoadOffset);
|
p_tik = (tik*)((quint8*)(data.data()) + payLoadOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ticket::FakeSign()
|
bool Ticket::FakeSign()
|
||||||
|
@ -160,6 +160,7 @@ private:
|
|||||||
|
|
||||||
//let data hold the entire tik data
|
//let data hold the entire tik data
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
|
QByteArray decKey;
|
||||||
|
|
||||||
//point the p_tik to the spot in "data" we want
|
//point the p_tik to the spot in "data" we want
|
||||||
void SetPointer();
|
void SetPointer();
|
||||||
|
@ -94,7 +94,8 @@ QByteArray PaddedByteArray( const QByteArray &orig, quint32 padTo )
|
|||||||
|
|
||||||
QByteArray AesDecrypt( quint16 index, const QByteArray source )
|
QByteArray AesDecrypt( quint16 index, const QByteArray source )
|
||||||
{
|
{
|
||||||
static quint8 iv[ 16 ];
|
//qDebug() << "AesDecrypt" << hex << index << source.size();
|
||||||
|
quint8 iv[ 16 ];
|
||||||
|
|
||||||
quint16 beidx = qFromBigEndian( index );
|
quint16 beidx = qFromBigEndian( index );
|
||||||
memset( iv, 0, 16 );
|
memset( iv, 0, 16 );
|
||||||
@ -118,6 +119,7 @@ QByteArray AesEncrypt( quint16 index, const QByteArray source )
|
|||||||
|
|
||||||
void AesSetKey( const QByteArray key )
|
void AesSetKey( const QByteArray key )
|
||||||
{
|
{
|
||||||
|
// qDebug() << "AesSetKey()" << key.toHex();
|
||||||
aes_set_key( (const quint8*)key.data() );
|
aes_set_key( (const quint8*)key.data() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ bool MainWindow::InstallNUSItem( NusJob job )
|
|||||||
{
|
{
|
||||||
//nand.WriteMetaData();
|
//nand.WriteMetaData();
|
||||||
UpdateTree();
|
UpdateTree();
|
||||||
ShowMessage( tr( "Deleted old TMD and private contents for\n%1" ).arg( title ) );
|
ShowMessage( tr( "Deleted old TMD and private contents for<br>%1" ).arg( title ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = t.Count();
|
cnt = t.Count();
|
||||||
|
Loading…
Reference in New Issue
Block a user