blob: 557bede9cda5c288d421bd8124c0e3975caab5fa (
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
95
|
using System;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Ess
{
public class SigningCertificateV2
: Asn1Encodable
{
private readonly Asn1Sequence certs;
private readonly Asn1Sequence policies;
public static SigningCertificateV2 GetInstance(
object o)
{
if (o == null || o is SigningCertificateV2)
return (SigningCertificateV2) o;
if (o is Asn1Sequence)
return new SigningCertificateV2((Asn1Sequence) o);
throw new ArgumentException(
"unknown object in 'SigningCertificateV2' factory : "
+ Platform.GetTypeName(o) + ".");
}
private SigningCertificateV2(
Asn1Sequence seq)
{
if (seq.Count < 1 || seq.Count > 2)
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
this.certs = Asn1Sequence.GetInstance(seq[0].ToAsn1Object());
if (seq.Count > 1)
{
this.policies = Asn1Sequence.GetInstance(seq[1].ToAsn1Object());
}
}
public SigningCertificateV2(
EssCertIDv2 cert)
{
this.certs = new DerSequence(cert);
}
public SigningCertificateV2(
EssCertIDv2[] certs)
{
this.certs = new DerSequence(certs);
}
public SigningCertificateV2(
EssCertIDv2[] certs,
PolicyInformation[] policies)
{
this.certs = new DerSequence(certs);
if (policies != null)
{
this.policies = new DerSequence(policies);
}
}
public EssCertIDv2[] GetCerts()
{
return certs.MapElements(EssCertIDv2.GetInstance);
}
public PolicyInformation[] GetPolicies()
{
return policies?.MapElements(PolicyInformation.GetInstance);
}
/**
* The definition of SigningCertificateV2 is
* <pre>
* SigningCertificateV2 ::= SEQUENCE {
* certs SEQUENCE OF EssCertIDv2,
* policies SEQUENCE OF PolicyInformation OPTIONAL
* }
* </pre>
* id-aa-signingCertificateV2 OBJECT IDENTIFIER ::= { iso(1)
* member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs9(9)
* smime(16) id-aa(2) 47 }
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(certs);
v.AddOptional(policies);
return new DerSequence(v);
}
}
}
|