iaik.pkcs.pkcs12
Class KeyFactory

java.lang.Object
  |
  +--javax.crypto.SecretKeyFactorySpi
        |
        +--iaik.pkcs.pkcs12.KeyFactory

public final class KeyFactory
extends SecretKeyFactorySpi

SecretKeyFactory implementation for the PBE ciphers (PKCS#12).

Keys may appear in two representations within the Java Security environment:

This SecretKey factory may be used for converting opaque secret keys (instances of javax.crypto.SecretKey, iaik.security.cipher.PBEKeyBMP) into transparent PBE key material (instances of javax.crypto.spec.PBEKeySpec) according to the PKCS#12 Personal Information Exchange Syntax Standard.

An application shall use the getInstance factory method of the javax.crypto.SecretKeyFactory engine class for accessing this PBE KeyFactory, e.g.:

 PBEKeySpec keySpec = new PBEKeySpec("password".toCharArray());
 SecretKeyFactory kf = SecretKeyFactory.getInstance("PKCS#12", "IAIK");
 SecretKey sk = kf.generateSecret(keySpec);
 

Version:
File Revision 13

Constructor Summary
KeyFactory()
          Default constructor.
 
Method Summary
protected  SecretKey engineGenerateSecret(KeySpec keySpec)
          Converts the given key specification (key material) into a SecretKey object.
protected  KeySpec engineGetKeySpec(SecretKey secretKey, Class classSpec)
          Converts the given secret key into the requested key specification (key material).
protected  SecretKey engineTranslateKey(SecretKey secretKey)
          Translates a key object of some unknown or untrusted provider into a secret key object of this key factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyFactory

public KeyFactory()
Default constructor.
Method Detail

engineGenerateSecret

protected SecretKey engineGenerateSecret(KeySpec keySpec)
                                  throws InvalidKeySpecException
Converts the given key specification (key material) into a SecretKey object.

The supplied keySpec has to be an instance of javax.crypto.spec.PBEKeySpec.

Overrides:
engineGenerateSecret in class SecretKeyFactorySpi
Parameters:
keySpec - the specification (key material) to be converted into SecretKey representation.
Returns:
the SecretKey object as instance of iaik.security.cipher.PBEKeyBMP
Throws:
InvalidKeySpecException - if the given key material cannot be converted into a SecretKey object by this key factory

engineGetKeySpec

protected KeySpec engineGetKeySpec(SecretKey secretKey,
                                   Class classSpec)
                            throws InvalidKeySpecException
Converts the given secret key into the requested key specification (key material).

This method may be used for getting a javax.crypto.spec.PBEKeySpec from the given secret key. The supplied secret key has to be an instance of iaik.security.cipher.PBEKeyBMP.

Overrides:
engineGetKeySpec in class SecretKeyFactorySpi
Parameters:
secretKey - the secret key to be converted
classSpec - the class implementing the requested secret key spec
Returns:
the key specification (key material) derived from the given secret key
Throws:
InvalidKeySpecException - if the given secret key cannot be converted into the requested key specification object by this key factory

engineTranslateKey

protected SecretKey engineTranslateKey(SecretKey secretKey)
                                throws InvalidKeyException
Translates a key object of some unknown or untrusted provider into a secret key object of this key factory.
Overrides:
engineTranslateKey in class SecretKeyFactorySpi
Parameters:
secretKey - the key of some unknown or untrusted provider
Returns:
the translated key as instance of iaik.security.cipher.PBEKeyBMP
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