/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* by using different algorithm parameters <em>P, Q, G</em>. It uses the
* Signature Standard (DSS), FIPS 186.
*
* 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 <code>currentCert</code> which doesn't
* from a CA's certificate called <code>caCert</code>.
* <p>
* <code><pre>
* // 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);
* </pre></code>
*
* @see java.security.interfaces.DSAParams
* @see java.security.interfaces.DSAPublicKey
* @see java.security.KeyFactory
* @see java.security.spec.DSAPublicKeySpec
*
* @author David Brownell
*/
public final
{
/*
* The three unsigned integer parameters.
*/
private BigInteger p , q, g;
/**
* Default constructor. The OID and parameters must be
* deserialized before this algorithm ID is used.
*/
// XXX deprecated for general use
public AlgIdDSA () {}
/**
* Construct an AlgIdDSA from an X.509 encoded byte array.
*/
/**
* define the algorithm parameters. Those integers are encoded
* as big-endian byte arrays.
*
*/
public AlgIdDSA (byte p [], byte q [], byte g [])
throws IOException
{
this (new BigInteger (1, p),
new BigInteger (1, q),
new BigInteger (1, g));
}
/**
* If all three are null, then the parameters portion of the algorithm id
* is set to null. See note in header regarding use.
*
*/
{
super (DSA_oid);
throw new ProviderException("Invalid parameters for DSS/DSA" +
" Algorithm ID");
try {
this.p = p;
this.q = q;
this.g = g;
initializeParams ();
} catch (IOException e) {
/* this should not happen */
throw new ProviderException ("Construct DSS/DSA Algorithm ID");
}
}
}
/**
* Returns "DSA", indicating the Digital Signature Algorithm (DSA) as
* defined by the Digital Signature Standard (DSS), FIPS 186.
*/
{ return "DSA"; }
/*
* For algorithm IDs which haven't been created from a DER encoded
* value, "params" must be created.
*/
private void initializeParams ()
throws IOException
{
out.putInteger(p);
out.putInteger(q);
out.putInteger(g);
}
/**
* Parses algorithm parameters P, Q, and G. They're found
* in the "params" member, which never needs to be changed.
*/
protected void decodeParams ()
throws IOException
{
throw new IOException("DSA alg params are null");
throw new IOException("DSA alg parsing error");
throw new IOException ("AlgIdDSA params, extra="+
}
/*
* Returns a formatted string describing the parameters.
*/
{ return paramsToString (); }
/*
* Returns a string describing the parameters.
*/
{
return " null\n";
else
return
"\n";
}
}