예제 #1
0
        public static void oi_symmetry_encrypt2(byte[] inBuf, int inBufLen, byte[] key, byte[] outBuf, ref int outBufLen)
        {
            int num  = 0;
            int num2 = 0;

            byte[] array  = new byte[8];
            byte[] array2 = new byte[8];
            byte[] array3 = new byte[8];
            int    num3   = inBufLen + 1 + MsdkTea.kSaltLen + MsdkTea.kZeroLen;
            int    num4;

            if ((num4 = num3 % 8) != 0)
            {
                num4 = 8 - num4;
            }
            Random random = new Random();

            array[0] = (byte)((random.Next(256) & 248) | num4);
            int num5 = 1;

            while (num4-- != 0)
            {
                array[num5++] = (byte)random.Next(256);
            }
            int i;

            for (i = 0; i < 8; i++)
            {
                array2[i] = 0;
            }
            outBufLen = 0;
            i         = 1;
            while (i <= MsdkTea.kSaltLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = (byte)random.Next(256);
                    i++;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] expr_E9_cp_0 = array;
                        int    expr_E9_cp_1 = j;
                        expr_E9_cp_0[expr_E9_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int j = 0; j < 8; j++)
                    {
                        int expr_11D_cp_1 = num2 + j;
                        outBuf[expr_11D_cp_1] ^= array2[j];
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = array[j];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            while (inBufLen != 0)
            {
                if (num5 < 8)
                {
                    array[num5++] = inBuf[num++];
                    inBufLen--;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] expr_1B7_cp_0 = array;
                        int    expr_1B7_cp_1 = j;
                        expr_1B7_cp_0[expr_1B7_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int j = 0; j < 8; j++)
                    {
                        int expr_1EB_cp_1 = num2 + j;
                        outBuf[expr_1EB_cp_1] ^= array2[j];
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = array[j];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            i = 1;
            while (i <= MsdkTea.kZeroLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = 0;
                    i++;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] expr_27D_cp_0 = array;
                        int    expr_27D_cp_1 = j;
                        expr_27D_cp_0[expr_27D_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int j = 0; j < 8; j++)
                    {
                        int expr_2B1_cp_1 = num2 + j;
                        outBuf[expr_2B1_cp_1] ^= array2[j];
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = array[j];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
        }
예제 #2
0
        public static void oi_symmetry_encrypt2(byte[] inBuf, int inBufLen, byte[] key, byte[] outBuf, ref int outBufLen)
        {
            int num  = 0;
            int num2 = 0;

            byte[] array  = new byte[8];
            byte[] array2 = new byte[8];
            byte[] array3 = new byte[8];
            int    num3   = inBufLen + 1 + MsdkTea.kSaltLen + MsdkTea.kZeroLen;
            int    num4;

            if ((num4 = num3 % 8) != 0)
            {
                num4 = 8 - num4;
            }
            Random random = new Random();

            array[0] = (byte)((random.Next(256) & 248) | num4);
            int num5 = 1;

            while (num4-- != 0)
            {
                array[num5++] = (byte)random.Next(256);
            }
            int i;

            for (i = 0; i < 8; i++)
            {
                array2[i] = 0;
            }
            outBufLen = 0;
            i         = 1;
            while (i <= MsdkTea.kSaltLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = (byte)random.Next(256);
                    i++;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] array4       = array;
                        int    num6         = j;
                        byte[] expr_F2_cp_0 = array4;
                        int    expr_F2_cp_1 = num6;
                        expr_F2_cp_0[expr_F2_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int k = 0; k < 8; k++)
                    {
                        int num7          = num2 + k;
                        int expr_129_cp_1 = num7;
                        outBuf[expr_129_cp_1] ^= array2[k];
                    }
                    for (int l = 0; l < 8; l++)
                    {
                        array2[l] = array[l];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            while (inBufLen != 0)
            {
                if (num5 < 8)
                {
                    array[num5++] = inBuf[num++];
                    inBufLen--;
                }
                if (num5 == 8)
                {
                    for (int m = 0; m < 8; m++)
                    {
                        byte[] array5        = array;
                        int    num8          = m;
                        byte[] expr_1C6_cp_0 = array5;
                        int    expr_1C6_cp_1 = num8;
                        expr_1C6_cp_0[expr_1C6_cp_1] ^= array3[m];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int n = 0; n < 8; n++)
                    {
                        int num9          = num2 + n;
                        int expr_1FD_cp_1 = num9;
                        outBuf[expr_1FD_cp_1] ^= array2[n];
                    }
                    for (int num10 = 0; num10 < 8; num10++)
                    {
                        array2[num10] = array[num10];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            i = 1;
            while (i <= MsdkTea.kZeroLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = 0;
                    i++;
                }
                if (num5 == 8)
                {
                    for (int num11 = 0; num11 < 8; num11++)
                    {
                        byte[] array6        = array;
                        int    num12         = num11;
                        byte[] expr_292_cp_0 = array6;
                        int    expr_292_cp_1 = num12;
                        expr_292_cp_0[expr_292_cp_1] ^= array3[num11];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int num13 = 0; num13 < 8; num13++)
                    {
                        int num14         = num2 + num13;
                        int expr_2C9_cp_1 = num14;
                        outBuf[expr_2C9_cp_1] ^= array2[num13];
                    }
                    for (int num15 = 0; num15 < 8; num15++)
                    {
                        array2[num15] = array[num15];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
        }