blob: 3506c8686b6747dd6fe1ef02c00d56690f22678c (
plain)
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
|
package org.spongycastle.asn1.x9;
import java.util.Enumeration;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1OctetString;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.DERTaggedObject;
/**
* ANS.1 def for Diffie-Hellman key exchange OtherInfo structure. See
* RFC 2631, or X9.42, for further details.
*/
public class OtherInfo
extends ASN1Object
{
private KeySpecificInfo keyInfo;
private ASN1OctetString partyAInfo;
private ASN1OctetString suppPubInfo;
public OtherInfo(
KeySpecificInfo keyInfo,
ASN1OctetString partyAInfo,
ASN1OctetString suppPubInfo)
{
this.keyInfo = keyInfo;
this.partyAInfo = partyAInfo;
this.suppPubInfo = suppPubInfo;
}
public OtherInfo(
ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
keyInfo = new KeySpecificInfo((ASN1Sequence)e.nextElement());
while (e.hasMoreElements())
{
DERTaggedObject o = (DERTaggedObject)e.nextElement();
if (o.getTagNo() == 0)
{
partyAInfo = (ASN1OctetString)o.getObject();
}
else if (o.getTagNo() == 2)
{
suppPubInfo = (ASN1OctetString)o.getObject();
}
}
}
public KeySpecificInfo getKeyInfo()
{
return keyInfo;
}
public ASN1OctetString getPartyAInfo()
{
return partyAInfo;
}
public ASN1OctetString getSuppPubInfo()
{
return suppPubInfo;
}
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* OtherInfo ::= SEQUENCE {
* keyInfo KeySpecificInfo,
* partyAInfo [0] OCTET STRING OPTIONAL,
* suppPubInfo [2] OCTET STRING
* }
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(keyInfo);
if (partyAInfo != null)
{
v.add(new DERTaggedObject(0, partyAInfo));
}
v.add(new DERTaggedObject(2, suppPubInfo));
return new DERSequence(v);
}
}
|