blob: 7a6c3b25e1c3b76930125b52211ca89585f96e5e (
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
|
using System;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Asn1.Cmp
{
/**
* <pre>
* KemCiphertextInfo ::= SEQUENCE {
* kem AlgorithmIdentifier{KEM-ALGORITHM, {...}},
* ct OCTET STRING
* }
* </pre>
*/
public class KemCiphertextInfo
: Asn1Encodable
{
public static KemCiphertextInfo GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is KemCiphertextInfo kemCiphertextInfo)
return kemCiphertextInfo;
return new KemCiphertextInfo(Asn1Sequence.GetInstance(obj));
}
public static KemCiphertextInfo GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) =>
new KemCiphertextInfo(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
private readonly AlgorithmIdentifier m_kem;
private readonly Asn1OctetString m_ct;
private KemCiphertextInfo(Asn1Sequence seq)
{
if (seq.Count != 2)
throw new ArgumentException("sequence size should 2", nameof(seq));
m_kem = AlgorithmIdentifier.GetInstance(seq[0]);
m_ct = Asn1OctetString.GetInstance(seq[1]);
}
public KemCiphertextInfo(AlgorithmIdentifier kem, Asn1OctetString ct)
{
m_kem = kem;
m_ct = ct;
}
public virtual AlgorithmIdentifier Kem => m_kem;
public virtual Asn1OctetString Ct => m_ct;
/**
* <pre>
* KemCiphertextInfo ::= SEQUENCE {
* kem AlgorithmIdentifier{KEM-ALGORITHM, {...}},
* ct OCTET STRING
* }
* </pre>
*
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object() => new DerSequence(m_kem, m_ct);
}
}
|