Beispiel #1
0
        public override bool Equals(
            object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            DsaValidationParameters other = obj as DsaValidationParameters;

            if (other == null)
            {
                return(false);
            }

            return(Equals(other));
        }
Beispiel #2
0
        public DsaParameters(
            BigInteger p,
            BigInteger q,
            BigInteger g,
            DsaValidationParameters parameters)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            if (q == null)
            {
                throw new ArgumentNullException("q");
            }
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            this.p          = p;
            this.q          = q;
            this.g          = g;
            this.validation = parameters;
        }
Beispiel #3
0
            /// <summary>
            /// Generate a new set of DSA domain parameters.
            /// </summary>
            /// <returns>A new set of DSADomainParameters</returns>
            public DsaDomainParameters GenerateDomainParameters()
            {
                if (parameters.P != null)
                {
                    byte[] seed = parameters.GetSeed();
                    if (seed != null && parameters.UsageIndex >= 0)
                    {
                        BigInteger g = DsaParametersGenerator.CalculateGenerator_FIPS186_3_Verifiable(FipsShs.CreateDigest(digestAlgorithm), parameters.P, parameters.Q, seed, parameters.UsageIndex);

                        return(new DsaDomainParameters(parameters.P, parameters.Q, g, new Org.BouncyCastle.Crypto.Asymmetric.DsaValidationParameters(seed, -1, parameters.UsageIndex)));
                    }
                    else
                    {
                        BigInteger g = DsaParametersGenerator.CalculateGenerator_FIPS186_3_Unverifiable(parameters.P, parameters.Q, random);

                        return(new DsaDomainParameters(parameters.P, parameters.Q, g, null));
                    }
                }
                else
                {
                    DsaParametersGenerator pGen = new DsaParametersGenerator(FipsShs.CreateDigest(digestAlgorithm));

                    DsaParameterGenerationParameters dsaGenParameters = new DsaParameterGenerationParameters(
                        parameters.L, parameters.N, parameters.Certainty, random, parameters.UsageIndex);

                    pGen.Init(dsaGenParameters);

                    DsaParameters p = pGen.GenerateParameters();

                    Org.BouncyCastle.Crypto.Internal.Parameters.DsaValidationParameters validationParameters = p.ValidationParameters;

                    return(new DsaDomainParameters(p.P, p.Q, p.G, new Org.BouncyCastle.Crypto.Asymmetric.DsaValidationParameters(validationParameters.GetSeed(), validationParameters.Counter, validationParameters.UsageIndex)));
                }
            }
Beispiel #4
0
 protected virtual bool Equals(
     DsaValidationParameters other)
 {
     return(counter == other.counter &&
            Arrays.AreEqual(seed, other.seed));
 }