(CPZ5): another encryption scheme.

This commit is contained in:
morkt 2016-09-27 10:40:02 +04:00
parent a244509039
commit d0c5f958b9
3 changed files with 25 additions and 9 deletions

View File

@ -290,13 +290,7 @@ namespace GameRes.Formats.Purple
for (int i = 0; i < secret_length; ++i)
secret_key[i] = secret[i] - key;
uint shift = key;
shift = (shift >> 8) ^ key;
shift = (shift >> 8) ^ key;
shift = (shift >> 8) ^ key;
shift = (shift >> 8) ^ key;
shift = ((shift ^ 0xB) & 0xF) + 7;
int shift = (int)(((key >> 24) ^ (key >> 16) ^ (key >> 8) ^ key ^ 0xB) & 0xF) + 7;
unsafe
{
fixed (byte* raw = data)
@ -305,7 +299,7 @@ namespace GameRes.Formats.Purple
int i = 5;
for (int n = data.Length / 4; n > 0; --n)
{
*data32 = Binary.RotR ((secret_key[i] ^ *data32) + scheme.IndexAddend, (int)shift) + 0x01010101;
*data32 = Binary.RotR ((secret_key[i] ^ *data32) + scheme.IndexAddend, shift) + 0x01010101;
++data32;
i = (i + 1) % 24;
}

View File

@ -27,7 +27,7 @@ using GameRes.Utility;
namespace GameRes.Formats.Cmvs
{
public enum Md5Variant { A, B, Chrono }
public enum Md5Variant { A, B, Chrono, Memoria }
public abstract class MD5 : Cryptography.MD5Base
{
@ -43,6 +43,7 @@ namespace GameRes.Formats.Cmvs
case Md5Variant.A: return new Md5VariantA();
case Md5Variant.B: return new Md5VariantB();
case Md5Variant.Chrono: return new Md5Chrono();
case Md5Variant.Memoria: return new Md5Memoria();
default: throw new System.ArgumentException ("Unknown MD5 variant", "variant");
}
}
@ -111,4 +112,23 @@ namespace GameRes.Formats.Cmvs
data[3] = m_state[0] + 0x1D0638AD;
}
}
public class Md5Memoria : MD5
{
protected override void InitState ()
{
m_state[0] = 0xA79463F9;
m_state[1] = 0xB6E755C5;
m_state[2] = 0xC696AF21;
m_state[3] = 0x6983E978;
}
protected override void SetResult (uint[] data)
{
data[0] = m_state[1];
data[1] = m_state[2];
data[2] = m_state[3];
data[3] = m_state[0];
}
}
}

View File

@ -768,6 +768,7 @@ Favorite Sweet!<br/>
Nanapuri<br/>
Sabae no Ou Scenario II<br/>
Soushinjutsu 3<br/>
Temaribana<br/>
Wakan Kazoku<br/>
</td></tr>
<tr class="odd last"><td>*.spd</td><td><tt>SPDC</tt><br/><tt>SPD8</tt></td><td>No</td></tr>
@ -864,6 +865,7 @@ Gakuen Saimin Reido<br/>
Chrono Clock<br/>
Hapymaher<br/>
Haruiro Ouse<br/>
Memoria<br/>
</td></tr>
<tr class="last"><td>*.pb3</td><td><tt>PB3B</tt></td><td>No</td></tr>
<tr class="odd"><td>*.g2<br/>*.stx</td><td>-</td><td>No</td><td rowspan="2">GLib2</td><td rowspan="2">