blob: 954125e3c5478393bca53ce42e68baae7d00744d (
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
|
using System;
namespace Org.BouncyCastle.Asn1.Esf
{
/// <remarks>
/// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition
/// <code>
/// OcspResponsesID ::= SEQUENCE {
/// ocspIdentifier OcspIdentifier,
/// ocspRepHash OtherHash OPTIONAL
/// }
/// </code>
/// </remarks>
public class OcspResponsesID
: Asn1Encodable
{
public static OcspResponsesID GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is OcspResponsesID ocspResponsesID)
return ocspResponsesID;
return new OcspResponsesID(Asn1Sequence.GetInstance(obj));
}
public static OcspResponsesID GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new OcspResponsesID(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
private readonly OcspIdentifier m_ocspIdentifier;
private readonly OtherHash m_ocspRepHash;
private OcspResponsesID(Asn1Sequence seq)
{
int count = seq.Count;
if (count < 1 || count > 2)
throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
m_ocspIdentifier = OcspIdentifier.GetInstance(seq[0]);
if (seq.Count > 1)
{
m_ocspRepHash = OtherHash.GetInstance(seq[1]);
}
}
public OcspResponsesID(OcspIdentifier ocspIdentifier)
: this(ocspIdentifier, null)
{
}
public OcspResponsesID(OcspIdentifier ocspIdentifier, OtherHash ocspRepHash)
{
m_ocspIdentifier = ocspIdentifier ?? throw new ArgumentNullException(nameof(ocspIdentifier));
m_ocspRepHash = ocspRepHash;
}
public OcspIdentifier OcspIdentifier => m_ocspIdentifier;
public OtherHash OcspRepHash => m_ocspRepHash;
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(2);
v.Add(m_ocspIdentifier);
v.AddOptional(m_ocspRepHash);
return new DerSequence(v);
}
}
}
|