blob: c22b079c8cab9d991980516d9b76d60b9ea2a9c5 (
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
|
using System;
namespace Org.BouncyCastle.Asn1.Cmp
{
public class CertRepMessage
: Asn1Encodable
{
private readonly Asn1Sequence caPubs;
private readonly Asn1Sequence response;
private CertRepMessage(Asn1Sequence seq)
{
int index = 0;
if (seq.Count > 1)
{
caPubs = Asn1Sequence.GetInstance((Asn1TaggedObject)seq[index++], true);
}
response = Asn1Sequence.GetInstance(seq[index]);
}
public static CertRepMessage GetInstance(object obj)
{
if (obj is CertRepMessage)
return (CertRepMessage)obj;
if (obj is Asn1Sequence)
return new CertRepMessage((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + obj.GetType().Name, "obj");
}
public CertRepMessage(CmpCertificate[] caPubs, CertResponse[] response)
{
if (response == null)
throw new ArgumentNullException("response");
if (caPubs != null)
{
this.caPubs = new DerSequence(caPubs);
}
this.response = new DerSequence(response);
}
public virtual CmpCertificate[] GetCAPubs()
{
if (caPubs == null)
return null;
CmpCertificate[] results = new CmpCertificate[caPubs.Count];
for (int i = 0; i != results.Length; ++i)
{
results[i] = CmpCertificate.GetInstance(caPubs[i]);
}
return results;
}
public virtual CertResponse[] GetResponse()
{
CertResponse[] results = new CertResponse[response.Count];
for (int i = 0; i != results.Length; ++i)
{
results[i] = CertResponse.GetInstance(response[i]);
}
return results;
}
/**
* <pre>
* CertRepMessage ::= SEQUENCE {
* caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
* OPTIONAL,
* response SEQUENCE OF CertResponse
* }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (caPubs != null)
{
v.Add(new DerTaggedObject(true, 1, caPubs));
}
v.Add(response);
return new DerSequence(v);
}
}
}
|