Ejemplo n.º 1
0
    public int DoFinal(byte[] output, int outOff)
    {
        int blockSize = cipher.GetBlockSize();

        if (padding == null)
        {
            while (bufOff < blockSize)
            {
                buf[bufOff++] = 0;
            }
        }
        else
        {
            if (bufOff == blockSize)
            {
                cipher.ProcessBlock(buf, 0, mac, 0);
                bufOff = 0;
            }
            padding.AddPadding(buf, bufOff);
        }
        cipher.ProcessBlock(buf, 0, mac, 0);
        DesEngine desEngine = new DesEngine();

        desEngine.Init(forEncryption: false, lastKey2);
        desEngine.ProcessBlock(mac, 0, mac, 0);
        desEngine.Init(forEncryption: true, lastKey3);
        desEngine.ProcessBlock(mac, 0, mac, 0);
        Array.Copy(mac, 0, output, outOff, macSize);
        Reset();
        return(macSize);
    }
Ejemplo n.º 2
0
        public int DoFinal(byte[] output, int outOff)
        {
            int blockSize = this.cipher.GetBlockSize();

            if (this.padding == null)
            {
                while (this.bufOff < blockSize)
                {
                    this.buf[this.bufOff++] = 0;
                }
            }
            else
            {
                if (this.bufOff == blockSize)
                {
                    this.cipher.ProcessBlock(this.buf, 0, this.mac, 0);
                    this.bufOff = 0;
                }
                this.padding.AddPadding(this.buf, this.bufOff);
            }
            this.cipher.ProcessBlock(this.buf, 0, this.mac, 0);
            DesEngine desEngine = new DesEngine();

            desEngine.Init(false, this.lastKey2);
            desEngine.ProcessBlock(this.mac, 0, this.mac, 0);
            desEngine.Init(true, this.lastKey3);
            desEngine.ProcessBlock(this.mac, 0, this.mac, 0);
            Array.Copy(this.mac, 0, output, outOff, this.macSize);
            this.Reset();
            return(this.macSize);
        }
Ejemplo n.º 3
0
            public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
            {
                if (inputBuffer == null)
                {
                    throw new ArgumentNullException("inputBuffer");
                }

                if (inputOffset < 0 || inputOffset > inputBuffer.Length)
                {
                    throw new ArgumentOutOfRangeException("inputOffset");
                }

                if (inputCount < 0 || inputOffset > inputBuffer.Length - inputCount)
                {
                    throw new ArgumentOutOfRangeException("inputCount");
                }

                if (inputCount != 8)
                {
                    throw new ArgumentOutOfRangeException("inputCount", "Can only transform 8 bytes at a time.");
                }

                if (outputBuffer == null)
                {
                    throw new ArgumentNullException("outputBuffer");
                }

                if (outputOffset < 0 || outputOffset > outputBuffer.Length - 8)
                {
                    throw new ArgumentOutOfRangeException("outputOffset");
                }

                return(engine.ProcessBlock(inputBuffer, inputOffset, outputBuffer, outputOffset));
            }
        public int DoFinal(
            byte[]  output,
            int outOff)
        {
            int blockSize = cipher.GetBlockSize();

            if (padding == null)
            {
                // pad with zeroes
                while (bufOff < blockSize)
                {
                    buf[bufOff++] = 0;
                }
            }
            else
            {
                if (bufOff == blockSize)
                {
                    cipher.ProcessBlock(buf, 0, mac, 0);
                    bufOff = 0;
                }

                padding.AddPadding(buf, bufOff);
            }

            cipher.ProcessBlock(buf, 0, mac, 0);

            // Added to code from base class
            DesEngine deseng = new DesEngine();

            deseng.Init(false, this.lastKey2);
            deseng.ProcessBlock(mac, 0, mac, 0);

            deseng.Init(true, this.lastKey3);
            deseng.ProcessBlock(mac, 0, mac, 0);
            // ****

            Array.Copy(mac, 0, output, outOff, macSize);

            Reset();

            return(macSize);
        }
Ejemplo n.º 5
0
        public void Read(BinaryReader reader)
        {
            var buff = reader.ReadBytes(30);

            for (var i = 0; i < 24; i += 8)
            {
                Decrypter.ProcessBlock(buff, i, buff, i);
            }

            UserName = Encoding.UTF8.GetString(buff, 0, FirstZeroIndex(buff, 0, 14));
            Password = Encoding.UTF8.GetString(buff, 14, FirstZeroIndex(buff, 14, 16));
            GameId   = reader.ReadUInt32();
            CDKey    = reader.ReadUInt16();
        }