Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Added vWii and Korean common-key and Korea to TMD region
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Sep 22, 2019
1 parent 50dbada commit acf7117
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Mod of showmiiwads-mod
This is a modification of [showmiiwads-mod](https://code.google.com/archive/p/showmiiwads-mod/) by orwel. The original was coded by [Leathl](https://code.google.com/archive/p/showmiiwads/).

## Changelog
### v1.5.2
* Backport my [libWiiSharp fixes](https://github.com/WiiDatabase/libWiiSharp/releases/tag/v0.31):
* Added vWii Common-Key: Decrypting and encrypting vWii titles is supported now (last one is untested)
* Added Korean Common-Key
* Add Korea to TMD region

### v1.5.1
Important fixes to the WAD building process from NAND dumps:
* Tickets are not faked with the "beer ticket" anymore
Expand Down
3 changes: 2 additions & 1 deletion ShowMiiWads/ShowMiiWads.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.5.1.%2a</ApplicationVersion>
<ApplicationVersion>1.5.2.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand All @@ -43,6 +43,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion ShowMiiWads/ShowMiiWads_Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace ShowMiiWads
public partial class ShowMiiWads_Main : Form
{
//Define global variables
public const string version = "1.5.1";
public const string version = "1.5.2";
private string language = "English";
private string langfile = "";
private string oldlang = "";
Expand Down
20 changes: 18 additions & 2 deletions ShowMiiWads/Wii.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,8 @@ public static byte[] GetTitleKey(byte[] wadtik)

byte[] encryptedkey = new byte[16];
byte[] iv = new byte[16];
byte[] ckey;
byte ckeyindex;
int tikpos = 0;

if (IsThisWad(wadtik) == true)
Expand All @@ -1345,13 +1347,27 @@ public static byte[] GetTitleKey(byte[] wadtik)
iv[j + 8] = 0x00;
}

ckeyindex = wadtik[tikpos + 0x1f1];

switch (ckeyindex)
{
default:
ckey = libWiiSharp.CommonKey.GetStandardKey();
break;
case 0x01:
ckey = libWiiSharp.CommonKey.GetKoreanKey();
break;
case 0x02:
ckey = libWiiSharp.CommonKey.GetvWiiKey();
break;
}

RijndaelManaged decrypt = new RijndaelManaged();
decrypt.Mode = CipherMode.CBC;
decrypt.Padding = PaddingMode.None;
decrypt.KeySize = 128;
decrypt.BlockSize = 128;
//decrypt.Key = commonkey;
decrypt.Key = libWiiSharp.CommonKey.GetStandardKey();
decrypt.Key = ckey;
decrypt.IV = iv;

ICryptoTransform cryptor = decrypt.CreateDecryptor();
Expand Down
6 changes: 6 additions & 0 deletions libWiiSharp/CommonKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class CommonKey
{
private static string standardKey = "ebe42a225e8593e448d9c5457381aaf7";
private static string koreanKey = "63b82bb4f4614e2e13f2fefbba4c9b7e";
private static string vwiiKey = "30bfc76e7c19afbb23163330ced7c28d";

public static byte[] GetStandardKey()
{
Expand All @@ -31,5 +32,10 @@ public static byte[] GetKoreanKey()
{
return Shared.HexStringToByteArray(koreanKey);
}

public static byte[] GetvWiiKey()
{
return Shared.HexStringToByteArray(vwiiKey);
}
}
}
1 change: 1 addition & 0 deletions libWiiSharp/TMD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum Region : ushort
USA = 1,
Europe = 2,
Free = 3,
Korea = 4,
}

public class TMD : IDisposable
Expand Down
29 changes: 27 additions & 2 deletions libWiiSharp/Ticket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum CommonKeyType : byte
{
Standard = 0x00,
Korean = 0x01,
vWii = 0x02,
}

public class Ticket : IDisposable
Expand Down Expand Up @@ -532,7 +533,19 @@ private void parseTicket(Stream ticketFile)

private void decryptTitleKey()
{
byte[] ckey = (commonKeyIndex == 0x01) ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey();
byte[] ckey;
switch (commonKeyIndex)
{
default:
ckey = CommonKey.GetStandardKey();
break;
case 0x01:
ckey = CommonKey.GetKoreanKey();
break;
case 0x02:
ckey = CommonKey.GetvWiiKey();
break;
}
byte[] iv = BitConverter.GetBytes(Shared.Swap(titleId));
Array.Resize(ref iv, 16);

Expand Down Expand Up @@ -560,7 +573,19 @@ private void decryptTitleKey()
private void encryptTitleKey()
{
commonKeyIndex = newKeyIndex;
byte[] ckey = (commonKeyIndex == 0x01) ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey();
byte[] ckey = CommonKey.GetStandardKey();
switch (commonKeyIndex)
{
default:
ckey = CommonKey.GetStandardKey();
break;
case 0x01:
ckey = CommonKey.GetKoreanKey();
break;
case 0x02:
ckey = CommonKey.GetvWiiKey();
break;
}
byte[] iv = BitConverter.GetBytes(Shared.Swap(titleId));
Array.Resize(ref iv, 16);

Expand Down

0 comments on commit acf7117

Please sign in to comment.