Org.BouncyCastle.Crypto.Engines.RC6Engine.EncryptBlock C# (CSharp) Метод

EncryptBlock() приватный Метод

private EncryptBlock ( byte input, int inOff, byte outBytes, int outOff ) : int
input byte
inOff int
outBytes byte
outOff int
Результат int
        private int EncryptBlock(
            byte[]  input,
            int     inOff,
            byte[]  outBytes,
            int     outOff)
        {
            // load A,B,C and D registers from in.
            int A = BytesToWord(input, inOff);
            int B = BytesToWord(input, inOff + bytesPerWord);
            int C = BytesToWord(input, inOff + bytesPerWord*2);
            int D = BytesToWord(input, inOff + bytesPerWord*3);

            // Do pseudo-round #0: pre-whitening of B and D
            B += _S[0];
            D += _S[1];

            // perform round #1,#2 ... #ROUNDS of encryption
            for (int i = 1; i <= _noRounds; i++)
            {
                int t = 0,u = 0;

                t = B*(2*B+1);
                t = RotateLeft(t,5);

                u = D*(2*D+1);
                u = RotateLeft(u,5);

                A ^= t;
                A = RotateLeft(A,u);
                A += _S[2*i];

                C ^= u;
                C = RotateLeft(C,t);
                C += _S[2*i+1];

                int temp = A;
                A = B;
                B = C;
                C = D;
                D = temp;
            }
            // do pseudo-round #(ROUNDS+1) : post-whitening of A and C
            A += _S[2*_noRounds+2];
            C += _S[2*_noRounds+3];

            // store A, B, C and D registers to out
            WordToBytes(A, outBytes, outOff);
            WordToBytes(B, outBytes, outOff + bytesPerWord);
            WordToBytes(C, outBytes, outOff + bytesPerWord*2);
            WordToBytes(D, outBytes, outOff + bytesPerWord*3);

            return 4 * bytesPerWord;
        }