public byte[] getrifKey(string rifIn, string actIn, string idps) { if ((rifIn == null) || (actIn == null)) { return(null); } byte[] o = null; FileStream stream = File.Open(rifIn, FileMode.Open); byte[] buffer2 = new byte[0x10]; byte[] buffer3 = new byte[0x10]; byte[] buffer = new byte[0x10]; byte[] buffer5 = new byte[0x10]; stream.Seek(0x40L, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); stream.Read(buffer5, 0, buffer5.Length); stream.Close(); ToolsImpl.aesecbDecrypt(RIFKEY, buffer, 0, buffer2, 0, 0x10); long num = ConversionUtils.be32(buffer2, 12); if (num < 0x80L) { byte[] src = decryptACTDAT(actIn, idps); byte[] dest = new byte[0x10]; o = new byte[0x10]; ConversionUtils.arraycopy(src, ((int)num) * 0x10, dest, 0L, 0x10); ToolsImpl.aesecbDecrypt(dest, buffer5, 0, o, 0, 0x10); } return(o); }
public byte[] getrifKey(String rifIn, String actIn, String idps) { if (rifIn == null || actIn == null) { return(null); } byte[] result = null; FileStream rifFile = File.Open(rifIn, FileMode.Open); byte[] rif0x40 = new byte[0x10]; byte[] rif0x50 = new byte[0x10]; byte[] encrif0x40 = new byte[0x10]; byte[] encrif0x50 = new byte[0x10]; rifFile.Seek(0x40, SeekOrigin.Begin); rifFile.Read(encrif0x40, 0, encrif0x40.Length); rifFile.Read(encrif0x50, 0, encrif0x50.Length); rifFile.Close(); ToolsImpl.aesecbDecrypt(RIFKEY, encrif0x40, 0x00, rif0x40, 0, 0x10); long index = ConversionUtils.be32(rif0x40, 0xC); // if (index < 0x80) { byte[] actDat = decryptACTDAT(actIn, idps); byte[] datKey = new byte[0x10]; result = new byte[0x10]; ConversionUtils.arraycopy(actDat, (int)index * 16, datKey, 0, 0x10); ToolsImpl.aesecbDecrypt(datKey, encrif0x50, 0, result, 0, 0x10); } return(result); }
private static byte[] decryptACTDAT(string actIn, string IDPSFile) { FileStream stream = File.Open(actIn, FileMode.Open); byte[] buffer = new byte[0x800]; byte[] o = new byte[buffer.Length]; stream.Seek(0x10L, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); stream.Close(); ToolsImpl.aesecbDecrypt(getPerConsoleKey(IDPSFile), buffer, 0, o, 0, buffer.Length); return(o); }
private static byte[] decryptACTDAT(String actIn, String IDPSFile) { FileStream actFile = File.Open(actIn, FileMode.Open); byte[] actdat = new byte[0x800]; byte[] result = new byte[actdat.Length]; actFile.Seek(0x10, SeekOrigin.Begin); actFile.Read(actdat, 0, actdat.Length); actFile.Close(); byte[] key = getPerConsoleKey(IDPSFile); ToolsImpl.aesecbDecrypt(key, actdat, 0, result, 0, actdat.Length); return(result); }
public byte[] getKey(string rapFile) { BinaryReader reader = new BinaryReader(File.OpenRead(rapFile)); byte[] i = reader.ReadBytes(0x10); reader.Close(); byte[] o = new byte[i.Length]; ToolsImpl.aesecbDecrypt(rapKey, i, 0, o, 0, i.Length); for (int j = 0; j < 5; j++) { int num3; int index = 0; while (index < 0x10) { num3 = indexTable[index]; o[num3] = (byte)(o[num3] ^ key1[num3]); index++; } index = 15; while (index > 0) { int num4 = indexTable[index]; int num5 = indexTable[index - 1]; o[num4] = (byte)(o[num4] ^ o[num5]); index--; } int num6 = 0; for (index = 0; index < 0x10; index++) { num3 = indexTable[index]; byte num7 = (byte)(o[num3] - num6); o[num3] = num7; if ((num6 != 1) || (num7 != 0xff)) { int num8 = num7 & 0xff; int num9 = key2[num3] & 0xff; num6 = (num8 < num9) ? 1 : 0; } o[num3] = (byte)(num7 - key2[num3]); } } return(o); }
public byte[] getKey(String rapFile) { BinaryReader raf = new BinaryReader(File.OpenRead(rapFile)); byte[] read = raf.ReadBytes(0x10); raf.Close(); byte[] intermediate = new byte[read.Length]; ToolsImpl.aesecbDecrypt(rapKey, read, 0, intermediate, 0, read.Length); for (int loop = 0; loop < 5; loop++) { for (int loop2 = 0; loop2 < 0x10; loop2++) { int index = indexTable[loop2]; intermediate[index] = (byte)(intermediate[index] ^ key1[index]); } for (int loop2 = 0xF; loop2 > 0; loop2--) { int index1 = indexTable[loop2]; int index2 = indexTable[loop2 - 1]; intermediate[index1] = (byte)(intermediate[index1] ^ intermediate[index2]); } int acum = 0; for (int loop2 = 0; loop2 < 0x10; loop2++) { int index = indexTable[loop2]; byte current = (byte)(intermediate[index] - acum); intermediate[index] = current; if (acum != 1 || current != 0xFF) { int aux1 = current & 0xFF; int aux2 = key2[index] & 0xFF; acum = (aux1 < aux2) ? 1 : 0; } current = (byte)(current - key2[index]); intermediate[index] = current; } } return(intermediate); }