01: package org.bouncycastle.asn1.x9;
02:
03: import java.util.Enumeration;
04:
05: import org.bouncycastle.asn1.ASN1Encodable;
06: import org.bouncycastle.asn1.ASN1EncodableVector;
07: import org.bouncycastle.asn1.ASN1OctetString;
08: import org.bouncycastle.asn1.ASN1Sequence;
09: import org.bouncycastle.asn1.DERObject;
10: import org.bouncycastle.asn1.DERObjectIdentifier;
11: import org.bouncycastle.asn1.DERSequence;
12:
13: /**
14: * ASN.1 def for Diffie-Hellman key exchange KeySpecificInfo structure. See
15: * RFC 2631, or X9.42, for further details.
16: */
17: public class KeySpecificInfo extends ASN1Encodable {
18: private DERObjectIdentifier algorithm;
19: private ASN1OctetString counter;
20:
21: public KeySpecificInfo(DERObjectIdentifier algorithm,
22: ASN1OctetString counter) {
23: this .algorithm = algorithm;
24: this .counter = counter;
25: }
26:
27: public KeySpecificInfo(ASN1Sequence seq) {
28: Enumeration e = seq.getObjects();
29:
30: algorithm = (DERObjectIdentifier) e.nextElement();
31: counter = (ASN1OctetString) e.nextElement();
32: }
33:
34: public DERObjectIdentifier getAlgorithm() {
35: return algorithm;
36: }
37:
38: public ASN1OctetString getCounter() {
39: return counter;
40: }
41:
42: /**
43: * Produce an object suitable for an ASN1OutputStream.
44: * <pre>
45: * KeySpecificInfo ::= SEQUENCE {
46: * algorithm OBJECT IDENTIFIER,
47: * counter OCTET STRING SIZE (4..4)
48: * }
49: * </pre>
50: */
51: public DERObject toASN1Object() {
52: ASN1EncodableVector v = new ASN1EncodableVector();
53:
54: v.add(algorithm);
55: v.add(counter);
56:
57: return new DERSequence(v);
58: }
59: }
|