01: package org.bouncycastle.asn1.cryptopro;
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.ASN1TaggedObject;
10: import org.bouncycastle.asn1.DERObject;
11: import org.bouncycastle.asn1.DERObjectIdentifier;
12: import org.bouncycastle.asn1.DERSequence;
13:
14: public class GOST28147Parameters extends ASN1Encodable {
15: ASN1OctetString iv;
16: DERObjectIdentifier paramSet;
17:
18: public static GOST28147Parameters getInstance(ASN1TaggedObject obj,
19: boolean explicit) {
20: return getInstance(ASN1Sequence.getInstance(obj, explicit));
21: }
22:
23: public static GOST28147Parameters getInstance(Object obj) {
24: if (obj == null || obj instanceof GOST28147Parameters) {
25: return (GOST28147Parameters) obj;
26: }
27:
28: if (obj instanceof ASN1Sequence) {
29: return new GOST28147Parameters((ASN1Sequence) obj);
30: }
31:
32: throw new IllegalArgumentException(
33: "Invalid GOST3410Parameter: "
34: + obj.getClass().getName());
35: }
36:
37: public GOST28147Parameters(ASN1Sequence seq) {
38: Enumeration e = seq.getObjects();
39:
40: iv = (ASN1OctetString) e.nextElement();
41: paramSet = (DERObjectIdentifier) e.nextElement();
42: }
43:
44: /**
45: * <pre>
46: * Gost28147-89-Parameters ::=
47: * SEQUENCE {
48: * iv Gost28147-89-IV,
49: * encryptionParamSet OBJECT IDENTIFIER
50: * }
51: *
52: * Gost28147-89-IV ::= OCTET STRING (SIZE (8))
53: * </pre>
54: */
55: public DERObject toASN1Object() {
56: ASN1EncodableVector v = new ASN1EncodableVector();
57:
58: v.add(iv);
59: v.add(paramSet);
60:
61: return new DERSequence(v);
62: }
63: }
|