1 package org.bouncycastle.asn1.x509;
2
3 import java.math.BigInteger;
4 import java.util.*;
5
6 import org.bouncycastle.asn1.*;
7
8 public class DSAParameter
9 implements DEREncodable
10 {
11 DERIntegerDERIntegerDERIntegerpublic static DSAParameter getInstance(
12 ASN1TaggedObject obj,
13 boolean explicit)
14 {
15 return getInstance(ASN1Sequence.getInstance(obj, explicit));
16 }
17
18 public static DSAParameter getInstance(
19 Object obj)
20 {
21 if(obj == null || obj instanceof DSAParameter)
22 {
23 return (DSAParameter)obj;
24 }
25
26 if(obj instanceof ASN1Sequence)
27 {
28 return new DSAParameter((ASN1Sequence)obj);
29 }
30
31 throw new IllegalArgumentException("Invalid DSAParameter: " + obj.getClass().getName());
32 }
33
34 public DSAParameter(
35 BigInteger p,
36 BigInteger q,
37 BigInteger g)
38 {
39 this.p = new DERInteger(p);
40 this.q = new DERInteger(q);
41 this.g = new DERInteger(g);
42 }
43
44 public DSAParameter(
45 ASN1Sequence seq)
46 {
47 Enumeration e = seq.getObjects();
48
49 p = (DERInteger)e.nextElement();
50 q = (DERInteger)e.nextElement();
51 g = (DERInteger)e.nextElement();
52 }
53
54 public BigInteger getP()
55 {
56 return p.getPositiveValue();
57 }
58
59 public BigInteger getQ()
60 {
61 return q.getPositiveValue();
62 }
63
64 public BigInteger getG()
65 {
66 return g.getPositiveValue();
67 }
68
69 public DERObject getDERObject()
70 {
71 DEREncodableVector v = new DEREncodableVector();
72
73 v.add(p);
74 v.add(q);
75 v.add(g);
76
77 return new DERSequence(v);
78 }
79 }
80 ?????????????????????p????????????????????????q???????????????????????????g???????????????????DSAParameter????????????????????????????????getInstance?????????ASN1TaggedObject?????????boolean????????????????getInstance????????????????????????????ASN1Sequence?????????????????????????????????????????getInstance?????????????????????????????????????????????????????obj??????????????????????????????????????????????????????????explicit???????????????????DSAParameter????????????????????????????????getInstance?????????Object????????????obj???????????????????????????obj?????????????????????DSAParameter??????????????????????????????????obj????????????obj????????????????????????DSAParameter??????????????????????????????????????ASN1Sequence???????????????????????????????????????????????????obj???????????????????????????????????????????????????????????????????????obj????????????DSAParameter?????????BigInteger?????????BigInteger?????????BigInteger??????????????????????DERInteger?????????????????????????????????p??????????????????????DERInteger?????????????????????????????????q??????????????????????DERInteger?????????????????????????????????g????????????DSAParameter?????????ASN1Sequence?????????????????????????????seq?????????????????????????????????getObjects?????????p??????????????DERInteger?????????????????????????e?????????q??????????????DERInteger?????????????????????????e?????????g??????????????DERInteger?????????????????????????e????????????BigInteger???????????????????????getP????????????????p??????????????????getPositiveValue????????????BigInteger???????????????????????getQ????????????????q??????????????????getPositiveValue????????????BigInteger???????????????????????getG????????????????g??????????????????getPositiveValue????????????DERObject??????????????????????getDERObject?????????DEREncodableVector?????????v???????????add???????????????p?????????v???????????add???????????????q?????????v???????????add???????????????g????????????????????DERSequence????????????????????????????????v