Org.BouncyCastle.Crypto.Engines.RC2Engine.DecryptBlock C# (CSharp) Method

DecryptBlock() private method

private DecryptBlock ( byte input, int inOff, byte outBytes, int outOff ) : void
input byte
inOff int
outBytes byte
outOff int
return void
        private void DecryptBlock(
            byte[]  input,
            int     inOff,
            byte[]  outBytes,
            int     outOff)
        {
            int x76, x54, x32, x10;

            x76 = ((input[inOff + 7] & 0xff) << 8) + (input[inOff + 6] & 0xff);
            x54 = ((input[inOff + 5] & 0xff) << 8) + (input[inOff + 4] & 0xff);
            x32 = ((input[inOff + 3] & 0xff) << 8) + (input[inOff + 2] & 0xff);
            x10 = ((input[inOff + 1] & 0xff) << 8) + (input[inOff + 0] & 0xff);

            for (int i = 60; i >= 44; i -= 4)
            {
                x76 = RotateWordLeft(x76, 11) - ((x10 & ~x54) + (x32 & x54) + workingKey[i+3]);
                x54 = RotateWordLeft(x54, 13) - ((x76 & ~x32) + (x10 & x32) + workingKey[i+2]);
                x32 = RotateWordLeft(x32, 14) - ((x54 & ~x10) + (x76 & x10) + workingKey[i+1]);
                x10 = RotateWordLeft(x10, 15) - ((x32 & ~x76) + (x54 & x76) + workingKey[i  ]);
            }

            x76 -= workingKey[x54 & 63];
            x54 -= workingKey[x32 & 63];
            x32 -= workingKey[x10 & 63];
            x10 -= workingKey[x76 & 63];

            for (int i = 40; i >= 20; i -= 4)
            {
                x76 = RotateWordLeft(x76, 11) - ((x10 & ~x54) + (x32 & x54) + workingKey[i+3]);
                x54 = RotateWordLeft(x54, 13) - ((x76 & ~x32) + (x10 & x32) + workingKey[i+2]);
                x32 = RotateWordLeft(x32, 14) - ((x54 & ~x10) + (x76 & x10) + workingKey[i+1]);
                x10 = RotateWordLeft(x10, 15) - ((x32 & ~x76) + (x54 & x76) + workingKey[i  ]);
            }

            x76 -= workingKey[x54 & 63];
            x54 -= workingKey[x32 & 63];
            x32 -= workingKey[x10 & 63];
            x10 -= workingKey[x76 & 63];

            for (int i = 16; i >= 0; i -= 4)
            {
                x76 = RotateWordLeft(x76, 11) - ((x10 & ~x54) + (x32 & x54) + workingKey[i+3]);
                x54 = RotateWordLeft(x54, 13) - ((x76 & ~x32) + (x10 & x32) + workingKey[i+2]);
                x32 = RotateWordLeft(x32, 14) - ((x54 & ~x10) + (x76 & x10) + workingKey[i+1]);
                x10 = RotateWordLeft(x10, 15) - ((x32 & ~x76) + (x54 & x76) + workingKey[i  ]);
            }

            outBytes[outOff + 0] = (byte)x10;
            outBytes[outOff + 1] = (byte)(x10 >> 8);
            outBytes[outOff + 2] = (byte)x32;
            outBytes[outOff + 3] = (byte)(x32 >> 8);
            outBytes[outOff + 4] = (byte)x54;
            outBytes[outOff + 5] = (byte)(x54 >> 8);
            outBytes[outOff + 6] = (byte)x76;
            outBytes[outOff + 7] = (byte)(x76 >> 8);
        }
    }