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
|
using System;
namespace Org.BouncyCastle.Asn1.Cmp
{
public class CertResponse
: Asn1Encodable
{
public static CertResponse GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is CertResponse certResponse)
return certResponse;
return new CertResponse(Asn1Sequence.GetInstance(obj));
}
public static CertResponse GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new CertResponse(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
private readonly DerInteger m_certReqId;
private readonly PkiStatusInfo m_status;
private readonly CertifiedKeyPair m_certifiedKeyPair;
private readonly Asn1OctetString m_rspInfo;
private CertResponse(Asn1Sequence seq)
{
int count = seq.Count, pos = 0;
if (count < 2 || count > 4)
throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
m_certReqId = DerInteger.GetInstance(seq[pos++]);
m_status = PkiStatusInfo.GetInstance(seq[pos++]);
m_certifiedKeyPair = Asn1Utilities.ReadOptional(seq, ref pos, CertifiedKeyPair.GetOptional);
m_rspInfo = Asn1Utilities.ReadOptional(seq, ref pos, Asn1OctetString.GetOptional);
if (pos != count)
throw new ArgumentException("Unexpected elements in sequence", nameof(seq));
}
public CertResponse(DerInteger certReqId, PkiStatusInfo status)
: this(certReqId, status, null, null)
{
}
public CertResponse(DerInteger certReqId, PkiStatusInfo status, CertifiedKeyPair certifiedKeyPair,
Asn1OctetString rspInfo)
{
m_certReqId = certReqId ?? throw new ArgumentNullException(nameof(certReqId));
m_status = status ?? throw new ArgumentNullException(nameof(status));
m_certifiedKeyPair = certifiedKeyPair;
m_rspInfo = rspInfo;
}
public virtual DerInteger CertReqID => m_certReqId;
public virtual PkiStatusInfo Status => m_status;
public virtual CertifiedKeyPair CertifiedKeyPair => m_certifiedKeyPair;
public virtual Asn1OctetString RspInfo => m_rspInfo;
/**
* <pre>
* CertResponse ::= SEQUENCE {
* certReqId INTEGER,
* -- to match this response with corresponding request (a value
* -- of -1 is to be used if certReqId is not specified in the
* -- corresponding request)
* status PKIStatusInfo,
* certifiedKeyPair CertifiedKeyPair OPTIONAL,
* rspInfo OCTET STRING OPTIONAL
* -- analogous to the id-regInfo-utf8Pairs string defined
* -- for regInfo in CertReqMsg [CRMF]
* }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(4);
v.Add(m_certReqId, m_status);
v.AddOptional(m_certifiedKeyPair, m_rspInfo);
return new DerSequence(v);
}
}
}
|