blob: eb302c00bfc3d1849dde4e4ce853bdd8ae697bdd (
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
|
using System;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Asn1.Cms
{
public class OriginatorPublicKey
: Asn1Encodable
{
public static OriginatorPublicKey GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is OriginatorPublicKey originatorPublicKey)
return originatorPublicKey;
return new OriginatorPublicKey(Asn1Sequence.GetInstance(obj));
}
public static OriginatorPublicKey GetInstance(Asn1TaggedObject obj, bool explicitly)
{
return new OriginatorPublicKey(Asn1Sequence.GetInstance(obj, explicitly));
}
private readonly AlgorithmIdentifier m_algorithm;
private readonly DerBitString m_publicKey;
public OriginatorPublicKey(AlgorithmIdentifier algorithm, byte[] publicKey)
: this(algorithm, new DerBitString(publicKey))
{
}
public OriginatorPublicKey(AlgorithmIdentifier algorithm, DerBitString publicKey)
{
m_algorithm = algorithm ?? throw new ArgumentNullException(nameof(algorithm));
m_publicKey = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
}
private OriginatorPublicKey(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 2)
throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
m_algorithm = AlgorithmIdentifier.GetInstance(seq[0]);
m_publicKey = DerBitString.GetInstance(seq[1]);
}
public AlgorithmIdentifier Algorithm => m_algorithm;
public DerBitString PublicKey => m_publicKey;
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* OriginatorPublicKey ::= Sequence {
* algorithm AlgorithmIdentifier,
* publicKey BIT STRING
* }
* </pre>
*/
public override Asn1Object ToAsn1Object() => new DerSequence(m_algorithm, m_publicKey);
}
}
|