public final class

AlgIdDSA

extends AlgorithmId
implements DSAParams
java.lang.Object
   ↳ sun.security.x509.AlgorithmId
     ↳ sun.security.x509.AlgIdDSA

Class Overview

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 follwoing 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);
 

Summary

[Expand]
Inherited Fields
From class sun.security.x509.AlgorithmId
Public Constructors
AlgIdDSA()
Default constructor.
AlgIdDSA(byte[] encodedAlg)
Construct an AlgIdDSA from an X.509 encoded byte array.
AlgIdDSA(byte[] p, byte[] q, byte[] g)
Constructs a DSS/DSA Algorithm ID from unsigned integers that define the algorithm parameters.
AlgIdDSA(BigInteger p, BigInteger q, BigInteger g)
Constructs a DSS/DSA Algorithm ID from numeric parameters.
Public Methods
BigInteger getG()
Returns the DSS/DSA parameter "G"
String getName()
Returns "DSA", indicating the Digital Signature Algorithm (DSA) as defined by the Digital Signature Standard (DSS), FIPS 186.
BigInteger getP()
Returns the DSS/DSA parameter "P"
BigInteger getQ()
Returns the DSS/DSA parameter "Q"
String toString()
Returns a string describing the algorithm and its parameters.
Protected Methods
void decodeParams()
Parses algorithm parameters P, Q, and G.
String paramsToString()
Provides a human-readable description of the algorithm parameters.
[Expand]
Inherited Methods
From class sun.security.x509.AlgorithmId
From class java.lang.Object
From interface java.security.interfaces.DSAParams
From interface sun.security.util.DerEncoder

Public Constructors

public AlgIdDSA ()

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

public AlgIdDSA (byte[] encodedAlg)

Construct an AlgIdDSA from an X.509 encoded byte array.

Throws
IOException

public AlgIdDSA (byte[] p, byte[] q, byte[] g)

Constructs a DSS/DSA Algorithm ID from unsigned integers that define the algorithm parameters. Those integers are encoded as big-endian byte arrays.

Parameters
p the DSS/DSA paramter "P"
q the DSS/DSA paramter "Q"
g the DSS/DSA paramter "G"
Throws
IOException

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 the DSS/DSA paramter "P"
q the DSS/DSA paramter "Q"
g the DSS/DSA paramter "G"

Public Methods

public BigInteger getG ()

Returns the DSS/DSA parameter "G"

Returns
  • the base, g.

public String getName ()

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

public BigInteger getP ()

Returns the DSS/DSA parameter "P"

Returns
  • the prime, p.

public BigInteger getQ ()

Returns the DSS/DSA parameter "Q"

Returns
  • the subprime, q.

public String toString ()

Returns a string describing the algorithm and its parameters.

Returns
  • a string representation of the object.

Protected Methods

protected void decodeParams ()

Parses algorithm parameters P, Q, and G. They're found in the "params" member, which never needs to be changed.

Throws
IOException

protected String paramsToString ()

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