Inheritance: Asn1Encodable
Exemple #1
0
        public X9ECParameters(
            Asn1Sequence seq)
        {
            if (!(seq[0] is DerInteger) ||
                !((DerInteger)seq[0]).Value.Equals(BigInteger.One))
            {
                throw new ArgumentException("bad version in X9ECParameters");
            }

            X9Curve x9c = null;

            if (seq[2] is X9Curve)
            {
                x9c = (X9Curve)seq[2];
            }
            else
            {
                x9c = new X9Curve(
                    new X9FieldID(
                        (Asn1Sequence)seq[1]),
                    (Asn1Sequence)seq[2]);
            }

            this.curve = x9c.Curve;

            if (seq[3] is X9ECPoint)
            {
                this.g = ((X9ECPoint)seq[3]).Point;
            }
            else
            {
                this.g = new X9ECPoint(curve, (Asn1OctetString)seq[3]).Point;
            }

            this.n    = ((DerInteger)seq[4]).Value;
            this.seed = x9c.GetSeed();

            if (seq.Count == 6)
            {
                this.h = ((DerInteger)seq[5]).Value;
            }
        }
        public X9ECParameters(
            Asn1Sequence seq)
        {
            if (!(seq[0] is DerInteger)
               || !((DerInteger) seq[0]).Value.Equals(BigInteger.One))
            {
                throw new ArgumentException("bad version in X9ECParameters");
            }

            X9Curve x9c = null;
            if (seq[2] is X9Curve)
            {
                x9c = (X9Curve) seq[2];
            }
            else
            {
                x9c = new X9Curve(
                    new X9FieldID(
                        (Asn1Sequence) seq[1]),
                        (Asn1Sequence) seq[2]);
            }

            this.curve = x9c.Curve;

            if (seq[3] is X9ECPoint)
            {
                this.g = ((X9ECPoint) seq[3]).Point;
            }
            else
            {
                this.g = new X9ECPoint(curve, (Asn1OctetString) seq[3]).Point;
            }

            this.n = ((DerInteger) seq[4]).Value;
            this.seed = x9c.GetSeed();

            if (seq.Count == 6)
            {
                this.h = ((DerInteger) seq[5]).Value;
            }
        }