public RsaBlindingParameters(
            RsaKeyParameters	publicKey,
            BigInteger			blindingFactor)
        {
            if (publicKey.IsPrivate)
                throw new ArgumentException("RSA parameters should be for a public key");

            this.publicKey = publicKey;
            this.blindingFactor = blindingFactor;
        }
 public DHParameters(
     BigInteger	p,
     BigInteger	g,
     BigInteger	q)
     : this(p, g, q, 0)
 {
 }
 public DsaParameters(
     BigInteger	p,
     BigInteger	q,
     BigInteger	g)
     : this(p, q, g, null)
 {
 }
 public ECDomainParameters(
     ECCurve     curve,
     ECPoint     g,
     BigInteger  n)
     : this(curve, g, n, BigInteger.One)
 {
 }
 public IssuerAndSerialNumber(
     X509Name	name,
     BigInteger	certSerialNumber)
 {
     this.name = name;
     this.certSerialNumber = new DerInteger(certSerialNumber);
 }
 public X9ECParameters(
     ECCurve		curve,
     ECPoint		g,
     BigInteger	n)
     : this(curve, g, n, BigInteger.One, null)
 {
 }
        public RsaPrivateCrtKeyParameters(
            BigInteger	modulus,
            BigInteger	publicExponent,
            BigInteger	privateExponent,
            BigInteger	p,
            BigInteger	q,
            BigInteger	dP,
            BigInteger	dQ,
            BigInteger	qInv)
            : base(true, modulus, privateExponent)
        {
            ValidateValue(publicExponent, "publicExponent", "exponent");
            ValidateValue(p, "p", "P value");
            ValidateValue(q, "q", "Q value");
            ValidateValue(dP, "dP", "DP value");
            ValidateValue(dQ, "dQ", "DQ value");
            ValidateValue(qInv, "qInv", "InverseQ value");

            this.e = publicExponent;
            this.p = p;
            this.q = q;
            this.dP = dP;
            this.dQ = dQ;
            this.qInv = qInv;
        }
 /**
  * @param privateKey
  */
 public NaccacheSternKeyParameters(bool privateKey, BigInteger g, BigInteger n, int lowerSigmaBound)
     : base(privateKey)
 {
     this.g = g;
     this.n = n;
     this.lowerSigmaBound = lowerSigmaBound;
 }
 public ElGamalParameter(
     BigInteger	p,
     BigInteger	g)
 {
     this.p = new DerInteger(p);
     this.g = new DerInteger(g);
 }
        /**
        * Return a random BigInteger not less than 'min' and not greater than 'max'
        *
        * @param min the least value that may be generated
        * @param max the greatest value that may be generated
        * @param random the source of randomness
        * @return a random BigInteger value in the range [min,max]
        */
        public static BigInteger CreateRandomInRange(
            BigInteger		min,
            BigInteger		max,
            // TODO Should have been just Random class
            SecureRandom	random)
        {
            int cmp = min.CompareTo(max);
            if (cmp >= 0)
            {
                if (cmp > 0)
                    throw new ArgumentException("'min' may not be greater than 'max'");

                return min;
            }

            if (min.BitLength > max.BitLength / 2)
            {
                return CreateRandomInRange(BigInteger.Zero, max.Subtract(min), random).Add(min);
            }

            for (int i = 0; i < MaxIterations; ++i)
            {
                BigInteger x = new BigInteger(max.BitLength, random);
                if (x.CompareTo(min) >= 0 && x.CompareTo(max) <= 0)
                {
                    return x;
                }
            }

            // fall back to a faster (restricted) method
            return new BigInteger(max.Subtract(min).BitLength - 1, random).Add(min);
        }
 public DHPrivateKeyParameters(
     BigInteger		x,
     DHParameters	parameters)
     : base(true, parameters)
 {
     this.x = x;
 }
 public Gost3410Parameters(
     BigInteger	p,
     BigInteger	q,
     BigInteger	a)
     : this(p, q, a, null)
 {
 }
 public DHParameters(
     BigInteger	p,
     BigInteger	g,
     BigInteger	q,
     int			l)
     : this(p, g, q, GetDefaultMParam(l), l, null, null)
 {
 }
        public DerInteger(
            BigInteger value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

            bytes = value.ToByteArray();
        }
 public ECDomainParameters(
     ECCurve     curve,
     ECPoint     g,
     BigInteger  n,
     BigInteger  h)
     : this(curve, g, n, h, null)
 {
 }
 public DHPrivateKeyParameters(
     BigInteger			x,
     DHParameters		parameters,
     DerObjectIdentifier	algorithmOid)
     : base(true, parameters, algorithmOid)
 {
     this.x = x;
 }
 public DHParameters(
     BigInteger				p,
     BigInteger				g,
     BigInteger				q,
     BigInteger				j,
     DHValidationParameters	validation)
     : this(p, g, q,  DefaultMinimumLength, 0, j, validation)
 {
 }
 public DHParameters(
     BigInteger  p,
     BigInteger  g,
     BigInteger  q,
     int         m,
     int         l)
     : this(p, g, q, m, l, null, null)
 {
 }
 public MacData(
     DigestInfo	digInfo,
     byte[]		salt,
     int			iterationCount)
 {
     this.digInfo = digInfo;
     this.salt = (byte[]) salt.Clone();
     this.iterationCount = BigInteger.ValueOf(iterationCount);
 }
 public DsaParameter(
     BigInteger	p,
     BigInteger	q,
     BigInteger	g)
 {
     this.p = new DerInteger(p);
     this.q = new DerInteger(q);
     this.g = new DerInteger(g);
 }
 public RsaKeyGenerationParameters(
     BigInteger		publicExponent,
     SecureRandom	random,
     int				strength,
     int				certainty)
     : base(random, strength)
 {
     this.publicExponent = publicExponent;
     this.certainty = certainty;
 }
        /**
         * calculate our initial message.
         */
        public BigInteger CalculateMessage()
        {
            DHKeyPairGenerator dhGen = new DHKeyPairGenerator();
            dhGen.Init(new DHKeyGenerationParameters(random, dhParams));
            AsymmetricCipherKeyPair dhPair = dhGen.GenerateKeyPair();

            this.privateValue = ((DHPrivateKeyParameters)dhPair.Private).X;

            return ((DHPublicKeyParameters)dhPair.Public).Y;
        }
        private RsaPublicKeyStructure(
            Asn1Sequence seq)
        {
            if (seq.Count != 2)
                throw new ArgumentException("Bad sequence size: " + seq.Count);

            // Note: we are accepting technically incorrect (i.e. negative) values here
            modulus = DerInteger.GetInstance(seq[0]).PositiveValue;
            publicExponent = DerInteger.GetInstance(seq[1]).PositiveValue;
        }
        public Gost3410PublicKeyParameters(
            BigInteger			y,
            DerObjectIdentifier publicKeyParamSet)
            : base(false, publicKeyParamSet)
        {
            if (y.SignValue < 1 || y.CompareTo(Parameters.P) >= 0)
                throw new ArgumentException("Invalid y for GOST3410 public key", "y");

            this.y = y;
        }
        public ECPrivateKeyParameters(
            BigInteger			d,
            DerObjectIdentifier publicKeyParamSet)
            : base("ECGOST3410", true, publicKeyParamSet)
        {
            if (d == null)
                throw new ArgumentNullException("d");

            this.d = d;
        }
        public ElGamalPublicKeyParameters(
            BigInteger			y,
            ElGamalParameters	parameters)
            : base(false, parameters)
        {
            if (y == null)
                throw new ArgumentNullException("y");

            this.y = y;
        }
        public DsaPrivateKeyParameters(
            BigInteger		x,
            DsaParameters	parameters)
            : base(true, parameters)
        {
            if (x == null)
                throw new ArgumentNullException("x");

            this.x = x;
        }
        public ECPrivateKeyStructure(
            BigInteger key)
        {
            if (key == null)
                throw new ArgumentNullException("key");

            this.seq = new DerSequence(
                new DerInteger(1),
                new DerOctetString(key.ToByteArrayUnsigned()));
        }
        public Gost3410PrivateKeyParameters(
            BigInteger			x,
            DerObjectIdentifier	publicKeyParamSet)
            : base(true, publicKeyParamSet)
        {
            if (x.SignValue < 1 || x.BitLength > 256 || x.CompareTo(Parameters.Q) >= 0)
                throw new ArgumentException("Invalid x for GOST3410 private key", "x");

            this.x = x;
        }
        public ECPrivateKeyParameters(
            string				algorithm,
            BigInteger			d,
            DerObjectIdentifier publicKeyParamSet)
            : base(algorithm, true, publicKeyParamSet)
        {
            if (d == null)
                throw new ArgumentNullException("d");

            this.d = d;
        }