mirror of
https://github.com/martravi/wiiqt6.git
synced 2024-11-22 05:29:14 +01:00
* add a few more things to get from keys.bin
* remove some junk left over from testing git-svn-id: http://wiiqt.googlecode.com/svn/trunk@44 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
parent
adebd42830
commit
3f1f5654ad
@ -429,23 +429,14 @@ void make_ec_cert( quint8 *cert, quint8 *sig, char *signer, char *name, quint8 *
|
||||
{
|
||||
//qDebug() << "make_ec_cert";
|
||||
memset( cert, 0, 0x180 );
|
||||
//qDebug() << "1";
|
||||
quint32 tmp = qFromBigEndian( (quint32)0x10002 );
|
||||
memcpy( (char*)cert, (const void*)&tmp, 4 );
|
||||
//qDebug() << "2";
|
||||
memcpy( cert + 4, sig, 60 );
|
||||
//qDebug() << "3";
|
||||
strcpy( (char*)cert + 0x80, signer );
|
||||
//qDebug() << "4";
|
||||
tmp = qFromBigEndian( (quint32)2 );
|
||||
memcpy( (char*)cert + 0xc0, (const void*)&tmp, 4 );
|
||||
//qDebug() << "5";
|
||||
//wbe32( cert + 0xc0, 2 );
|
||||
strcpy( (char*)cert + 0xc4, name );
|
||||
//qDebug() << "6";
|
||||
tmp = qFromBigEndian( key_id );
|
||||
memcpy( (char*)cert + 0x104, (const void*)&tmp, 4 );
|
||||
//qDebug() << "7";
|
||||
//wbe32( cert + 0x104, key_id );
|
||||
ec_priv_to_pub( priv, cert + 0x108 );
|
||||
}
|
||||
|
@ -50,3 +50,38 @@ const QByteArray KeysBin::HMac()
|
||||
return QByteArray();
|
||||
return data.mid( 0x144, 0x14 );
|
||||
}
|
||||
|
||||
const QByteArray KeysBin::Boot1Hash()
|
||||
{
|
||||
if( data.size() != 0x400 )
|
||||
return QByteArray();
|
||||
return data.mid( 0x100, 0x14 );
|
||||
}
|
||||
|
||||
const QByteArray KeysBin::CommonKey()
|
||||
{
|
||||
if( data.size() != 0x400 )
|
||||
return QByteArray();
|
||||
return data.mid( 0x114, 0x10 );
|
||||
}
|
||||
|
||||
const QByteArray KeysBin::RngKey()
|
||||
{
|
||||
if( data.size() != 0x400 )
|
||||
return QByteArray();
|
||||
return data.mid( 0x168, 0x10 );
|
||||
}
|
||||
|
||||
const QByteArray KeysBin::Otp()
|
||||
{
|
||||
if( data.size() != 0x400 )
|
||||
return QByteArray();
|
||||
return data.mid( 0x100, 0x80 );
|
||||
}
|
||||
|
||||
const QByteArray KeysBin::Seeprom()
|
||||
{
|
||||
if( data.size() != 0x400 )
|
||||
return QByteArray();
|
||||
return data.mid( 0x200, 0x100 );
|
||||
}
|
||||
|
@ -4,12 +4,17 @@
|
||||
#include "includes.h"
|
||||
|
||||
//quick class for grabbing some stuff from a keys.bin from bootmii ( should be 0x400 bytes )
|
||||
// TODO - this isnt complete at all
|
||||
class KeysBin
|
||||
{
|
||||
public:
|
||||
KeysBin( QByteArray stuff = QByteArray() );
|
||||
|
||||
const QByteArray Otp();
|
||||
const QByteArray Seeprom();
|
||||
|
||||
const QByteArray Boot1Hash();
|
||||
const QByteArray CommonKey();
|
||||
const QByteArray RngKey();
|
||||
const QByteArray NG_ID();
|
||||
const QByteArray NG_key_ID();
|
||||
const QByteArray NG_Sig();
|
||||
|
@ -16,7 +16,9 @@ NandBin::~NandBin()
|
||||
{
|
||||
if( f.isOpen() )
|
||||
{
|
||||
#ifdef NAND_BIN_CAN_WRITE
|
||||
f.flush();
|
||||
#endif
|
||||
f.close();
|
||||
}
|
||||
|
||||
@ -382,17 +384,6 @@ bool NandBin::InitNand( const QIcon &dirs, const QIcon &files )
|
||||
|
||||
root = new QTreeWidgetItem( QStringList() << nandPath );
|
||||
AddChildren( root, 0 );
|
||||
/*#ifdef NAND_BIN_CAN_WRITE
|
||||
CreateEntry( "/testDir", 0, 0, NAND_DIR, NAND_RW, NAND_RW, NAND_RW );
|
||||
quint16 pp = CreateEntry( "/testDir/testFile", 0, 0, NAND_FILE, NAND_RW, NAND_RW, NAND_RW );
|
||||
qDebug() << "created entry" << pp;
|
||||
Delete( "/testDir/testFile" );
|
||||
pp = CreateEntry( "/testDir/testFile", 0, 0, NAND_FILE, NAND_RW, NAND_RW, NAND_RW );
|
||||
qDebug() << "created entry" << pp;
|
||||
SetData( pp, QByteArray( 0x10000, '\x0' ) );
|
||||
|
||||
WriteMetaData();
|
||||
#endif*/
|
||||
|
||||
//checkout the blocks for boot1&2
|
||||
QList<QByteArray>blocks;
|
||||
@ -1069,13 +1060,11 @@ bool NandBin::WriteDecryptedCluster( quint32 pageNo, const QByteArray &data, fst
|
||||
|
||||
bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
|
||||
{
|
||||
//return true;
|
||||
#ifndef NAND_BIN_CAN_WRITE
|
||||
qWarning() << __FILE__ << "was built without write support";
|
||||
return false;
|
||||
#endif
|
||||
//qDebug() << "NandBin::WritePage(" << hex << pageNo << ")";
|
||||
//return true;
|
||||
quint32 n_pagelen[] = { 0x800, 0x840, 0x840 };
|
||||
if( (quint32)data.size() != n_pagelen[ type ] )
|
||||
{
|
||||
@ -1091,7 +1080,7 @@ bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
|
||||
f.seek( (quint64)pageNo * (quint64)n_pagelen[ type ] ); //seek to the beginning of the page to write
|
||||
//qDebug() << "writing page at:" << f.pos() << hex << (quint32)f.pos();
|
||||
//hexdump( data, 0, 0x20 );
|
||||
return f.write( data );
|
||||
return ( f.write( data ) == data.size() );
|
||||
}
|
||||
|
||||
quint16 NandBin::CreateNode( const QString &name, quint32 uid, quint16 gid, quint8 attr, quint8 user_perm, quint8 group_perm, quint8 other_perm )
|
||||
@ -1412,11 +1401,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
||||
//grab a random cluster from the list
|
||||
quint16 idx = qrand() % freeClusters.size();
|
||||
quint16 cl = freeClusters.takeAt( idx ); //remove this number from the list
|
||||
/*if( freeClusters.contains( cl ) )
|
||||
{
|
||||
qDebug() << "wtf4";
|
||||
return false;
|
||||
}*/
|
||||
|
||||
fts << cl; //add this one to the clusters that will be used to hold the data
|
||||
quint16 block = cl / 8; //try to find other clusters in the same block
|
||||
for( quint16 i = block * 8; i < ( ( block + 1 ) * 8 ) && fts.size() < clCnt; i++ )
|
||||
@ -1428,11 +1413,6 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
||||
{
|
||||
fts << i;
|
||||
freeClusters.removeAt( freeClusters.indexOf( i, 0 ) );
|
||||
/*if( freeClusters.contains( i ) )
|
||||
{
|
||||
qDebug() << "wtf5";
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
//read the spare data to see that the cluster is good - removed for now. but its probably not a bad idea to do this
|
||||
@ -1464,74 +1444,22 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
||||
//all the data has been written, now make sure the fats are correct
|
||||
fsts[ idx ].sub = fts.at( 0 );
|
||||
|
||||
/*QList<quint16>bugFix = fts;
|
||||
for( quint16 i = 0; i < fts.size(); i++ )
|
||||
{
|
||||
if( bugFix.at( i ) != fts.at( i ) )
|
||||
{
|
||||
qDebug() << "wwwwtttf?" << i << hex << bugFix.at( i ) << fts.at( i );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
quint16 te = fsts[ idx ].sub;*/
|
||||
|
||||
for( quint16 i = 0; i < clCnt - 1; i++ )
|
||||
{
|
||||
fats.replace( fts.at( 0 ), fts.at( 1 ) );
|
||||
/*qDebug() << "replacing fat" << hex << fts.at( 0 ) << "to point to" << fts.at( 1 ) << "actual:" << fats.at( fts.at( 0 ) );
|
||||
if( te != fts.at( 0 ) || te != bugFix.at( i ) )
|
||||
{
|
||||
qDebug() << "failed" << i << hex << te << fts.at( 0 ) << bugFix.at( i );
|
||||
return false;
|
||||
}*/
|
||||
fts.takeFirst();
|
||||
//te = GetFAT( te );
|
||||
}
|
||||
//follow the fat chain and make sure it is as expected
|
||||
/*quint16 num = 0;
|
||||
te = fsts[ idx ].sub;
|
||||
while( te < 0xfff0 )
|
||||
{
|
||||
if( te != bugFix.at( num ) )
|
||||
{
|
||||
qDebug() << "mismatch" << num << hex << te << bugFix.at( num );
|
||||
break;
|
||||
}
|
||||
te = GetFAT( te );
|
||||
num++;
|
||||
}*/
|
||||
|
||||
//qDebug() << "1 followed the chain to" << num << "items. expected" << clCnt;
|
||||
//qDebug() << "loop is done";
|
||||
fats.replace( fts.at( 0 ), 0xfffb );//last cluster in chain
|
||||
fts.takeFirst();
|
||||
//qDebug() << "fixed the last one" << hex << fts;
|
||||
// if the new data uses less clusters than the previous data, mark the extra ones as free
|
||||
//if( !fts.isEmpty() )
|
||||
//qDebug() << "need to mark" << fts.size() << "clusters free";
|
||||
|
||||
while( !fts.isEmpty() )
|
||||
{
|
||||
fats.replace( fts.at( 0 ), 0xfffe );
|
||||
fts.takeFirst();
|
||||
}
|
||||
//qDebug() << "2nd loop is done";
|
||||
|
||||
//follow the fat chain and make sure it is as expected
|
||||
/*num = 0;
|
||||
te = fsts[ idx ].sub;
|
||||
while( te < 0xfff0 )
|
||||
{
|
||||
if( te != bugFix.at( num ) )
|
||||
{
|
||||
qDebug() << "mismatch" << num << hex << te << bugFix.at( num );
|
||||
break;
|
||||
}
|
||||
te = GetFAT( te );
|
||||
num++;
|
||||
}
|
||||
|
||||
qDebug() << "2 followed the chain to" << num << "items. expected" << clCnt;*/
|
||||
|
||||
fsts[ idx ].size = data.size();
|
||||
|
||||
@ -1543,7 +1471,6 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
||||
}
|
||||
|
||||
i->setText( 2, QString( "%1" ).arg( data.size(), 0, 16 ) );
|
||||
//f.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,8 @@ macx{
|
||||
message("mac build")
|
||||
LIBS += -L./quazip/lib/mac -lquazip
|
||||
}
|
||||
else unix {
|
||||
else {
|
||||
unix {
|
||||
!contains(QMAKE_HOST.arch, x86_64) {
|
||||
message("x86 build")
|
||||
LIBS += -L./quazip/lib/linux_x86 -lquazip
|
||||
@ -85,4 +86,5 @@ else unix {
|
||||
LIBS += -L./quazip/lib/linux_x64 -lquazip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user