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

EncryptBlock() private method

private EncryptBlock ( byte input, int inOff, byte outBytes, int outOff ) : void
input byte
inOff int
outBytes byte
outOff int
return void
        private void EncryptBlock(
            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 = 0; i <= 16; i += 4)
            {
                    x10 = RotateWordLeft(x10 + (x32 & ~x76) + (x54 & x76) + workingKey[i  ], 1);
                    x32 = RotateWordLeft(x32 + (x54 & ~x10) + (x76 & x10) + workingKey[i+1], 2);
                    x54 = RotateWordLeft(x54 + (x76 & ~x32) + (x10 & x32) + workingKey[i+2], 3);
                    x76 = RotateWordLeft(x76 + (x10 & ~x54) + (x32 & x54) + workingKey[i+3], 5);
            }

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

            for (int i = 20; i <= 40; i += 4)
            {
                    x10 = RotateWordLeft(x10 + (x32 & ~x76) + (x54 & x76) + workingKey[i  ], 1);
                    x32 = RotateWordLeft(x32 + (x54 & ~x10) + (x76 & x10) + workingKey[i+1], 2);
                    x54 = RotateWordLeft(x54 + (x76 & ~x32) + (x10 & x32) + workingKey[i+2], 3);
                    x76 = RotateWordLeft(x76 + (x10 & ~x54) + (x32 & x54) + workingKey[i+3], 5);
            }

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

            for (int i = 44; i < 64; i += 4)
            {
                    x10 = RotateWordLeft(x10 + (x32 & ~x76) + (x54 & x76) + workingKey[i  ], 1);
                    x32 = RotateWordLeft(x32 + (x54 & ~x10) + (x76 & x10) + workingKey[i+1], 2);
                    x54 = RotateWordLeft(x54 + (x76 & ~x32) + (x10 & x32) + workingKey[i+2], 3);
                    x76 = RotateWordLeft(x76 + (x10 & ~x54) + (x32 & x54) + workingKey[i+3], 5);
            }

            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);
        }