com.ibm.crypto.provider
Class PKCS5KeySpec

java.lang.Object
  extended by com.ibm.crypto.provider.PKCS5KeySpec
All Implemented Interfaces:
KeySpec

public class PKCS5KeySpec
extends Object
implements KeySpec

Specification for a "generalized" PBE key. While a PBEKey is derived from a password and is used in the PBEWithMD5andDES cipher, a PKCS5Key is derived from a password and can be used in any PBES1 encryption schemes (for example, PBEWithMD5AndDES, PBEWithMD2AndRC2, PBEWithSHAAndTripleDES, etc).

Note that this class stores passwords as char arrays instead of String objects (which would seem more logical), because the String class is immutable and there is no way to overwrite its internal value when the password stored in it is no longer needed. Hence, this class requests the password as a char array, so it can be overwritten when done.


Constructor Summary
PKCS5KeySpec(char[] password, String alg)
          Constructor that takes a password and an algorithm.
 
Method Summary
protected  void finalize()
          Ensures that the password characters of this spec are set to blanks when there are no more references to it.
 String getAlgorithm()
          Returns the algorithm.
 char[] getPassword()
          Returns the password.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PKCS5KeySpec

public PKCS5KeySpec(char[] password,
                    String alg)
Constructor that takes a password and an algorithm.

Note that the given password is cloned before it is stored in the new PKCS5KeySpec object.

Parameters:
password - the password.
alg - the algorithm.
Method Detail

getPassword

public final char[] getPassword()
Returns the password.

Note that this method returns a reference to the password. It is the caller's responsibility to zero out the password information after it is no longer needed.

Returns:
the password

getAlgorithm

public final String getAlgorithm()
Returns the algorithm.

Returns:
the algorithm

finalize

protected void finalize()
Ensures that the password characters of this spec are set to blanks when there are no more references to it.

Overrides:
finalize in class Object