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

Gost28147Func() private method

private Gost28147Func ( int workingKey, byte inBytes, int inOff, byte outBytes, int outOff ) : void
workingKey int
inBytes byte
inOff int
outBytes byte
outOff int
return void
		private void Gost28147Func(
			int[]   workingKey,
			byte[]  inBytes,
			int     inOff,
			byte[]  outBytes,
			int     outOff)
		{
			int N1, N2, tmp;  //tmp -> for saving N1
			N1 = bytesToint(inBytes, inOff);
			N2 = bytesToint(inBytes, inOff + 4);

			if (this.forEncryption)
			{
			for(int k = 0; k < 3; k++)  // 1-24 steps
			{
				for(int j = 0; j < 8; j++)
				{
					tmp = N1;
					int step = Gost28147_mainStep(N1, workingKey[j]);
					N1 = N2 ^ step; // CM2
					N2 = tmp;
				}
			}
			for(int j = 7; j > 0; j--)  // 25-31 steps
			{
				tmp = N1;
				N1 = N2 ^ Gost28147_mainStep(N1, workingKey[j]); // CM2
				N2 = tmp;
			}
			}
			else //decrypt
			{
			for(int j = 0; j < 8; j++)  // 1-8 steps
			{
				tmp = N1;
				N1 = N2 ^ Gost28147_mainStep(N1, workingKey[j]); // CM2
				N2 = tmp;
			}
			for(int k = 0; k < 3; k++)  //9-31 steps
			{
				for(int j = 7; j >= 0; j--)
				{
					if ((k == 2) && (j==0))
					{
						break; // break 32 step
					}
					tmp = N1;
					N1 = N2 ^ Gost28147_mainStep(N1, workingKey[j]); // CM2
					N2 = tmp;
				}
			}
			}

			N2 = N2 ^ Gost28147_mainStep(N1, workingKey[0]);  // 32 step (N1=N1)

			intTobytes(N1, outBytes, outOff);
			intTobytes(N2, outBytes, outOff + 4);
		}