RC2CBCParameter.cs
1.69 KB
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
using System;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Pkcs
{
public class RC2CbcParameter
: Asn1Encodable
{
internal DerInteger version;
internal Asn1OctetString iv;
public static RC2CbcParameter GetInstance(
object obj)
{
if (obj is Asn1Sequence)
{
return new RC2CbcParameter((Asn1Sequence) obj);
}
throw new ArgumentException("Unknown object in factory: " + Platform.GetTypeName(obj), "obj");
}
public RC2CbcParameter(
byte[] iv)
{
this.iv = new DerOctetString(iv);
}
public RC2CbcParameter(
int parameterVersion,
byte[] iv)
{
this.version = new DerInteger(parameterVersion);
this.iv = new DerOctetString(iv);
}
private RC2CbcParameter(
Asn1Sequence seq)
{
if (seq.Count == 1)
{
iv = (Asn1OctetString)seq[0];
}
else
{
version = (DerInteger)seq[0];
iv = (Asn1OctetString)seq[1];
}
}
public BigInteger RC2ParameterVersion
{
get
{
return version == null ? null : version.Value;
}
}
public byte[] GetIV()
{
return Arrays.Clone(iv.GetOctets());
}
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (version != null)
{
v.Add(version);
}
v.Add(iv);
return new DerSequence(v);
}
}
}