Publickeypublic interface dhprivatekey extends dhkey
Chapter 9. Keys and Certificates 141
public interface PrivateKey extends Key
public interface DSAParams {
public BigInteger getP( );
public BigInteger getQ( );
public BigInteger getG( );
}
Keys that are generated by DSA will typically implement the DSAKey interface (java.security.interfaces.DSAKey):
public void printKey(Key k) {
if (k instanceof DSAKey) {
System.out.println("key is DSA");
System.out.println("P value is " +
((DSAKey) k).getParams().getP( )); }
else System.out.println("key is not DSA");
}
The idea of a DSA key is extended even further by these two interfaces (both of which are in the java.security.interfaces package):
DSA keys are often used in the Java world (and elsewhere in cryptography), and if you know you're dealing with DSA keys, these interfaces can be very useful. In particular, if you're writing a security provider that provides an implementation of DSA keys, you should ensure that you implement all of these interfaces correctly.
9.1.2.2 RSA keys
These interfaces allow you to retrieve the parameters used to create the RSA key. In particular, the RSA public key interface has methods to return its modulus and public exponent while the private key has methods to return its modulus and private exponent. The RSAPrivateKeyCrt interface defines additional methods to return its prime values (known as P and Q) and their exponents.
9.1.2.3 Diffie−Hellman keys
Diffie−Hellman parameters are encoded into the javax.crypto.spec.DHParameterSpec class, which includes the Diffie−Hellman parameters G, L, and P. The Diffie−Hellman public key interface includes the parameter Y, and the Diffie−Hellman private key interface includes the parameter X.
9.1.2.4 The KeyPair class