h36704 s 00030/00111/00221 d D 1.6 97/12/09 15:24:53 luehe 7 6 c rm ,* e s 00002/00002/00330 d D 1.5 97/11/18 08:49:08 luehe 6 5 c replaced "Architecture" with "Extension" when referring to API Spec & Reference Guide e s 00002/00002/00330 d D 1.4 97/11/17 13:31:21 luehe 5 4 c removed "#ApplA" from anchor reference e s 00000/00009/00332 d D 1.3 97/10/22 15:25:10 luehe 4 3 c removed examples e s 00002/00003/00339 d D 1.2 97/10/10 12:42:08 luehe 3 1 c fixed getProvider javadocs e s 00000/00000/00000 d R 1.2 97/10/09 09:58:18 Codemgr 2 1 c SunPro Code Manager data about conflicts, renames, etc... c Name history : 1 0 security/JCE1.2/earlyaccess/javax.crypto.SecretKeyFactory.html e s 00342/00000/00000 d D 1.1 97/10/09 09:58:17 luehe 1 0 c date and time created 97/10/09 09:58:17 by luehe e u U f e 0 t T I 1 D 3 E 3 I 3 D 7 E 7 I 7 E 7 E 3 Class javax.crypto.SecretKeyFactory
D 7
All Packages  Class Hierarchy  This Package  Previous  Next  Index
E 7 I 7 All Packages Class Hierarchy This Package Previous Next Index E 7

Class javax.crypto.SecretKeyFactory

java.lang.Object
   |
   +----javax.crypto.SecretKeyFactory

D 7
public abstract class SecretKeyFactory E 7 I 7
public class SecretKeyFactory E 7
extends Object
This class represents a factory for secret keys.

Key factories are used to convert keys (opaque cryptographic keys of type Key) into key specifications (transparent representations of the underlying key material), and vice versa. Secret key factories only operate on secret (symmetric) keys.

Key factories are bi-directional, i.e., they allow to build an opaque key object from a given key specification (key material), or to retrieve the underlying key material of a key object in a suitable format.

A provider should document the key specifications supported by its secret key factory. D 7 For example, the Sun provider SecretKeyFactory for DES keys E 7 I 7 For example, the DES SecretKeyFactory of the Sun provider E 7 supports DESKeySpec as a transparent representation of DES D 7 keys, and the SecretKeyFactory for DES-EDE keys supports E 7 I 7 keys, and the DES-EDE SecretKeyFactory supports E 7 DESedeKeySpec as a transparent representation of DES-EDE keys. D 4

The following is an example of how to use a SecretKeyFactory to convert secret key data into a SecretKey object, which can be used for a subsequent Cipher operation:

 byte[] desKeyData;
 DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
 SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
 
E 4 D 7

The methods of SecretKeyFactory are divided into two groups:

SecretKeyFactory API (Application Program Interface)
These are the public methods which are visible to applications requesting the services of a secret key factory.
SecretKeyFactory SPI (Service Provider Interface)
These are the (abstract) methods that must be implemented by providers of secret key factories. Each method in this group is prefixed by the keyword engine, and is called by a correspondingly-named public API method. For example, engineGenerateSecret is called by generateSecret.
E 7

See Also: D 7
SecretKey, Key, KeyFactory, KeySpec, DESKeySpec, DESedeKeySpec E 7 I 7
SecretKey, Key, KeyFactory, KeySpec, DESKeySpec, DESedeKeySpec, PBEKeySpec E 7

Constructor Index

 o D 7 SecretKeyFactory()
E 7 I 7 SecretKeyFactory(SecretKeyFactorySpi, Provider)
Creates a SecretKeyFactory object. E 7

Method Index

 o D 7 engineGenerateSecret(KeySpec)
SPI: Generates a SecretKey object from the provided key specification (key material).
 o engineGetKeySpec(SecretKey, Class)
SPI: Returns a specification (key material) of the given key object in the requested format.
 o engineTranslateKey(SecretKey)
SPI: Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this key factory.
 o E 7 generateSecret(KeySpec)
Generates a SecretKey object from the provided key specification (key material).
 o getInstance(String)
Generates a SecretKeyFactory object for the specified secret key algorithm.
 o getInstance(String, String)
Generates a SecretKeyFactory object for the specified secret key algorithm from the specified provider.
 o getKeySpec(SecretKey, Class)
Returns a specification (key material) of the given key object in the requested format.
 o getProvider()
Returns the provider of this SecretKeyFactory object.
 o translateKey(SecretKey)
Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this key factory.

Constructors

D 7  o E 7 I 7  o E 7 SecretKeyFactory
D 7
 public SecretKeyFactory()
E 7
I 7
 protected SecretKeyFactory(SecretKeyFactorySpi keyFacSpi,
                            Provider provider)
E 7
I 7
Creates a SecretKeyFactory object.

Parameters:
keyFacSpi - the delegate
provider - the provider
E 7

Methods

 o getInstance
D 7
 public static SecretKeyFactory getInstance(String algorithm) throws NoSuchAlgorithmException
E 7
I 7
 public static final SecretKeyFactory getInstance(String algorithm) throws NoSuchAlgorithmException
E 7
Generates a SecretKeyFactory object for the specified secret key algorithm. If the default provider package contains a SecretKeyFactory subclass for the specified algorithm, an instance of that subclass is returned. If such a key factory is not available in the default provider package, other provider packages are searched.

Parameters:
algorithm - the standard name of the requested secret key algorithm. D 7 See Appendix A in the E 5 I 5 "../guide/security/CryptoSpec.html"> E 7 I 7 See Appendix A in the E 7 E 5 D 6 Java Cryptography Architecture API Specification & Reference E 6 I 6 Java Cryptography Extension API Specification & Reference E 6 for information about standard algorithm names.
Returns:
a SecretKeyFactory object for the specified secret key algorithm.
Throws: NoSuchAlgorithmException
if the requested algorithm is not available in the default provider package or any of the other provider packages that were searched.
 o getInstance
D 7
 public static SecretKeyFactory getInstance(String algorithm,
                                            String provider) throws NoSuchAlgorithmException, NoSuchProviderException
E 7
I 7
 public static final SecretKeyFactory getInstance(String algorithm,
                                                  String provider) throws NoSuchAlgorithmException, NoSuchProviderException
E 7
Generates a SecretKeyFactory object for the specified secret key algorithm from the specified provider.

Parameters:
algorithm - the standard name of the requested secret key algorithm. D 7 See Appendix A in the E 5 I 5 "../guide/security/CryptoSpec.html"> E 7 I 7 See Appendix A in the E 7 E 5 D 6 Java Cryptography Architecture API Specification & Reference E 6 I 6 Java Cryptography Extension API Specification & Reference E 6 for information about standard algorithm names.
provider - the name of the provider.
Returns:
a SecretKeyFactory object for the specified secret key algorithm.
Throws: NoSuchAlgorithmException
if the algorithm is not available from the specified provider.
Throws: NoSuchProviderException
if the provider has not been configured.
See Also:
Provider
 o getProvider
 public final Provider getProvider()
Returns the provider of this SecretKeyFactory object.

Returns: D 3
the provider of this SecretKeyFactory object, or null if the provider has not yet been set E 3 I 3
the provider of this SecretKeyFactory object E 3
 o generateSecret
D 7
 public SecretKey generateSecret(KeySpec keySpec) throws InvalidKeySpecException
E 7
I 7
 public final SecretKey generateSecret(KeySpec keySpec) throws InvalidKeySpecException
E 7
Generates a SecretKey object from the provided key specification (key material).

Parameters:
keySpec - the specification (key material) of the secret key
Returns:
the secret key
Throws: InvalidKeySpecException
if the given key specification is inappropriate for this key factory to produce a secret key.
D 7  o engineGenerateSecret
 protected abstract SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException
SPI: Generates a SecretKey object from the provided key specification (key material).

Parameters:
keySpec - the specification (key material) of the secret key
Returns:
the secret key
Throws: InvalidKeySpecException
if the given key specification is inappropriate for this key factory to produce a secret key.
E 7  o getKeySpec
D 7
 public KeySpec getKeySpec(SecretKey key,
                           Class keySpec) throws InvalidKeySpecException
E 7
I 7
 public final KeySpec getKeySpec(SecretKey key,
                                 Class keySpec) throws InvalidKeySpecException
E 7
Returns a specification (key material) of the given key object in the requested format.

Parameters:
key - the key
keySpec - the requested format in which the key material shall be returned
Returns:
the underlying key specification (key material) in the requested format
Throws: InvalidKeySpecException
if the requested key specification is inappropriate for the given key, or the given key cannot be processed (e.g., the given key has an unrecognized algorithm or format).
D 7  o engineGetKeySpec
 protected abstract KeySpec engineGetKeySpec(SecretKey key,
                                             Class keySpec) throws InvalidKeySpecException
SPI: Returns a specification (key material) of the given key object in the requested format.

Parameters:
key - the key
keySpec - the requested format in which the key material shall be returned
Returns:
the underlying key specification (key material) in the requested format
Throws: InvalidKeySpecException
if the requested key specification is inappropriate for the given key, or the given key cannot be dealt with (e.g., the given key has an unrecognized format).
E 7  o translateKey
D 7
 public SecretKey translateKey(SecretKey key) throws InvalidKeyException
E 7
I 7
 public final SecretKey translateKey(SecretKey key) throws InvalidKeyException
E 7
Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this key factory.

Parameters:
key - the key whose provider is unknown or untrusted
Returns:
the translated key
Throws: InvalidKeyException
if the given key cannot be processed by this key factory.
D 7  o engineTranslateKey
 protected abstract SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException
SPI: Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this key factory.

Parameters:
key - the key whose provider is unknown or untrusted
Returns:
the translated key
Throws: InvalidKeyException
if the given key cannot be processed by this key factory.
E 7
D 7
All Packages  Class Hierarchy  This Package  Previous  Next  Index
E 7 I 7 All Packages Class Hierarchy This Package Previous Next Index E 7 E 1