예제 #1
0
        private TimeStampReq(
            Asn1Sequence seq)
        {
            int nbObjects = seq.Count;
            int seqStart  = 0;

            // version
            version = DerInteger.GetInstance(seq[seqStart++]);

            // messageImprint
            messageImprint = MessageImprint.GetInstance(seq[seqStart++]);

            for (int opt = seqStart; opt < nbObjects; opt++)
            {
                // tsaPolicy
                if (seq[opt] is DerObjectIdentifier)
                {
                    tsaPolicy = DerObjectIdentifier.GetInstance(seq[opt]);
                }
                // nonce
                else if (seq[opt] is DerInteger)
                {
                    nonce = DerInteger.GetInstance(seq[opt]);
                }
                // certReq
                else if (seq[opt] is DerBoolean)
                {
                    certReq = DerBoolean.GetInstance(seq[opt]);
                }
                // extensions
                else if (seq[opt] is Asn1TaggedObject)
                {
                    Asn1TaggedObject tagged = (Asn1TaggedObject)seq[opt];
                    if (tagged.TagNo == 0)
                    {
                        extensions = X509Extensions.GetInstance(tagged, false);
                    }
                }
            }
        }
예제 #2
0
        private TstInfo(
            Asn1Sequence seq)
        {
            IEnumerator e = seq.GetEnumerator();

            // version
            e.MoveNext();
            version = DerInteger.GetInstance(e.Current);

            // tsaPolicy
            e.MoveNext();
            tsaPolicyId = DerObjectIdentifier.GetInstance(e.Current);

            // messageImprint
            e.MoveNext();
            messageImprint = MessageImprint.GetInstance(e.Current);

            // serialNumber
            e.MoveNext();
            serialNumber = DerInteger.GetInstance(e.Current);

            // genTime
            e.MoveNext();
            genTime = DerGeneralizedTime.GetInstance(e.Current);

            // default for ordering
            ordering = DerBoolean.False;

            while (e.MoveNext())
            {
                Asn1Object o = (Asn1Object)e.Current;

                if (o is Asn1TaggedObject)
                {
                    DerTaggedObject tagged = (DerTaggedObject)o;

                    switch (tagged.TagNo)
                    {
                    case 0:
                        tsa = GeneralName.GetInstance(tagged, true);
                        break;

                    case 1:
                        extensions = X509Extensions.GetInstance(tagged, false);
                        break;

                    default:
                        throw new ArgumentException("Unknown tag value " + tagged.TagNo);
                    }
                }

                if (o is DerSequence)
                {
                    accuracy = Accuracy.GetInstance(o);
                }

                if (o is DerBoolean)
                {
                    ordering = DerBoolean.GetInstance(o);
                }

                if (o is DerInteger)
                {
                    nonce = DerInteger.GetInstance(o);
                }
            }
        }