public void TestSha1() { var Kirk = new Kirk(); Kirk.kirk_init(); var Input = new byte[] { // Size 0x20, 0x00, 0x00, 0x00, // Data 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; var ExpectedOutput = new byte[] { 0xDE, 0x8A, 0x84, 0x7B, 0xFF, 0x8C, 0x34, 0x3D, 0x69, 0xB8, 0x53, 0xA2, 0x15, 0xE6, 0xEE, 0x77, 0x5E, 0xF2, 0xEF, 0x96 }; var Output = new byte[0x14]; Assert.Equal(0x24, Input.Length); fixed(byte *OutputPtr = Output) fixed(byte *InputPtr = Input) { Kirk.KirkSha1(OutputPtr, InputPtr, Input.Length); } Assert.Equal(ExpectedOutput, Output); //Console.WriteLine(BitConverter.ToString(Hash)); }
public void TestCmd7() { var Kirk = new Kirk(); Kirk.kirk_init(); var _src = new byte[0x20 + 0x14]; var _dst = new byte[0x20]; var ExpectedOutput = new byte[] { 0xE4, 0x8B, 0x57, 0x4C, 0x6E, 0xAF, 0x62, 0x51, 0x5C, 0x44, 0x52, 0x1D, 0xBA, 0x7D, 0xD4, 0x32, 0xE4, 0x8B, 0x57, 0x4C, 0x6E, 0xAF, 0x62, 0x51, 0x5C, 0x44, 0x52, 0x1D, 0xBA, 0x7D, 0xD4, 0x32 }; fixed(byte *src = _src) fixed(byte *dst = _dst) { *(uint *)(&src[0x00]) = 5; // Mode *(uint *)(&src[0x0C]) = 0x03; // KeySeed *(uint *)(&src[0x10]) = 1; // DataSize Kirk.kirk_CMD7(dst, src, 0x20); Console.WriteLine("_src: {0}", BitConverter.ToString(_src)); Console.WriteLine("_dst: {0}", BitConverter.ToString(_dst)); Assert.Equal(ExpectedOutput, _dst); } }
public void TestCmd1() { var Kirk = new Kirk(); Kirk.kirk_init(); var _src = new byte[0x100]; var _dst = new byte[0x10]; var ExpectedOutput = new byte[] { 0xE3, 0x17, 0x49, 0x84, 0xAE, 0xB9, 0xB5, 0xAF, 0x7D, 0x9F, 0x73, 0xAD, 0x93, 0x66, 0x62, 0xD5 }; fixed(byte *src = _src) fixed(byte *dst = _dst) { *(uint *)(&src[0x60]) = 1; // Mode *(uint *)(&src[0x70]) = 0x10; // DataSize *(uint *)(&src[0x74]) = 0; // DataOffset Kirk.kirk_CMD1(dst, src, 0x100, false); //Console.WriteLine(BitConverter.ToString(_src)); //Console.WriteLine(BitConverter.ToString(_dst)); Assert.Equal(ExpectedOutput, _dst); } }
/// <summary> /// /// </summary> /// <param name="pbIn"></param> /// <param name="showInfo"></param> public byte[] Decrypt(byte[] pbIn, bool showInfo = false) { _kirk = new Kirk(); _kirk.kirk_init(); return(DecryptPrx(pbIn, showInfo)); }
/// <summary> /// /// </summary> /// <param name="iplData"></param> /// <param name="outputStream"></param> /// <param name="toMemoryAddress"></param> /// <returns></returns> public static IplInfo DecryptIplToMemory(byte[] iplData, Stream outputStream, bool toMemoryAddress = true) { var buffer = new byte[0x1000]; var iplInfo = default(IplInfo); //ArrayUtils.HexDump(IplData); fixed(byte *iplPtr = iplData) fixed(byte *bufferPtr = buffer) { for (var n = 0; n < iplData.Length; n += 0x1000) { var ptr = iplPtr + n; var header = *(Kirk.Aes128CmacHeader *)ptr; //Console.WriteLine(Header.DataSize); var kirk = new Kirk(); kirk.kirk_init(); kirk.kirk_CMD1(bufferPtr, ptr, 0x1000, doCheck: false); var iplBlock = *(IplBlock *)bufferPtr; //Console.WriteLine(IplBlock.ToStringDefault()); if (toMemoryAddress) { outputStream.Position = iplBlock.LoadAddress; Console.WriteLine("IplBlock.LoadAddress: 0x{0:X8}", iplBlock.LoadAddress); } outputStream.WriteBytes(PointerUtils.PointerToByteArray(&iplBlock.BlockData, (int)iplBlock.BlockSize)); if (iplBlock.EntryFunction != 0) { iplInfo.EntryFunction = iplBlock.EntryFunction; } } } return(iplInfo); }
public LleKirk(DebugPspMemory memory) { this.Memory = memory; Kirk = new Kirk(); Kirk.kirk_init(); }