summary refs log tree commit diff
path: root/crypto/src/asn1/cms/TimeStampAndCRL.cs
blob: c0cd4890529a304fbc0ff08b5af08a01e92edb0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
namespace Org.BouncyCastle.Asn1.Cms
{
    public class TimeStampAndCrl
		: Asn1Encodable
	{
        public static TimeStampAndCrl GetInstance(object obj)
        {
			if (obj == null)
				return null;
            if (obj is TimeStampAndCrl timeStampAndCrl)
                return timeStampAndCrl;
            return new TimeStampAndCrl(Asn1Sequence.GetInstance(obj));
        }

        public static TimeStampAndCrl GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
        {
            return new TimeStampAndCrl(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
        }

        private ContentInfo timeStamp;
		private X509.CertificateList crl;

		public TimeStampAndCrl(ContentInfo timeStamp)
		{
			this.timeStamp = timeStamp;
		}

		private TimeStampAndCrl(Asn1Sequence seq)
		{
			this.timeStamp = ContentInfo.GetInstance(seq[0]);
			if (seq.Count == 2)
			{
				this.crl = X509.CertificateList.GetInstance(seq[1]);
			}
		}

		public virtual ContentInfo TimeStampToken
		{
			get { return this.timeStamp; }
		}

		public virtual X509.CertificateList Crl
		{
			get { return this.crl; }
		}

		/**
		 * <pre>
		 * TimeStampAndCRL ::= SEQUENCE {
		 *     timeStamp   TimeStampToken,          -- according to RFC 3161
		 *     crl         CertificateList OPTIONAL -- according to RFC 5280
		 *  }
		 * </pre>
		 * @return
		 */
		public override Asn1Object ToAsn1Object()
		{
			Asn1EncodableVector v = new Asn1EncodableVector(timeStamp);
			v.AddOptional(crl);
			return new DerSequence(v);
		}
	}
}