blob: bc8b7f73144c5e9a3a9814b9cd99e05d77a71be6 (
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
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
|
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Asn1.Ocsp
{
public class ResponderID
: Asn1Encodable, IAsn1Choice
{
private readonly Asn1Encodable id;
public static ResponderID GetInstance(object obj)
{
if (obj == null || obj is ResponderID)
{
return (ResponderID)obj;
}
if (obj is Asn1OctetString octets)
{
return new ResponderID(octets);
}
if (obj is Asn1TaggedObject o)
{
if (o.TagNo == 1)
return new ResponderID(X509Name.GetInstance(o, true));
return new ResponderID(Asn1OctetString.GetInstance(o, true));
}
return new ResponderID(X509Name.GetInstance(obj));
}
public ResponderID(
Asn1OctetString id)
{
if (id == null)
throw new ArgumentNullException("id");
this.id = id;
}
public ResponderID(
X509Name id)
{
if (id == null)
throw new ArgumentNullException("id");
this.id = id;
}
public static ResponderID GetInstance(
Asn1TaggedObject obj,
bool isExplicit)
{
return GetInstance(obj.GetObject()); // must be explicitly tagged
}
public virtual byte[] GetKeyHash()
{
if (id is Asn1OctetString)
{
return ((Asn1OctetString)id).GetOctets();
}
return null;
}
public virtual X509Name Name
{
get
{
if (id is Asn1OctetString)
{
return null;
}
return X509Name.GetInstance(id);
}
}
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* ResponderID ::= CHOICE {
* byName [1] Name,
* byKey [2] KeyHash }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
if (id is Asn1OctetString)
{
return new DerTaggedObject(true, 2, id);
}
return new DerTaggedObject(true, 1, id);
}
}
}
|