Org.BouncyCastle.Crypto.Engines.Gost28147Engine.intTobytes C# (CSharp) Method

intTobytes() private static method

private static intTobytes ( int num, byte outBytes, int outOff ) : void
num int
outBytes byte
outOff int
return void
		private static void intTobytes(
				int     num,
				byte[]  outBytes,
				int     outOff)
		{
				outBytes[outOff + 3] = (byte)(num >> 24);
				outBytes[outOff + 2] = (byte)(num >> 16);
				outBytes[outOff + 1] = (byte)(num >> 8);
				outBytes[outOff] =     (byte)num;
		}

Usage Example

Ejemplo n.º 1
0
        private void Gost28147Func(int[] workingKey, byte[] inBytes, int inOff, byte[] outBytes, int outOff)
        {
            int num  = Gost28147Engine.bytesToint(inBytes, inOff);
            int num2 = Gost28147Engine.bytesToint(inBytes, inOff + 4);

            if (this.forEncryption)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        int num3 = num;
                        int num4 = this.Gost28147_mainStep(num, workingKey[j]);
                        num  = (num2 ^ num4);
                        num2 = num3;
                    }
                }
                for (int k = 7; k > 0; k--)
                {
                    int num3 = num;
                    num  = (num2 ^ this.Gost28147_mainStep(num, workingKey[k]));
                    num2 = num3;
                }
            }
            else
            {
                for (int l = 0; l < 8; l++)
                {
                    int num3 = num;
                    num  = (num2 ^ this.Gost28147_mainStep(num, workingKey[l]));
                    num2 = num3;
                }
                for (int m = 0; m < 3; m++)
                {
                    int num5 = 7;
                    while (num5 >= 0 && (m != 2 || num5 != 0))
                    {
                        int num3 = num;
                        num  = (num2 ^ this.Gost28147_mainStep(num, workingKey[num5]));
                        num2 = num3;
                        num5--;
                    }
                }
            }
            num2 ^= this.Gost28147_mainStep(num, workingKey[0]);
            Gost28147Engine.intTobytes(num, outBytes, outOff);
            Gost28147Engine.intTobytes(num2, outBytes, outOff + 4);
        }