public class DSAParams
extends java.lang.Object
implements java.security.interfaces.DSAParams
NIST's Digital Signature Standard (DSS) specifies the DSA algorithm as public-key algorithm for being used for digital signing applications. For first calculating a hash value of any data to be signed, the Secure Hash Algorithm is proposed to be used along with the DSA algorithm.
The DSA algorithm uses a certain number of parameters:
p, which length is a multiple of 64 bits lying between
512 and 1024 bits
q) of p-1
(h(p-1)/q)(mod p) > 1
g = (h(p-1)/q)(mod p)
x less than q
y calculated from y = (gx)(mod p)
This class represents the public parameters p (prime), q
(sub-prime), and g and, for instance, may be used for algorithm specific
initializing a KeyPairGenerator for generating DSA keys:
DSAParams dsa_params = new DSAParams(p, q, g); dsa_key_gen.initialize(dsa_params, random);
(See http://java.sun.com/products/JDK/1.1/docs/guide/security/CryptoSpec.html)
Note:In versions of the toolkit 8.0 patch 184269 and earlier, the toolkit always encoded the DSA parameters with a bitlength as the initial ASN.1 component. This does not conform to RFC 3279. According to RFC 3279, it should be encoded as follows:
Dss-Parms ::= SEQUENCE {
p INTEGER,
q INTEGER,
g INTEGER }
Therefore, the toolkit will now not encode the bit length in the default setting and will follow RFC 3279.
Setting the system property specified below will allow the bit length to be encoded if this is required to
be backward compatible with an existing application:
-Diaik.security.dsa.DSAParams.encodeBitLengthParam=true
KeyPairGenerator,
KeyPair,
DSAPublicKey,
DSAPrivateKey,
DSAKeyPairGenerator,
DSAKeyFactory| Constructor and Description |
|---|
DSAParams(ASN1Object obj)
Creates a new DSAParams object from the given ASN.1 Object.
|
DSAParams(java.math.BigInteger p,
java.math.BigInteger q,
java.math.BigInteger g)
Creates a new DSAParams object from the given BigInteger
parameters.
|
DSAParams(java.security.interfaces.DSAParams params)
Creates a new DSAParams object from the given DSAParams
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Compares this DSAParams object with the given DSAParams object.
|
java.math.BigInteger |
getG()
Returns the public base value
g as BigInteger. |
java.math.BigInteger |
getP()
Returns the public prime value
p as BigInteger. |
java.math.BigInteger |
getQ()
Returns the public sub-prime value
q as BigInteger. |
int |
hashCode()
Returns a hash code for this DSAParams object.
|
ASN1Object |
toASN1Object()
Returns this DSAParams object as ASN1Object of type SEQUENCE.
|
java.lang.String |
toString()
Returns a string that represents the contents of this DSAParams.
|
public DSAParams(java.math.BigInteger p,
java.math.BigInteger q,
java.math.BigInteger g)
p - the public prime p (of a multiple length of 64 bits between 512
and 1024 bits)q - the public sub-prime q (a 160-bit prime factor of p-1)g - the public base g (=(h(p-1)/q)(mod p) > 1, with h < p-1)public DSAParams(java.security.interfaces.DSAParams params)
params - the DSAParamspublic DSAParams(ASN1Object obj) throws CodingException
This constructor may be used for parsing an already exisiting
DSAParams object, supplied as ASN1Object
that may have been created by calling toASN1Object.
obj - the DSA parameters as ASN1ObjectCodingExceptionpublic java.math.BigInteger getP()
p as BigInteger.getP in interface java.security.interfaces.DSAParamspublic java.math.BigInteger getQ()
q as BigInteger.getQ in interface java.security.interfaces.DSAParamspublic java.math.BigInteger getG()
g as BigInteger.getG in interface java.security.interfaces.DSAParamspublic ASN1Object toASN1Object()
The ASN1Object returned by this method may be used as parameter value
when creating a DSAParams object using the
DSAParams(ASN1Object obj) constructor.
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the other DSAParams objecttrue, if the two DSAParams objects are equal, false otherwisepublic java.lang.String toString()
toString in class java.lang.Object