CSharpRTMP.Core.Protocols.Rtmfp.AESEngine.Decrypt16Byte C# (CSharp) Method

Decrypt16Byte() private method

private Decrypt16Byte ( BufferWithOffset inArray, int start, UInt32 key ) : void
inArray CSharpRTMP.Common.BufferWithOffset
start int
key System.UInt32
return void
        private void Decrypt16Byte(BufferWithOffset inArray,int start, UInt32[] key)
        {
            UInt32 s0, s1, s2, s3, t0, t1, t2, t3;

            ByteArrayToU32(inArray.Buffer, start+inArray.Offset, out s0, out s1, out s2, out s3);
            s0 = s0 ^ key[0];
            s1 = s1 ^ key[1];
            s2 = s2 ^ key[2];
            s3 = s3 ^ key[3];
            int r = rounds >> 1;
            int i = 0;
            for (;;)
            {
                t0 =
                    Td0[(s0 >> 24)] ^
                    Td1[(s3 >> 16) & 0xff] ^
                    Td2[(s2 >> 8) & 0xff] ^
                    Td3[(s1) & 0xff] ^
                    key[4 + 8*i];
                t1 =
                    Td0[(s1 >> 24)] ^
                    Td1[(s0 >> 16) & 0xff] ^
                    Td2[(s3 >> 8) & 0xff] ^
                    Td3[(s2) & 0xff] ^
                    key[5 + 8*i];
                t2 =
                    Td0[(s2 >> 24)] ^
                    Td1[(s1 >> 16) & 0xff] ^
                    Td2[(s0 >> 8) & 0xff] ^
                    Td3[(s3) & 0xff] ^
                    key[6 + 8*i];
                t3 =
                    Td0[(s3 >> 24)] ^
                    Td1[(s2 >> 16) & 0xff] ^
                    Td2[(s1 >> 8) & 0xff] ^
                    Td3[(s0) & 0xff] ^
                    key[7 + 8*i];
                i++;
                if (--r == 0)
                {
                    break;
                }

                s0 =
                    Td0[(t0 >> 24)] ^
                    Td1[(t3 >> 16) & 0xff] ^
                    Td2[(t2 >> 8) & 0xff] ^
                    Td3[(t1) & 0xff] ^
                    key[0 + 8*i];
                s1 =
                    Td0[(t1 >> 24)] ^
                    Td1[(t0 >> 16) & 0xff] ^
                    Td2[(t3 >> 8) & 0xff] ^
                    Td3[(t2) & 0xff] ^
                    key[1 + 8*i];
                s2 =
                    Td0[(t2 >> 24)] ^
                    Td1[(t1 >> 16) & 0xff] ^
                    Td2[(t0 >> 8) & 0xff] ^
                    Td3[(t3) & 0xff] ^
                    key[2 + 8*i];
                s3 =
                    Td0[(t3 >> 24)] ^
                    Td1[(t2 >> 16) & 0xff] ^
                    Td2[(t1 >> 8) & 0xff] ^
                    Td3[(t0) & 0xff] ^
                    key[3 + 8*i];
            }

            s0 =
                (Td4[(t0 >> 24)] << 24) ^
                (Td4[(t3 >> 16) & 0xff] << 16) ^
                (Td4[(t2 >> 8) & 0xff] << 8) ^
                (Td4[(t1) & 0xff]) ^
                key[0 + 8*i];

            s1 =
                (Td4[(t1 >> 24)] << 24) ^
                (Td4[(t0 >> 16) & 0xff] << 16) ^
                (Td4[(t3 >> 8) & 0xff] << 8) ^
                (Td4[(t2) & 0xff]) ^
                key[1 + 8*i];

            s2 =
                (Td4[(t2 >> 24)] << 24) ^
                (Td4[(t1 >> 16) & 0xff] << 16) ^
                (Td4[(t0 >> 8) & 0xff] << 8) ^
                (Td4[(t3) & 0xff]) ^
                key[2 + 8*i];

            s3 =
                (Td4[(t3 >> 24)] << 24) ^
                (Td4[(t2 >> 16) & 0xff] << 16) ^
                (Td4[(t1 >> 8) & 0xff] << 8) ^
                (Td4[(t0) & 0xff]) ^
                key[3 + 8*i];

            U32ToByteArray(s0, s1, s2, s3, inArray.Buffer, start+inArray.Offset);
        }