Пример #1
0
        static void ShiftFshKey()
        {
            FlashAddr = 0X2074;
            R0X41     = ReadFshData(R0XC1);

            if (R0X41 != 0)
            {
                for (;;)
                {
                    //			asm("BANKSEL _A.R0XAB");
                    //			asm("RRCF _A.R0XAB, F, B");
                    //			asm("RRCF _A.R0XAC, F, B");
                    //			asm("RRCF _A.R0XAD, F, B");
                    //			asm("RRCF _A.R0XAE, F, B ");
                    ulR0XAB >>= 1;

                    BytesOP.ClrBit(ref ulR0XAB, 7);
                    if (BytesOP.GetBit(ulR0XAB, 27))
                    {
                        BytesOP.SetBit(ref ulR0XAB, 7);
                    }
                    ;

                    //           asm("BANKSEL _A.R0XAF");
                    //		   asm("RRCF _A.R0XAF, F, B");
                    //		   asm("RRCF _A.R0XB0, F, B");
                    //		   asm("RRCF _A.R0XB1, F, B");
                    //		   asm("RRCF _A.R0XB2, F, B");
                    ulR0XAF >>= 1;

                    BytesOP.ClrBit(ref ulR0XAF, 7);
                    if (BytesOP.GetBit(ulR0XAF, 27))
                    {
                        BytesOP.SetBit(ref ulR0XAF, 7);
                    }
                    ;

                    R0X41--;
                    if (R0X41 == 0)
                    {
                        break;
                    }
                }
            }

            R0XBB = 0XAB;
            R0XBC = 0XB3;
            R0X52 = 0X7F;
            R0X53 = 0X3F;

            BytesOP.SetBit(ref R0XCB, 6);
            GetFshKey();
        }
Пример #2
0
        public static byte[] Decode(byte[] sin)
        {
            byte[] sout = new byte[8];

            for (int i = 0; i < 8; i++)
            {
                RAMBUF[i + 0x83] = sin[i];
                RAMBUF[i + 0x8b] = sin[i];
            }

            R0XBB = 0X8B;
            R0XBC = 0XA3;
            R0X52 = 0X3F;
            R0X53 = 0X3F;

            BytesOP.ClrBit(ref R0XCB, 6);

            GetFshKey();

            R0XBB = 0X93;
            R0XBC = 0XAB;
            R0X52 = 0X3F;
            R0X53 = 0X3F;

            BytesOP.SetBit(ref R0XCB, 6);

            GetFshKey();

            for (int i = 16; i != 0; i--)     // 16次循环
            {
                MixFshKey();
            }

            R0XBB = 0XA3;
            R0XBC = 0X8B;
            R0X52 = 0X7F;
            R0X53 = 0X3F;

            BytesOP.ClrBit(ref R0XCB, 6);

            GetFshKey();
            for (int i = 0; i < 8; i++)
            {
                sout[i] = RAMBUF[0x8b + i];
            }
            return(sout);
        }