iaik.security.dsa
Class DSAKeyFactory

java.lang.Object
  |
  +--java.security.KeyFactorySpi
        |
        +--iaik.security.dsa.DSAKeyFactory

public final class DSAKeyFactory
extends KeyFactorySpi

This class converts DSA keys (opaque representation) in their KeySpecs (transparent representation) and vice versa.

To convert, for instance, DER encoded PKCS#8 private key material (e.g. pkcs8_key_spec instantiated from PKCS8EncodedKeySpec) into DSAPrivateKey representation, use this KeyFactory for DSA keys:

 KeyFactory dsa_key_fac = KeyFactory.getInstance("DSA");
 DSAPrivateKey dsa_priv_key = (DSAPrivateKey)dsa_key_fac.generatePrivate(pkcs8_key_spec);
 

Version:
File Revision 14
See Also:
DSAPrivateKey, DSAPublicKey

Constructor Summary
DSAKeyFactory()
          Default constructor for creating a DSAKeyFactory.
 
Method Summary
protected  PrivateKey engineGeneratePrivate(KeySpec keySpec)
          Converts the given key specification to a PrivateKey.
protected  PublicKey engineGeneratePublic(KeySpec keySpec)
          Converts the given key specification to a PublicKey.
protected  KeySpec engineGetKeySpec(Key key, Class classSpec)
          Converts the given key into the requested key specification (key material).
protected  Key engineTranslateKey(Key key)
          Translates the given key object of some unknown or untrusted provider into a key object supported by this DSA key factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSAKeyFactory

public DSAKeyFactory()
Default constructor for creating a DSAKeyFactory. Applications shall use KeyFactory.getInstance("DSA"); for instantiating a DSAKeyFactory.
Method Detail

engineGeneratePrivate

protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
                                    throws InvalidKeySpecException
Converts the given key specification to a PrivateKey. The given key material may either be a DSAPrivateKeySpec or a PKCS8EncodedKeySpec.
Overrides:
engineGeneratePrivate in class KeyFactorySpi
Parameters:
keySpec - the key specification as DSAPrivateKeySpec or PKCS8EncodedKeySpec
Returns:
the resulting PrivateKey
Throws:
InvalidKeySpecException - if the given key material is not a DSAPrivateKeySpec or PKCS8EncodedKeySpec

engineGeneratePublic

protected PublicKey engineGeneratePublic(KeySpec keySpec)
                                  throws InvalidKeySpecException
Converts the given key specification to a PublicKey. The given key material may either be a DSAPublicKeySpec or a X509EncodedKeySpec.
Overrides:
engineGeneratePublic in class KeyFactorySpi
Parameters:
keySpec - the key specification as DSAPublicKeySpec or X509EncodedKeySpec
Returns:
the resulting PublicKey
Throws:
InvalidKeySpecException - if the given key material is not a DSAPublicKeySpec or X509EncodedKeySpec

engineGetKeySpec

protected KeySpec engineGetKeySpec(Key key,
                                   Class classSpec)
                            throws InvalidKeySpecException
Converts the given key into the requested key specification (key material). The given key may either be a DSAPublicKey or a DSAPrivateKey. If the key is a DSAPublicKey, this method only can create a DSAPublicKeySpec or a X509EncodedKeySpec from it. If the given key is a DSAPrivateKey, a DSAPrivateKeySpec or a PKCS8EncodedKeySpec may be returned, depending on which of these two types of specifications is requested by classSpec. Each attempt to get key material of a type not matching to a given DSA key will raise an exception.
Overrides:
engineGetKeySpec in class KeyFactorySpi
Parameters:
key - the key to be converted, which either may be a DSAPublicKey or a DSAPrivateKey.
keySpec - the key specification type into which the key shall be converted, which may be a DSAPublicKeySpec or a X509EncodedKeySpec if the given key is a DSAPublicKey, or a DSAPrivateKeySpec or a PKCS8EncodedKeySpec if the given key is a DSAPrivateKey
Returns:
the key specification (key material) derived from the given key
Throws:
InvalidKeySpecException - if the given key cannot be converted into the requested key specification object by this key factory

engineTranslateKey

protected Key engineTranslateKey(Key key)
                          throws InvalidKeyException
Translates the given key object of some unknown or untrusted provider into a key object supported by this DSA key factory. This method only can translate keys of type DSAPublicKey or DSAPrivateKey.
Overrides:
engineTranslateKey in class KeyFactorySpi
Parameters:
key - the key of some unknown or untrusted provider
Returns:
the translated key
Throws:
InvalidKeyException - if the given key cannot be translated by this key factory

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK