diff --git a/ArcFormats/KiriKiri/CryptAlgorithms.cs b/ArcFormats/KiriKiri/CryptAlgorithms.cs index 0595a03a..e44b33e5 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -976,4 +976,49 @@ namespace GameRes.Formats.KiriKiri Decrypt (entry, offset, data, pos, count); } } + + [Serializable] + public class PuCaCrypt : ICrypt + { + public uint[] HashTable; + public byte[] KeyTable; + + public override void Decrypt (Xp3Entry entry, long offset, byte[] buffer, int pos, int count) + { + if (HashTable != null) + { + int i = Array.IndexOf (HashTable, entry.Hash); + if (i != -1) + { + for (int j = 0; j < count; ++j) + buffer[pos+j] ^= KeyTable[i]; + return; + } + } + var hash_table = new byte[32]; + uint hash = entry.Hash; + for (int k = 0; k < 32; k += 4) + { + if (0 != (hash & 1)) + hash |= 0x80000000; + else + hash &= 0x7FFFFFFF; + LittleEndian.Pack (hash, hash_table, k); + hash >>= 1; + } + var key_table = new byte[0x400]; + for (int l = 0; l < 32; ++l) + { + for (int m = 0; m < 32; ++m) + key_table[32 * l + m] = (byte)(~hash_table[l] ^ hash_table[m]); + } + for (int n = 0; n < count; ++n) + buffer[pos+n] ^= key_table[(offset + n) & 0x3FF]; + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] buffer, int pos, int count) + { + Decrypt (entry, offset, buffer, pos, count); + } + } } diff --git a/ArcFormats/Properties/AssemblyInfo.cs b/ArcFormats/Properties/AssemblyInfo.cs index 5e323133..cf3a425c 100644 --- a/ArcFormats/Properties/AssemblyInfo.cs +++ b/ArcFormats/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.2.33.1382")] -[assembly: AssemblyFileVersion ("1.2.33.1382")] +[assembly: AssemblyVersion ("1.2.33.1383")] +[assembly: AssemblyFileVersion ("1.2.33.1383")] diff --git a/ArcFormats/Resources/Formats.dat b/ArcFormats/Resources/Formats.dat index da4b60e3..5e921c67 100644 Binary files a/ArcFormats/Resources/Formats.dat and b/ArcFormats/Resources/Formats.dat differ diff --git a/docs/version.xml b/docs/version.xml index 7b4c81eb..76fbbe44 100644 --- a/docs/version.xml +++ b/docs/version.xml @@ -12,10 +12,10 @@ - 66 + 67 https://github.com/morkt/GARbro/raw/master/ArcFormats/Resources/Formats.dat - +