blob: 9b30c6dba78d37705b760826c9c703cf0a1222cd (
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
96
|
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
namespace Org.BouncyCastle.Asn1.Smime
{
public class SmimeCapability
: Asn1Encodable
{
/**
* general preferences
*/
public static readonly DerObjectIdentifier PreferSignedData = PkcsObjectIdentifiers.PreferSignedData;
public static readonly DerObjectIdentifier CannotDecryptAny = PkcsObjectIdentifiers.CannotDecryptAny;
public static readonly DerObjectIdentifier SmimeCapabilitiesVersions = PkcsObjectIdentifiers.SmimeCapabilitiesVersions;
/**
* encryption algorithms preferences
*/
public static readonly DerObjectIdentifier DesCbc = new DerObjectIdentifier("1.3.14.3.2.7");
public static readonly DerObjectIdentifier DesEde3Cbc = PkcsObjectIdentifiers.DesEde3Cbc;
public static readonly DerObjectIdentifier RC2Cbc = PkcsObjectIdentifiers.RC2Cbc;
private DerObjectIdentifier capabilityID;
private Asn1Object parameters;
public SmimeCapability(
Asn1Sequence seq)
{
capabilityID = (DerObjectIdentifier) seq[0].ToAsn1Object();
if (seq.Count > 1)
{
parameters = seq[1].ToAsn1Object();
}
}
public SmimeCapability(
DerObjectIdentifier capabilityID,
Asn1Encodable parameters)
{
if (capabilityID == null)
throw new ArgumentNullException("capabilityID");
this.capabilityID = capabilityID;
if (parameters != null)
{
this.parameters = parameters.ToAsn1Object();
}
}
public static SmimeCapability GetInstance(
object obj)
{
if (obj == null || obj is SmimeCapability)
{
return (SmimeCapability) obj;
}
if (obj is Asn1Sequence)
{
return new SmimeCapability((Asn1Sequence) obj);
}
throw new ArgumentException("Invalid SmimeCapability");
}
public DerObjectIdentifier CapabilityID
{
get { return capabilityID; }
}
public Asn1Object Parameters
{
get { return parameters; }
}
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* SMIMECapability ::= Sequence {
* capabilityID OBJECT IDENTIFIER,
* parameters ANY DEFINED BY capabilityID OPTIONAL
* }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(capabilityID);
v.AddOptional(parameters);
return new DerSequence(v);
}
}
}
|