APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.x509

public final Class AlgIdDSA

extends AlgorithmId
implements DSAParams
Class Inheritance
All Implemented Interfaces
java.security.interfaces.DSAParams, java.security.spec.AlgorithmParameterSpec
Imports
java.io.ObjectInputStream, .IOException, .InvalidObjectException, java.math.BigInteger, java.security.*, java.security.interfaces.DSAParams, java.util.Arrays, sun.security.util.*

This class identifies DSS/DSA Algorithm variants, which are distinguished by using different algorithm parameters P, Q, G. It uses the NIST/IETF standard DER encoding. These are used to implement the Digital Signature Standard (DSS), FIPS 186.

Note

DSS/DSA Algorithm IDs may be created without these parameters. Use of DSS/DSA in modes where parameters are either implicit (e.g. a default applicable to a site or a larger scope), or are derived from some Certificate Authority's DSS certificate, is not supported directly. The application is responsible for creating a key containing the required parameters prior to using the key in cryptographic operations. The following is an example of how this may be done assuming that we have a certificate called currentCert which doesn't contain DSS/DSA parameters and we need to derive DSS/DSA parameters from a CA's certificate called caCert.

// key containing parameters to use
DSAPublicKey cAKey = (DSAPublicKey)(caCert.getPublicKey());
// key without parameters
DSAPublicKey nullParamsKey = (DSAPublicKey)(currentCert.getPublicKey());

DSAParams cAKeyParams = cAKey.getParams();
KeyFactory kf = KeyFactory.getInstance("DSA");
DSAPublicKeySpec ks = new DSAPublicKeySpec(nullParamsKey.getY(),
                                           cAKeyParams.getP(),
                                           cAKeyParams.getQ(),
                                           cAKeyParams.getG());
DSAPublicKey usableKey = kf.generatePublic(ks);
Author
David Brownell
See Also
java.security.interfaces.DSAParams, java.security.interfaces.DSAPublicKey, java.security.KeyFactory, java.security.spec.DSAPublicKeySpec

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private BigInteger
g

private BigInteger
p

private BigInteger
q

private static final long
Inherited from sun.security.x509.AlgorithmId:
DSA_oidEC_oidencodedParamsMD2_oidMD5_oidMGF1_oidRSAEncryption_oidRSASSA_PSS_oidSHA224_oidSHA256_oidSHA384_oidSHA3_224_oidSHA3_256_oidSHA3_384_oidSHA3_512_oidSHA512_224_oidSHA512_256_oidSHA512_oidSHA_oidSHAKE128_256_oidSHAKE256_512_oid

Constructor Summary

AccessConstructor and Description
public
AlgIdDSA()
Deprecated

Default constructor.

public
AlgIdDSA(BigInteger
the DSS/DSA parameter "P"
p
,
BigInteger
the DSS/DSA parameter "Q"
q
,
BigInteger
the DSS/DSA parameter "G"
g
)

Constructs a DSS/DSA Algorithm ID from numeric parameters.

Method Summary

Modifier and TypeMethod and Description
private static byte[]
public BigInteger
getG()

Implements java.security.interfaces.DSAParams.getG.

Returns the DSS/DSA parameter "G"

public String
getName()

Overrides sun.security.x509.AlgorithmId.getName.

Returns "DSA", indicating the Digital Signature Algorithm (DSA) as defined by the Digital Signature Standard (DSS), FIPS 186.

public BigInteger
getP()

Implements java.security.interfaces.DSAParams.getP.

Returns the DSS/DSA parameter "P"

public BigInteger
getQ()

Implements java.security.interfaces.DSAParams.getQ.

Returns the DSS/DSA parameter "Q"

protected String
paramsToString()

Overrides sun.security.x509.AlgorithmId.paramsToString.

Provides a human-readable description of the algorithm parameters.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
stream
)

Restores the state of this object from the stream.

public String
toString()

Overrides sun.security.x509.AlgorithmId.toString.

Returns a string describing the algorithm and its parameters.

Inherited from sun.security.x509.AlgorithmId:
clearAliasOidsTabledecodeParamsencodeencodeequalsequalsequalsequalsOIDgetgetgetAlgorithmIdgetEncodedParamsgetOIDgetParametershashCodeparse

Field Detail

gback to summary
private BigInteger g
pback to summary
private BigInteger p
qback to summary
private BigInteger q
serialVersionUIDback to summary
private static final long serialVersionUID

Hides sun.security.x509.AlgorithmId.serialVersionUID.

Annotations
@Serial

Constructor Detail

AlgIdDSAback to summary
public AlgIdDSA()

Deprecated

Default constructor. The OID and parameters must be deserialized before this algorithm ID is used.

Annotations
@Deprecated
AlgIdDSAback to summary
public AlgIdDSA(BigInteger p, BigInteger q, BigInteger g)

Constructs a DSS/DSA Algorithm ID from numeric parameters. If all three are null, then the parameters portion of the algorithm id is set to null. See note in header regarding use.

Parameters
p:BigInteger

the DSS/DSA parameter "P"

q:BigInteger

the DSS/DSA parameter "Q"

g:BigInteger

the DSS/DSA parameter "G"

Method Detail

encodeback to summary
private static byte[] encode(BigInteger p, BigInteger q, BigInteger g) throws IOException
getGback to summary
public BigInteger getG()

Implements java.security.interfaces.DSAParams.getG.

Returns the DSS/DSA parameter "G"

getNameback to summary
public String getName()

Overrides sun.security.x509.AlgorithmId.getName.

Returns "DSA", indicating the Digital Signature Algorithm (DSA) as defined by the Digital Signature Standard (DSS), FIPS 186.

getPback to summary
public BigInteger getP()

Implements java.security.interfaces.DSAParams.getP.

Returns the DSS/DSA parameter "P"

getQback to summary
public BigInteger getQ()

Implements java.security.interfaces.DSAParams.getQ.

Returns the DSS/DSA parameter "Q"

paramsToStringback to summary
protected String paramsToString()

Overrides sun.security.x509.AlgorithmId.paramsToString.

Doc from sun.security.x509.AlgorithmId.paramsToString.

Provides a human-readable description of the algorithm parameters. This may be redefined by subclasses which parse those parameters.

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException

Restores the state of this object from the stream. Override to check on the 'p', 'q', 'g', and 'encodedParams'.

Parameters
stream:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
toStringback to summary
public String toString()

Overrides sun.security.x509.AlgorithmId.toString.

Doc from sun.security.x509.AlgorithmId.toString.

Returns a string describing the algorithm and its parameters.

sun.security.x509 back to summary

private Class AlgIdDSA.DSAComponents

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final BigInteger
g

private final BigInteger
p

private final BigInteger
q

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

gback to summary
private final BigInteger g
pback to summary
private final BigInteger p
qback to summary
private final BigInteger q

Constructor Detail

DSAComponentsback to summary
pack-priv DSAComponents(BigInteger p, BigInteger q, BigInteger g)