Пример #1
0
 private void Decrypt(byte[] pBuffer, ushort pBuild, byte pLocale, TransformLocale pTransformLocale)
 {
     if (pTransformLocale == TransformLocale.AES)
     {
         mAES.TransformAES(pBuffer);
     }
     else if (pTransformLocale == TransformLocale.AES_MCRYPTO)
     {
         mAES.TransformAES(pBuffer);
         for (int index1 = 1; index1 <= 6; ++index1)
         {
             byte firstFeedback  = 0;
             byte secondFeedback = 0;
             byte length         = (byte)(pBuffer.Length & 0xFF);
             if ((index1 % 2) == 0)
             {
                 for (int index2 = 0; index2 < pBuffer.Length; ++index2)
                 {
                     byte temp = pBuffer[index2];
                     temp           -= 0x48;
                     temp            = (byte)(~temp);
                     temp            = temp.RollLeft(length & 0xFF);
                     secondFeedback  = temp;
                     temp           ^= firstFeedback;
                     firstFeedback   = secondFeedback;
                     temp           -= length;
                     temp            = temp.RollRight(3);
                     pBuffer[index2] = temp;
                     --length;
                 }
             }
             else
             {
                 for (int index2 = pBuffer.Length - 1; index2 >= 0; --index2)
                 {
                     byte temp = pBuffer[index2];
                     temp            = temp.RollLeft(3);
                     temp           ^= 0x13;
                     secondFeedback  = temp;
                     temp           ^= firstFeedback;
                     firstFeedback   = secondFeedback;
                     temp           -= length;
                     temp            = temp.RollRight(4);
                     pBuffer[index2] = temp;
                     --length;
                 }
             }
         }
     }
     else if (pTransformLocale == TransformLocale.NONE)
     {
         // lol
     }
     else if (pTransformLocale == TransformLocale.OLDEST_MCRYPTO)
     {
         mAES.TransformOldKMS(pBuffer);
     }
     else if (pTransformLocale == TransformLocale.MCRYPTO)
     {
         mAES.ShiftIV();
         for (int index1 = 1; index1 <= 6; ++index1)
         {
             byte firstFeedback  = 0;
             byte secondFeedback = 0;
             byte length         = (byte)(pBuffer.Length & 0xFF);
             if ((index1 % 2) == 0)
             {
                 for (int index2 = 0; index2 < pBuffer.Length; ++index2)
                 {
                     byte temp = pBuffer[index2];
                     temp           -= 0x48;
                     temp            = (byte)(~temp);
                     temp            = temp.RollLeft(length & 0xFF);
                     secondFeedback  = temp;
                     temp           ^= firstFeedback;
                     firstFeedback   = secondFeedback;
                     temp           -= length;
                     temp            = temp.RollRight(3);
                     pBuffer[index2] = temp;
                     --length;
                 }
             }
             else
             {
                 for (int index2 = pBuffer.Length - 1; index2 >= 0; --index2)
                 {
                     byte temp = pBuffer[index2];
                     temp            = temp.RollLeft(3);
                     temp           ^= 0x13;
                     secondFeedback  = temp;
                     temp           ^= firstFeedback;
                     firstFeedback   = secondFeedback;
                     temp           -= length;
                     temp            = temp.RollRight(4);
                     pBuffer[index2] = temp;
                     --length;
                 }
             }
         }
     }
     else if (pTransformLocale == TransformLocale.SPECIAL)
     {
         mAES.TransformKMS(pBuffer);
     }
 }
Пример #2
0
        private void Decrypt(byte[] pBuffer, TransformMethod pTransformLocale)
        {
            if ((pTransformLocale & TransformMethod.AES) != 0)
            {
                mAES.TransformAES(pBuffer);
            }

            if ((pTransformLocale & TransformMethod.MAPLE_CRYPTO) != 0)
            {
                for (int index1 = 1; index1 <= 6; ++index1)
                {
                    byte firstFeedback  = 0;
                    byte secondFeedback = 0;
                    byte length         = (byte)(pBuffer.Length & 0xFF);
                    if ((index1 % 2) == 0)
                    {
                        for (int index2 = 0; index2 < pBuffer.Length; ++index2)
                        {
                            byte temp = pBuffer[index2];
                            temp           -= 0x48;
                            temp            = (byte)(~temp);
                            temp            = RollLeft(temp, length & 0xFF);
                            secondFeedback  = temp;
                            temp           ^= firstFeedback;
                            firstFeedback   = secondFeedback;
                            temp           -= length;
                            temp            = RollRight(temp, 3);
                            pBuffer[index2] = temp;
                            --length;
                        }
                    }
                    else
                    {
                        for (int index2 = pBuffer.Length - 1; index2 >= 0; --index2)
                        {
                            byte temp = pBuffer[index2];
                            temp            = RollLeft(temp, 3);
                            temp           ^= 0x13;
                            secondFeedback  = temp;
                            temp           ^= firstFeedback;
                            firstFeedback   = secondFeedback;
                            temp           -= length;
                            temp            = RollRight(temp, 4);
                            pBuffer[index2] = temp;
                            --length;
                        }
                    }
                }
            }

            if ((pTransformLocale & TransformMethod.KMS_CRYPTO) != 0)
            {
                mAES.TransformKMS(pBuffer);
            }
            if ((pTransformLocale & TransformMethod.OLD_KMS_CRYPTO) != 0)
            {
                mAES.TransformOldKMS(pBuffer);
            }

            if ((pTransformLocale & TransformMethod.SHIFT_IV) != 0)
            {
                mAES.ShiftIV();
            }
            if ((pTransformLocale & TransformMethod.SHIFT_IV_OLD) != 0)
            {
                mAES.ShiftIVOld();
            }
        }