public class DSAParams extends java.lang.Object implements ASN1Object, java.io.Externalizable, java.security.interfaces.DSAParams
The necessary parameters to implement DSA are:
The following ASN.1 encoding is used, defined in the PKIX draft standard:
Dss-Parms ::= SEQUENCE { p INTEGER, q INTEGER, g INTEGER }
A DSAParams may also store the seed and counter used to generate p and q.
Warning: The serialization capability of this class should only be used for short-term storage and RMI between applications running the same version of this product. It should not be relied on for long-term perisistence, as future versions of this class may use an incompatible serialization format. For now, applications requiring long-term persistence should use the ASN.1 encodings provided by the input(InputStream)
and output(OutputStream)
methods directly, instead of serialization.
Constructor and Description |
---|
DSAParams()
Creates a new empty instance.
|
DSAParams(ASN1Sequence s)
Creates a new DSAParams object by parsing the given ASN.1 sequence.
|
DSAParams(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g)
Creates a new DSAParams object with the given values of p, q, and g.
|
DSAParams(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, byte[] seed, int counter, java.math.BigInteger h)
Creates a new DSAParams object with the given values of p, q, g, seed, counter and h.
|
DSAParams(java.io.InputStream is)
Creates a new DSAParams object by reading its encoding from the given input stream.
|
Modifier and Type | Method and Description |
---|---|
int |
getCounter()
Get the counter that was used generate these parameters.
|
java.math.BigInteger |
getG()
Gets g.
|
java.math.BigInteger |
getH()
Gets h.
|
java.math.BigInteger |
getP()
Gets p.
|
java.math.BigInteger |
getQ()
Gets q.
|
byte[] |
getSeed()
Gets the seed that was used generate these parameters.
|
void |
input(ASN1Sequence s)
Parses a DSAParams object from given ASN1Sequence.
|
void |
input(java.io.InputStream is)
Reads the encoding of a DSAParams object from given InputStream.
|
boolean |
isValidParams()
Checks if this
DSAParams contains DSA domain parameters generated by the FIPs-approved method as specified in FIPS 186-2. |
int |
length()
Returns the length of this object's encoding.
|
void |
output(java.io.OutputStream os)
Outputs the encoding of this
DSAParams object to the given OutputStream. |
ASN1Sequence |
outputASN1()
Outputs this
DSAParams object to the given ASN1Sequence. |
void |
readExternal(java.io.ObjectInput is)
Reads the input stream and initializes the DSA parameters.
|
java.lang.String |
toString()
Transforms this
DSAParams object into a readable string. |
void |
writeExternal(java.io.ObjectOutput os)
Writes to the output stream the DER encoding of this object.
|
public DSAParams()
public DSAParams(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g)
p
- the large prime pq
- the small prime qg
- the generator gpublic DSAParams(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, byte[] seed, int counter, java.math.BigInteger h)
p
- the large prime pq
- the small prime qg
- the generator gseed
- the seed used to generate p and q.counter
- the counter used to generate p and q.h
- the value used to generate g.public DSAParams(java.io.InputStream is) throws java.io.IOException
is
- the inputStream where the DSAParam comes fromjava.io.IOException
- If an input exception occured.public DSAParams(ASN1Sequence s) throws java.io.IOException
s
- the ASN1Sequence representing the DSAParams.java.io.IOException
- If an input exception occured.public java.math.BigInteger getP()
getP
in interface java.security.interfaces.DSAParams
null
if p is not initializedpublic java.math.BigInteger getQ()
getQ
in interface java.security.interfaces.DSAParams
null
if q is not initializedpublic java.math.BigInteger getG()
getG
in interface java.security.interfaces.DSAParams
null
if g is not initializedpublic byte[] getSeed()
null
if seed is not initializedpublic int getCounter()
null
if the count is not initializedpublic java.math.BigInteger getH()
null
if h is not initializedpublic boolean isValidParams()
DSAParams
contains DSA domain parameters generated by the FIPs-approved method as specified in FIPS 186-2.public void input(java.io.InputStream is) throws java.io.IOException
input
in interface Streamable
is
- the inputStream where the DSAParam comes fromjava.io.IOException
- If an input exception occured.output(java.io.OutputStream)
public void input(ASN1Sequence s) throws java.io.IOException
s
- the ASN1Sequence representing the DSAParams.java.io.IOException
- If an input exception occured.outputASN1()
public void output(java.io.OutputStream os) throws java.io.IOException
DSAParams
object to the given OutputStream.output
in interface Streamable
os
- the OutputStream where this DSAParams
will gojava.io.IOException
- If an output exception occured.input(InputStream)
public ASN1Sequence outputASN1()
DSAParams
object to the given ASN1Sequence.DSAParams
will goinput(ASN1Sequence)
public int length()
length
in interface Streamable
public java.lang.String toString()
DSAParams
object into a readable string.toString
in class java.lang.Object
DSAParams
objectpublic void writeExternal(java.io.ObjectOutput os) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
os
- The output stream to write the encoding to.java.io.IOException
public void readExternal(java.io.ObjectInput is) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
is
- The stream to read from.java.io.IOException
java.lang.ClassNotFoundException