01: package org.bouncycastle.asn1.cryptopro;
02:
03: import java.math.BigInteger;
04: import java.util.Enumeration;
05:
06: import org.bouncycastle.asn1.ASN1Encodable;
07: import org.bouncycastle.asn1.ASN1EncodableVector;
08: import org.bouncycastle.asn1.ASN1Sequence;
09: import org.bouncycastle.asn1.ASN1TaggedObject;
10: import org.bouncycastle.asn1.DERInteger;
11: import org.bouncycastle.asn1.DERObject;
12: import org.bouncycastle.asn1.DERSequence;
13:
14: public class ECGOST3410ParamSetParameters extends ASN1Encodable {
15: DERInteger p, q, a, b, x, y;
16:
17: public static ECGOST3410ParamSetParameters getInstance(
18: ASN1TaggedObject obj, boolean explicit) {
19: return getInstance(ASN1Sequence.getInstance(obj, explicit));
20: }
21:
22: public static ECGOST3410ParamSetParameters getInstance(Object obj) {
23: if (obj == null || obj instanceof ECGOST3410ParamSetParameters) {
24: return (ECGOST3410ParamSetParameters) obj;
25: }
26:
27: if (obj instanceof ASN1Sequence) {
28: return new ECGOST3410ParamSetParameters((ASN1Sequence) obj);
29: }
30:
31: throw new IllegalArgumentException(
32: "Invalid GOST3410Parameter: "
33: + obj.getClass().getName());
34: }
35:
36: public ECGOST3410ParamSetParameters(BigInteger a, BigInteger b,
37: BigInteger p, BigInteger q, int x, BigInteger y) {
38: this .a = new DERInteger(a);
39: this .b = new DERInteger(b);
40: this .p = new DERInteger(p);
41: this .q = new DERInteger(q);
42: this .x = new DERInteger(x);
43: this .y = new DERInteger(y);
44: }
45:
46: public ECGOST3410ParamSetParameters(ASN1Sequence seq) {
47: Enumeration e = seq.getObjects();
48:
49: a = (DERInteger) e.nextElement();
50: b = (DERInteger) e.nextElement();
51: p = (DERInteger) e.nextElement();
52: q = (DERInteger) e.nextElement();
53: x = (DERInteger) e.nextElement();
54: y = (DERInteger) e.nextElement();
55: }
56:
57: public BigInteger getP() {
58: return p.getPositiveValue();
59: }
60:
61: public BigInteger getQ() {
62: return q.getPositiveValue();
63: }
64:
65: public BigInteger getA() {
66: return a.getPositiveValue();
67: }
68:
69: public DERObject toASN1Object() {
70: ASN1EncodableVector v = new ASN1EncodableVector();
71:
72: v.add(a);
73: v.add(b);
74: v.add(p);
75: v.add(q);
76: v.add(x);
77: v.add(y);
78:
79: return new DERSequence(v);
80: }
81: }
|