예제 #1
0
        byte[] ProcessBlock(BinaryReader b, uint[] key, XTEAFunction xteaFunc, bool reuseMemory)
        {
            // Data is in big-endian
            //uint v0 = ToUInt(b.ReadBytes(4));
            //uint v1 = ToUInt(b.ReadBytes(4));
            b.Read(intBuffer, 0, 4);
            uint v0 = ToUInt(intBuffer);

            b.Read(intBuffer, 0, 4);
            uint v1 = ToUInt(intBuffer);

            uint[] result = xteaFunc(v0, v1, key, reuseMemory);

            // Output is in big-endian
            byte[] resultarr = memoryBuffer;
            if (!reuseMemory)
            {
                resultarr = new byte[8];
            }
            resultarr[0] = (byte)((result[0] >> 24));
            resultarr[1] = (byte)((result[0] >> 16));
            resultarr[2] = (byte)((result[0] >> 8));
            resultarr[3] = (byte)((result[0]));
            resultarr[4] = (byte)((result[1] >> 24));
            resultarr[5] = (byte)((result[1] >> 16));
            resultarr[6] = (byte)((result[1] >> 8));
            resultarr[7] = (byte)((result[1]));

            return(resultarr);
        }
예제 #2
0
        byte[] ProcessBlock(BinaryReader b, uint[] key, XTEAFunction xteaFunc, bool reuseMemory)
        {
            // Data is in big-endian
            //uint v0 = ToUInt(b.ReadBytes(4));
            //uint v1 = ToUInt(b.ReadBytes(4));
            b.Read(intBuffer, 0, 4);
            uint v0 = ToUInt(intBuffer);
            b.Read(intBuffer, 0, 4);
            uint v1 = ToUInt(intBuffer);

            uint[] result = xteaFunc(v0, v1, key, reuseMemory);

            // Output is in big-endian
            byte[] resultarr = memoryBuffer;
            if (!reuseMemory) {
                resultarr = new byte[8];
            }
            resultarr[0] = (byte)((result[0] >> 24));
            resultarr[1] = (byte)((result[0] >> 16));
            resultarr[2] = (byte)((result[0] >> 8));
            resultarr[3] = (byte)((result[0]));
            resultarr[4] = (byte)((result[1] >> 24));
            resultarr[5] = (byte)((result[1] >> 16));
            resultarr[6] = (byte)((result[1] >> 8));
            resultarr[7] = (byte)((result[1]));

            return resultarr;
        }
예제 #3
0
 public DatLoader()
 {
     // Init reusable delegates
     encFunc = new XTEAFunction(this.Encrypt);
     decFunc = new XTEAFunction(this.Decrypt);
 }
예제 #4
0
 public DatLoader()
 {
     // Init reusable delegates
     encFunc = new XTEAFunction(this.Encrypt);
     decFunc = new XTEAFunction(this.Decrypt);
 }