blob: e465346eba7a973a4fce3ceb04eedc2503a73f4e (
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
|
using System;
namespace Org.BouncyCastle.Asn1.Cmp
{
public class KeyRecRepContent
: Asn1Encodable
{
public static KeyRecRepContent GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is KeyRecRepContent keyRecRepContent)
return keyRecRepContent;
return new KeyRecRepContent(Asn1Sequence.GetInstance(obj));
}
public static KeyRecRepContent GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new KeyRecRepContent(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
private readonly PkiStatusInfo m_status;
private readonly CmpCertificate m_newSigCert;
private readonly Asn1Sequence m_caCerts;
private readonly Asn1Sequence m_keyPairHist;
private KeyRecRepContent(Asn1Sequence seq)
{
m_status = PkiStatusInfo.GetInstance(seq[0]);
for (int pos = 1; pos < seq.Count; ++pos)
{
Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[pos], Asn1Tags.ContextSpecific);
switch (tObj.TagNo)
{
case 0:
m_newSigCert = CmpCertificate.GetInstance(tObj.GetExplicitBaseObject());
break;
case 1:
m_caCerts = Asn1Sequence.GetInstance(tObj.GetExplicitBaseObject());
break;
case 2:
m_keyPairHist = Asn1Sequence.GetInstance(tObj.GetExplicitBaseObject());
break;
default:
throw new ArgumentException("unknown tag number: " + tObj.TagNo);
}
}
}
public virtual PkiStatusInfo Status => m_status;
public virtual CmpCertificate NewSigCert => m_newSigCert;
public virtual CmpCertificate[] GetCACerts() => m_caCerts?.MapElements(CmpCertificate.GetInstance);
public virtual CertifiedKeyPair[] GetKeyPairHist() => m_keyPairHist?.MapElements(CertifiedKeyPair.GetInstance);
/**
* <pre>
* KeyRecRepContent ::= SEQUENCE {
* status PKIStatusInfo,
* newSigCert [0] CMPCertificate OPTIONAL,
* caCerts [1] SEQUENCE SIZE (1..MAX) OF
* CMPCertificate OPTIONAL,
* keyPairHist [2] SEQUENCE SIZE (1..MAX) OF
* CertifiedKeyPair OPTIONAL
* }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(4);
v.Add(m_status);
v.AddOptionalTagged(true, 0, m_newSigCert);
v.AddOptionalTagged(true, 1, m_caCerts);
v.AddOptionalTagged(true, 2, m_keyPairHist);
return new DerSequence(v);
}
}
}
|