Org.BouncyCastle.Crypto.Generators.Gost3410ParametersGenerator.procedure_Bb C# (CSharp) Метод

procedure_Bb() приватный Метод

private procedure_Bb ( long x0, long c, BigInteger pq ) : void
x0 long
c long
pq Org.BouncyCastle.Math.BigInteger
Результат void
		private void procedure_Bb(long x0, long c, BigInteger[] pq)
		{
			//Verify and perform condition: 0<x<2^32; 0<c<2^32; c - odd.
			while(x0<0 || x0>4294967296L)
			{
				x0 = init_random.NextInt()*2;
			}

			while((c<0 || c>4294967296L) || (c/2==0))
			{
				c = init_random.NextInt()*2+1;
			}

			BigInteger [] qp = new BigInteger[2];
			BigInteger q = null, Q = null, p = null;
			BigInteger C = BigInteger.ValueOf(c);
			BigInteger constA32 = BigInteger.ValueOf(97781173);

			//step1
			x0 = procedure_Aa(x0, c, qp, 256);
			q = qp[0];

			//step2
			x0 = procedure_Aa(x0, c, qp, 512);
			Q = qp[0];

			BigInteger[] y = new BigInteger[33];
			y[0] = BigInteger.ValueOf(x0);

			const int tp = 1024;

			BigInteger qQ = q.Multiply(Q);

step3:
			for(;;)
			{
				//step 3
				for (int j=0; j<32; j++)
				{
					y[j+1] = (y[j].Multiply(constA32).Add(C)).Mod(BigInteger.Two.Pow(32));
				}

				//step 4
				BigInteger Y = BigInteger.Zero;
				for (int j=0; j<32; j++)
				{
					Y = Y.Add(y[j].ShiftLeft(32*j));
				}

				y[0] = y[32]; //step 5

				//step 6
				BigInteger N = BigInteger.One.ShiftLeft(tp-1).Divide(qQ).Add(
					Y.ShiftLeft(tp-1).Divide(qQ.ShiftLeft(1024)));

				if (N.TestBit(0))
				{
					N = N.Add(BigInteger.One);
				}

				//step 7

				for(;;)
				{
					//step 11
					BigInteger qQN = qQ.Multiply(N);

					if (qQN.BitLength > tp)
					{
						goto step3; //step 9
					}

					p = qQN.Add(BigInteger.One);

					//step10
					if (BigInteger.Two.ModPow(qQN, p).CompareTo(BigInteger.One) == 0
						&& BigInteger.Two.ModPow(q.Multiply(N), p).CompareTo(BigInteger.One) != 0)
					{
						pq[0] = p;
						pq[1] = q;
						return;
					}

					N = N.Add(BigInteger.Two);
				}
			}
		}