2002/03/21 01:19:32
[org.ibex.core.git] / src / org / bouncycastle / asn1 / x509 / DSAParameter.java
1 package org.bouncycastle.asn1.x509;
2
3 import java.math.*;
4 import java.util.*;
5
6 import org.bouncycastle.asn1.*;
7
8 public class DSAParameter
9     implements DEREncodable
10 {
11     DERInteger      p, q, g;
12
13     public DSAParameter(
14         BigInteger  p,
15         BigInteger  q,
16         BigInteger  g)
17     {
18         this.p = new DERInteger(p);
19         this.q = new DERInteger(q);
20         this.g = new DERInteger(g);
21     }
22
23     public DSAParameter(
24         DERConstructedSequence  seq)
25     {
26         Enumeration     e = seq.getObjects();
27
28         p = (DERInteger)e.nextElement();
29         q = (DERInteger)e.nextElement();
30         g = (DERInteger)e.nextElement();
31     }
32
33     public BigInteger getP()
34     {
35         return p.getPositiveValue();
36     }
37
38     public BigInteger getQ()
39     {
40         return q.getPositiveValue();
41     }
42
43     public BigInteger getG()
44     {
45         return g.getPositiveValue();
46     }
47
48     public DERObject getDERObject()
49     {
50         DERConstructedSequence  seq = new DERConstructedSequence();
51
52         seq.addObject(p);
53         seq.addObject(q);
54         seq.addObject(g);
55
56         return seq;
57     }
58 }