F2() статический приватный Метод

static private F2 ( uint D, uint Kmi, int Kri ) : uint
D uint
Kmi uint
Kri int
Результат uint
Пример #1
0
        internal override void SetKey(byte[] key)
        {
            uint num  = 1518500249u;
            uint num2 = 1859775393u;
            int  num3 = 19;
            int  num4 = 17;

            for (int i = 0; i < 24; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    _Tm[i * 8 + j] = num;
                    num           += num2;
                    _Tr[i * 8 + j] = num3;
                    num3           = (num3 + num4) & 0x1F;
                }
            }
            byte[] array = new byte[64];
            ((global::System.Array)key).CopyTo((global::System.Array)array, 0);
            for (int k = 0; k < 8; k++)
            {
                _workingKey[k] = Pack.BE_To_UInt32(array, k * 4);
            }
            for (int l = 0; l < 12; l++)
            {
                int    num5 = l * 2 * 8;
                uint[] workingKey;
                (workingKey = _workingKey)[6] = workingKey[6] ^ Cast5Engine.F1(_workingKey[7], _Tm[num5], _Tr[num5]);
                (workingKey = _workingKey)[5] = workingKey[5] ^ Cast5Engine.F2(_workingKey[6], _Tm[num5 + 1], _Tr[num5 + 1]);
                (workingKey = _workingKey)[4] = workingKey[4] ^ Cast5Engine.F3(_workingKey[5], _Tm[num5 + 2], _Tr[num5 + 2]);
                (workingKey = _workingKey)[3] = workingKey[3] ^ Cast5Engine.F1(_workingKey[4], _Tm[num5 + 3], _Tr[num5 + 3]);
                (workingKey = _workingKey)[2] = workingKey[2] ^ Cast5Engine.F2(_workingKey[3], _Tm[num5 + 4], _Tr[num5 + 4]);
                (workingKey = _workingKey)[1] = workingKey[1] ^ Cast5Engine.F3(_workingKey[2], _Tm[num5 + 5], _Tr[num5 + 5]);
                (workingKey = _workingKey)[0] = workingKey[0] ^ Cast5Engine.F1(_workingKey[1], _Tm[num5 + 6], _Tr[num5 + 6]);
                (workingKey = _workingKey)[7] = workingKey[7] ^ Cast5Engine.F2(_workingKey[0], _Tm[num5 + 7], _Tr[num5 + 7]);
                num5 = (l * 2 + 1) * 8;
                (workingKey = _workingKey)[6] = workingKey[6] ^ Cast5Engine.F1(_workingKey[7], _Tm[num5], _Tr[num5]);
                (workingKey = _workingKey)[5] = workingKey[5] ^ Cast5Engine.F2(_workingKey[6], _Tm[num5 + 1], _Tr[num5 + 1]);
                (workingKey = _workingKey)[4] = workingKey[4] ^ Cast5Engine.F3(_workingKey[5], _Tm[num5 + 2], _Tr[num5 + 2]);
                (workingKey = _workingKey)[3] = workingKey[3] ^ Cast5Engine.F1(_workingKey[4], _Tm[num5 + 3], _Tr[num5 + 3]);
                (workingKey = _workingKey)[2] = workingKey[2] ^ Cast5Engine.F2(_workingKey[3], _Tm[num5 + 4], _Tr[num5 + 4]);
                (workingKey = _workingKey)[1] = workingKey[1] ^ Cast5Engine.F3(_workingKey[2], _Tm[num5 + 5], _Tr[num5 + 5]);
                (workingKey = _workingKey)[0] = workingKey[0] ^ Cast5Engine.F1(_workingKey[1], _Tm[num5 + 6], _Tr[num5 + 6]);
                (workingKey = _workingKey)[7] = workingKey[7] ^ Cast5Engine.F2(_workingKey[0], _Tm[num5 + 7], _Tr[num5 + 7]);
                _Kr[l * 4]     = (int)(_workingKey[0] & 0x1F);
                _Kr[l * 4 + 1] = (int)(_workingKey[2] & 0x1F);
                _Kr[l * 4 + 2] = (int)(_workingKey[4] & 0x1F);
                _Kr[l * 4 + 3] = (int)(_workingKey[6] & 0x1F);
                _Km[l * 4]     = _workingKey[7];
                _Km[l * 4 + 1] = _workingKey[5];
                _Km[l * 4 + 2] = _workingKey[3];
                _Km[l * 4 + 3] = _workingKey[1];
            }
        }
Пример #2
0
        internal override void SetKey(byte[] key)
        {
            uint num  = 1518500249u;
            uint num2 = 1859775393u;
            int  num3 = 19;
            int  num4 = 17;

            for (int i = 0; i < 24; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    this._Tm[i * 8 + j] = num;
                    num += num2;
                    this._Tr[i * 8 + j] = num3;
                    num3 = (num3 + num4 & 31);
                }
            }
            byte[] array = new byte[64];
            key.CopyTo(array, 0);
            for (int k = 0; k < 8; k++)
            {
                this._workingKey[k] = Pack.BE_To_UInt32(array, k * 4);
            }
            for (int l = 0; l < 12; l++)
            {
                int num5 = l * 2 * 8;
                this._workingKey[6] ^= Cast5Engine.F1(this._workingKey[7], this._Tm[num5], this._Tr[num5]);
                this._workingKey[5] ^= Cast5Engine.F2(this._workingKey[6], this._Tm[num5 + 1], this._Tr[num5 + 1]);
                this._workingKey[4] ^= Cast5Engine.F3(this._workingKey[5], this._Tm[num5 + 2], this._Tr[num5 + 2]);
                this._workingKey[3] ^= Cast5Engine.F1(this._workingKey[4], this._Tm[num5 + 3], this._Tr[num5 + 3]);
                this._workingKey[2] ^= Cast5Engine.F2(this._workingKey[3], this._Tm[num5 + 4], this._Tr[num5 + 4]);
                this._workingKey[1] ^= Cast5Engine.F3(this._workingKey[2], this._Tm[num5 + 5], this._Tr[num5 + 5]);
                this._workingKey[0] ^= Cast5Engine.F1(this._workingKey[1], this._Tm[num5 + 6], this._Tr[num5 + 6]);
                this._workingKey[7] ^= Cast5Engine.F2(this._workingKey[0], this._Tm[num5 + 7], this._Tr[num5 + 7]);
                num5 = (l * 2 + 1) * 8;
                this._workingKey[6] ^= Cast5Engine.F1(this._workingKey[7], this._Tm[num5], this._Tr[num5]);
                this._workingKey[5] ^= Cast5Engine.F2(this._workingKey[6], this._Tm[num5 + 1], this._Tr[num5 + 1]);
                this._workingKey[4] ^= Cast5Engine.F3(this._workingKey[5], this._Tm[num5 + 2], this._Tr[num5 + 2]);
                this._workingKey[3] ^= Cast5Engine.F1(this._workingKey[4], this._Tm[num5 + 3], this._Tr[num5 + 3]);
                this._workingKey[2] ^= Cast5Engine.F2(this._workingKey[3], this._Tm[num5 + 4], this._Tr[num5 + 4]);
                this._workingKey[1] ^= Cast5Engine.F3(this._workingKey[2], this._Tm[num5 + 5], this._Tr[num5 + 5]);
                this._workingKey[0] ^= Cast5Engine.F1(this._workingKey[1], this._Tm[num5 + 6], this._Tr[num5 + 6]);
                this._workingKey[7] ^= Cast5Engine.F2(this._workingKey[0], this._Tm[num5 + 7], this._Tr[num5 + 7]);
                this._Kr[l * 4]      = (int)(this._workingKey[0] & 31u);
                this._Kr[l * 4 + 1]  = (int)(this._workingKey[2] & 31u);
                this._Kr[l * 4 + 2]  = (int)(this._workingKey[4] & 31u);
                this._Kr[l * 4 + 3]  = (int)(this._workingKey[6] & 31u);
                this._Km[l * 4]      = this._workingKey[7];
                this._Km[l * 4 + 1]  = this._workingKey[5];
                this._Km[l * 4 + 2]  = this._workingKey[3];
                this._Km[l * 4 + 3]  = this._workingKey[1];
            }
        }
Пример #3
0
        internal override void SetKey(byte[] key)
        {
            uint num  = 0x5a827999;
            uint num2 = 0x6ed9eba1;
            int  num3 = 0x13;
            int  num4 = 0x11;

            for (int i = 0; i < 0x18; i++)
            {
                for (int m = 0; m < 8; m++)
                {
                    this._Tm[(i * 8) + m] = num;
                    num += num2;
                    this._Tr[(i * 8) + m] = num3;
                    num3 = (num3 + num4) & 0x1f;
                }
            }
            byte[] array = new byte[0x40];
            key.CopyTo(array, 0);
            for (int j = 0; j < 8; j++)
            {
                this._workingKey[j] = Pack.BE_To_UInt32(array, j * 4);
            }
            for (int k = 0; k < 12; k++)
            {
                int index = (k * 2) * 8;
                this._workingKey[6] ^= Cast5Engine.F1(this._workingKey[7], this._Tm[index], this._Tr[index]);
                this._workingKey[5] ^= Cast5Engine.F2(this._workingKey[6], this._Tm[index + 1], this._Tr[index + 1]);
                this._workingKey[4] ^= Cast5Engine.F3(this._workingKey[5], this._Tm[index + 2], this._Tr[index + 2]);
                this._workingKey[3] ^= Cast5Engine.F1(this._workingKey[4], this._Tm[index + 3], this._Tr[index + 3]);
                this._workingKey[2] ^= Cast5Engine.F2(this._workingKey[3], this._Tm[index + 4], this._Tr[index + 4]);
                this._workingKey[1] ^= Cast5Engine.F3(this._workingKey[2], this._Tm[index + 5], this._Tr[index + 5]);
                this._workingKey[0] ^= Cast5Engine.F1(this._workingKey[1], this._Tm[index + 6], this._Tr[index + 6]);
                this._workingKey[7] ^= Cast5Engine.F2(this._workingKey[0], this._Tm[index + 7], this._Tr[index + 7]);
                index = ((k * 2) + 1) * 8;
                this._workingKey[6]  ^= Cast5Engine.F1(this._workingKey[7], this._Tm[index], this._Tr[index]);
                this._workingKey[5]  ^= Cast5Engine.F2(this._workingKey[6], this._Tm[index + 1], this._Tr[index + 1]);
                this._workingKey[4]  ^= Cast5Engine.F3(this._workingKey[5], this._Tm[index + 2], this._Tr[index + 2]);
                this._workingKey[3]  ^= Cast5Engine.F1(this._workingKey[4], this._Tm[index + 3], this._Tr[index + 3]);
                this._workingKey[2]  ^= Cast5Engine.F2(this._workingKey[3], this._Tm[index + 4], this._Tr[index + 4]);
                this._workingKey[1]  ^= Cast5Engine.F3(this._workingKey[2], this._Tm[index + 5], this._Tr[index + 5]);
                this._workingKey[0]  ^= Cast5Engine.F1(this._workingKey[1], this._Tm[index + 6], this._Tr[index + 6]);
                this._workingKey[7]  ^= Cast5Engine.F2(this._workingKey[0], this._Tm[index + 7], this._Tr[index + 7]);
                this._Kr[k * 4]       = ((int)this._workingKey[0]) & 0x1f;
                this._Kr[(k * 4) + 1] = ((int)this._workingKey[2]) & 0x1f;
                this._Kr[(k * 4) + 2] = ((int)this._workingKey[4]) & 0x1f;
                this._Kr[(k * 4) + 3] = ((int)this._workingKey[6]) & 0x1f;
                this._Km[k * 4]       = this._workingKey[7];
                this._Km[(k * 4) + 1] = this._workingKey[5];
                this._Km[(k * 4) + 2] = this._workingKey[3];
                this._Km[(k * 4) + 3] = this._workingKey[1];
            }
        }
Пример #4
0
 private void CAST_Decipher(uint A, uint B, uint C, uint D, uint[] result)
 {
     for (int i = 0; i < 6; i++)
     {
         int num = (11 - i) * 4;
         C ^= Cast5Engine.F1(D, this._Km[num], this._Kr[num]);
         B ^= Cast5Engine.F2(C, this._Km[num + 1], this._Kr[num + 1]);
         A ^= Cast5Engine.F3(B, this._Km[num + 2], this._Kr[num + 2]);
         D ^= Cast5Engine.F1(A, this._Km[num + 3], this._Kr[num + 3]);
     }
     for (int j = 6; j < 12; j++)
     {
         int num2 = (11 - j) * 4;
         D ^= Cast5Engine.F1(A, this._Km[num2 + 3], this._Kr[num2 + 3]);
         A ^= Cast5Engine.F3(B, this._Km[num2 + 2], this._Kr[num2 + 2]);
         B ^= Cast5Engine.F2(C, this._Km[num2 + 1], this._Kr[num2 + 1]);
         C ^= Cast5Engine.F1(D, this._Km[num2], this._Kr[num2]);
     }
     result[0] = A;
     result[1] = B;
     result[2] = C;
     result[3] = D;
 }
Пример #5
0
 private void CAST_Encipher(uint A, uint B, uint C, uint D, uint[] result)
 {
     for (int i = 0; i < 6; i++)
     {
         int index = i * 4;
         C ^= Cast5Engine.F1(D, this._Km[index], this._Kr[index]);
         B ^= Cast5Engine.F2(C, this._Km[index + 1], this._Kr[index + 1]);
         A ^= Cast5Engine.F3(B, this._Km[index + 2], this._Kr[index + 2]);
         D ^= Cast5Engine.F1(A, this._Km[index + 3], this._Kr[index + 3]);
     }
     for (int j = 6; j < 12; j++)
     {
         int index = j * 4;
         D ^= Cast5Engine.F1(A, this._Km[index + 3], this._Kr[index + 3]);
         A ^= Cast5Engine.F3(B, this._Km[index + 2], this._Kr[index + 2]);
         B ^= Cast5Engine.F2(C, this._Km[index + 1], this._Kr[index + 1]);
         C ^= Cast5Engine.F1(D, this._Km[index], this._Kr[index]);
     }
     result[0] = A;
     result[1] = B;
     result[2] = C;
     result[3] = D;
 }