FindECCurveByOid() static private method

static private FindECCurveByOid ( DerObjectIdentifier oid ) : X9ECParameters
oid Org.BouncyCastle.Asn1.DerObjectIdentifier
return Org.BouncyCastle.Asn1.X9.X9ECParameters
コード例 #1
0
        public void Init(KeyGenerationParameters parameters)
        {
            if (parameters is ECKeyGenerationParameters)
            {
                ECKeyGenerationParameters eCKeyGenerationParameters = (ECKeyGenerationParameters)parameters;
                this.publicKeyParamSet = eCKeyGenerationParameters.PublicKeyParamSet;
                this.parameters        = eCKeyGenerationParameters.DomainParameters;
            }
            else
            {
                int strength = parameters.Strength;
                DerObjectIdentifier oid;
                if (strength <= 239)
                {
                    if (strength == 192)
                    {
                        oid = X9ObjectIdentifiers.Prime192v1;
                        goto IL_AA;
                    }
                    if (strength == 224)
                    {
                        oid = SecObjectIdentifiers.SecP224r1;
                        goto IL_AA;
                    }
                    if (strength == 239)
                    {
                        oid = X9ObjectIdentifiers.Prime239v1;
                        goto IL_AA;
                    }
                }
                else
                {
                    if (strength == 256)
                    {
                        oid = X9ObjectIdentifiers.Prime256v1;
                        goto IL_AA;
                    }
                    if (strength == 384)
                    {
                        oid = SecObjectIdentifiers.SecP384r1;
                        goto IL_AA;
                    }
                    if (strength == 521)
                    {
                        oid = SecObjectIdentifiers.SecP521r1;
                        goto IL_AA;
                    }
                }
                throw new InvalidParameterException("unknown key size.");
IL_AA:
                X9ECParameters x9ECParameters = ECKeyPairGenerator.FindECCurveByOid(oid);
                this.parameters = new ECDomainParameters(x9ECParameters.Curve, x9ECParameters.G, x9ECParameters.N, x9ECParameters.H, x9ECParameters.GetSeed());
            }
            this.random = parameters.Random;
            if (this.random == null)
            {
                this.random = new SecureRandom();
            }
        }