blob: 85c0a646c70ad6d347f04da64348177957ab523a (
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
|
using System;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Asn1.Esf
{
/// <remarks>
/// <code>
/// OtherCertID ::= SEQUENCE {
/// otherCertHash OtherHash,
/// issuerSerial IssuerSerial OPTIONAL
/// }
/// </code>
/// </remarks>
public class OtherCertID
: Asn1Encodable
{
public static OtherCertID GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is OtherCertID otherCertID)
return otherCertID;
return new OtherCertID(Asn1Sequence.GetInstance(obj));
}
public static OtherCertID GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new OtherCertID(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
private readonly OtherHash m_otherCertHash;
private readonly IssuerSerial m_issuerSerial;
private OtherCertID(Asn1Sequence seq)
{
int count = seq.Count;
if (count < 1 || count > 2)
throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
m_otherCertHash = OtherHash.GetInstance(seq[0]);
if (count > 1)
{
m_issuerSerial = IssuerSerial.GetInstance(seq[1]);
}
}
public OtherCertID(OtherHash otherCertHash)
: this(otherCertHash, null)
{
}
public OtherCertID(OtherHash otherCertHash, IssuerSerial issuerSerial)
{
m_otherCertHash = otherCertHash ?? throw new ArgumentNullException(nameof(otherCertHash));
m_issuerSerial = issuerSerial;
}
public OtherHash OtherCertHash => m_otherCertHash;
public IssuerSerial IssuerSerial => m_issuerSerial;
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(2);
v.Add(m_otherCertHash);
v.AddOptional(m_issuerSerial);
return new DerSequence(v);
}
}
}
|