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
|
using System;
namespace Org.BouncyCastle.Asn1
{
/**
* A Der encoded set object
*/
public class DerSet
: Asn1Set
{
public static readonly DerSet Empty = new DerSet();
public static DerSet FromVector(Asn1EncodableVector elementVector)
{
return elementVector.Count < 1 ? Empty : new DerSet(elementVector);
}
/**
* create an empty set
*/
public DerSet()
: base()
{
}
/**
* @param obj - a single object that makes up the set.
*/
public DerSet(Asn1Encodable element)
: base(element)
{
}
public DerSet(params Asn1Encodable[] elements)
: base(elements, true)
{
}
internal DerSet(Asn1Encodable[] elements, bool doSort)
: base(elements, doSort)
{
}
/**
* @param v - a vector of objects making up the set.
*/
public DerSet(Asn1EncodableVector elementVector)
: base(elementVector, true)
{
}
internal DerSet(Asn1EncodableVector elementVector, bool doSort)
: base(elementVector, doSort)
{
}
internal DerSet(bool isSorted, Asn1Encodable[] elements)
: base(isSorted, elements)
{
}
internal override IAsn1Encoding GetEncoding(int encoding)
{
return new ConstructedDLEncoding(Asn1Tags.Universal, Asn1Tags.Set,
Asn1OutputStream.GetContentsEncodings(Asn1OutputStream.EncodingDer, GetSortedElements()));
}
internal override IAsn1Encoding GetEncodingImplicit(int encoding, int tagClass, int tagNo)
{
return new ConstructedDLEncoding(tagClass, tagNo,
Asn1OutputStream.GetContentsEncodings(Asn1OutputStream.EncodingDer, GetSortedElements()));
}
private Asn1Encodable[] GetSortedElements()
{
if (m_sortedElements == null)
{
int count = m_elements.Length;
Asn1Object[] asn1Objects = new Asn1Object[count];
for (int i = 0; i < count; ++i)
{
asn1Objects[i] = m_elements[i].ToAsn1Object();
}
Sort(asn1Objects);
m_sortedElements = asn1Objects;
}
return m_sortedElements;
}
}
}
|