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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
using System;
namespace Org.BouncyCastle.Asn1.X509
{
public class V2Form
: Asn1Encodable
{
internal GeneralNames issuerName;
internal IssuerSerial baseCertificateID;
internal ObjectDigestInfo objectDigestInfo;
public static V2Form GetInstance(
Asn1TaggedObject obj,
bool explicitly)
{
return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
}
public static V2Form GetInstance(object obj)
{
if (obj is V2Form)
return (V2Form)obj;
if (obj != null)
return new V2Form(Asn1Sequence.GetInstance(obj));
return null;
}
public V2Form(GeneralNames issuerName)
: this(issuerName, null, null)
{
}
public V2Form(GeneralNames issuerName, IssuerSerial baseCertificateID)
: this(issuerName, baseCertificateID, null)
{
}
public V2Form(GeneralNames issuerName, ObjectDigestInfo objectDigestInfo)
: this(issuerName, null, objectDigestInfo)
{
}
public V2Form(
GeneralNames issuerName,
IssuerSerial baseCertificateID,
ObjectDigestInfo objectDigestInfo)
{
this.issuerName = issuerName;
this.baseCertificateID = baseCertificateID;
this.objectDigestInfo = objectDigestInfo;
}
private V2Form(
Asn1Sequence seq)
{
if (seq.Count > 3)
{
throw new ArgumentException("Bad sequence size: " + seq.Count);
}
int index = 0;
if (!(seq[0] is Asn1TaggedObject))
{
index++;
this.issuerName = GeneralNames.GetInstance(seq[0]);
}
for (int i = index; i != seq.Count; i++)
{
Asn1TaggedObject o = Asn1TaggedObject.GetInstance(seq[i]);
if (o.TagNo == 0)
{
baseCertificateID = IssuerSerial.GetInstance(o, false);
}
else if (o.TagNo == 1)
{
objectDigestInfo = ObjectDigestInfo.GetInstance(o, false);
}
else
{
throw new ArgumentException("Bad tag number: " + o.TagNo);
}
}
}
public GeneralNames IssuerName
{
get { return issuerName; }
}
public IssuerSerial BaseCertificateID
{
get { return baseCertificateID; }
}
public ObjectDigestInfo ObjectDigestInfo
{
get { return objectDigestInfo; }
}
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* V2Form ::= Sequence {
* issuerName GeneralNames OPTIONAL,
* baseCertificateID [0] IssuerSerial OPTIONAL,
* objectDigestInfo [1] ObjectDigestInfo OPTIONAL
* -- issuerName MUST be present in this profile
* -- baseCertificateID and objectDigestInfo MUST NOT
* -- be present in this profile
* }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
v.AddOptional(issuerName);
v.AddOptionalTagged(false, 0, baseCertificateID);
v.AddOptionalTagged(false, 1, objectDigestInfo);
return new DerSequence(v);
}
}
}
|