Skip to content

Commit

Permalink
omgkeyz
Browse files Browse the repository at this point in the history
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2447 8ced0084-cf51-0410-be5f-012b33b47a6e
  • Loading branch information
bushing committed Feb 26, 2009
1 parent 0f2a075 commit 6ff1645
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 89 deletions.
8 changes: 0 additions & 8 deletions Source/Core/Common/Src/Paths.h
Expand Up @@ -66,10 +66,6 @@
#define GC_MEMCARDA "MemoryCardA"
#define GC_MEMCARDB "MemoryCardB"

#define WII_MASTERKEY "masterkey.bin"
#define WII_MASTERKEY_HEX "masterkey.txt"
#define WII_MASTERKEY1 "masterkey1.bin"
#define WII_MASTERKEY1_HEX "masterkey1.txt"
#define WII_EUR_SETTING "setting-eur.txt"
#define WII_USA_SETTING "setting-usa.txt"
#define WII_JAP_SETTING "setting-jpn.txt"
Expand Down Expand Up @@ -125,10 +121,6 @@
#define DSP_ROM_FILE FULL_GC_SYS_DIR DSP_ROM
#define DSP_COEF_FILE FULL_GC_SYS_DIR DSP_COEF

#define WII_MASTERKEY_FILE FULL_WII_SYS_DIR WII_MASTERKEY
#define WII_MASTERKEY_FILE_HEX FULL_WII_SYS_DIR WII_MASTERKEY_HEX
#define WII_MASTERKEY1_FILE FULL_WII_SYS_DIR WII_MASTERKEY1
#define WII_MASTERKEY1_FILE_HEX FULL_WII_SYS_DIR WII_MASTERKEY1_HEX
#define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING
#define WII_USA_SETTING_FILE FULL_WII_SYS_DIR WII_USA_SETTING
#define WII_JAP_SETTING_FILE FULL_WII_SYS_DIR WII_JAP_SETTING
Expand Down
19 changes: 5 additions & 14 deletions Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp
Expand Up @@ -74,20 +74,11 @@ u8* CreateWADEntry(DiscIO::IBlobReader& _rReader, u32 _Size, u64 _Offset)

void GetKeyFromTicket(u8* pTicket, u8* pTicketKey)
{
u8 CommonKey[16];
FILE* pMasterKeyFile = fopen(WII_MASTERKEY_FILE, "rb");
_dbg_assert_msg_(BOOT, pMasterKeyFile!=0x0, "WiiWAD: Cant open MasterKeyFile for WII");

if (pMasterKeyFile)
{
fread(CommonKey, 16, 1, pMasterKeyFile);
fclose(pMasterKeyFile);

u8 IV[16];
memset(IV, 0, sizeof IV);
memcpy(IV, pTicket + 0x01dc, 8);
AESDecode(CommonKey, IV, pTicket + 0x01bf, 16, pTicketKey);
}
u8 CommonKey[16] = {0xeb,0xe4,0x2a,0x22,0x5e,0x85,0x93,0xe4,0x48,0xd9,0xc5,0x45,0x73,0x81,0xaa,0xf7};
u8 IV[16];
memset(IV, 0, sizeof IV);
memcpy(IV, pTicket + 0x01dc, 8);
AESDecode(CommonKey, IV, pTicket + 0x01bf, 16, pTicketKey);
}

bool ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u8* pTMD)
Expand Down
69 changes: 2 additions & 67 deletions Source/Core/DiscIO/Src/VolumeCreator.cpp
Expand Up @@ -62,9 +62,8 @@ class CBlobBigEndianReader
IBlobReader& m_rReader;
};

unsigned char g_MasterKey[16];
unsigned char g_MasterKeyK[16];
bool g_MasterKeyInit[] = {false, false};
const unsigned char g_MasterKey[16] = {0xeb,0xe4,0x2a,0x22,0x5e,0x85,0x93,0xe4,0x48,0xd9,0xc5,0x45,0x73,0x81,0xaa,0xf7};
const unsigned char g_MasterKeyK[16] = {0x63,0xb8,0x2b,0xb4,0xf4,0x61,0x4e,0x2e,0x13,0xf2,0xfe,0xfb,0xba,0x4c,0x9b,0x7e};

IVolume* CreateVolumeFromCryptedWiiImage(IBlobReader& _rReader, u32 _VolumeType, bool Korean);
EDiscType GetDiscType(IBlobReader& _rReader);
Expand Down Expand Up @@ -125,70 +124,6 @@ bool IsVolumeWiiDisc(const IVolume *_rVolume)

IVolume* CreateVolumeFromCryptedWiiImage(IBlobReader& _rReader, u32 _VolumeType, bool Korean)
{
if (!g_MasterKeyInit[Korean ? 1 : 0])
{
const char * MasterKeyFile = Korean ? WII_MASTERKEY1_FILE : WII_MASTERKEY_FILE;
const char * MasterKeyFileHex = Korean ? WII_MASTERKEY1_FILE_HEX : WII_MASTERKEY_FILE_HEX;

FILE* pT = fopen(MasterKeyFile, "rb");
if (pT == NULL)
{
if (PanicYesNo("Can't open '%s'.\n If you know the key, now it's the time to paste it into "
"'%s' before pressing [YES].", MasterKeyFile, MasterKeyFileHex))
{
pT = fopen(MasterKeyFileHex, "r");
if (!pT) {
PanicAlert("could not open %s", MasterKeyFileHex);
return NULL;
}

static char hexkey[32];
if (fread(hexkey, 1, 32, pT)<32)
{
PanicAlert("%s is not the right size", MasterKeyFileHex);
fclose(pT);
return NULL;
}
fclose(pT);

static char binkey[16];
char *t = hexkey;
for (int i = 0; i < 16; i++)
{
char h[3] = {*(t++), *(t++), 0};
binkey[i] = (char)strtol(h, NULL, 16);
}

pT = fopen(MasterKeyFile, "wb");
if (!pT) {
PanicAlert("could not open/make '%s' for writing!", MasterKeyFile);
return NULL;
}

fwrite(binkey, 16, 1, pT);
fclose(pT);

pT = fopen(MasterKeyFileHex, "rb");
if (!pT) {
PanicAlert("could not open '%s' for reading!\n did the file get deleted or locked after converting?", MasterKeyFileHex);
return NULL;
}
}
else
return NULL;
}

fread(Korean ? g_MasterKeyK : g_MasterKey, 16, 1, pT);
fclose(pT);
const u32 keyhash = 0x4bc30936;
const u32 keyhashK = 0x485c08e9;
u32 hash = HashAdler32(Korean ? g_MasterKeyK : g_MasterKey, 16);
if (hash != (Korean ? keyhashK : keyhash))
PanicAlert("Your Wii %sdisc decryption key is bad.", Korean ? "Korean " : "",keyhash, hash);
else
g_MasterKeyInit[Korean ? 1 : 0] = true;
}

CBlobBigEndianReader Reader(_rReader);

u32 numPartitions = Reader.Read32(0x40000);
Expand Down

0 comments on commit 6ff1645

Please sign in to comment.