com.ibm.crypto.hdwrCCA.provider
Class PKCS5KeySpec
- java.lang.Object
-
- com.ibm.crypto.hdwrCCA.provider.PKCS5KeySpec
-
- All Implemented Interfaces:
- java.security.spec.KeySpec
public class PKCS5KeySpec extends java.lang.Object implements java.security.spec.KeySpecSpecification 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
Stringobjects (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
Constructors Constructor and Description PKCS5KeySpec(char[] password, java.lang.String alg)Constructor that takes a password and an algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description protected voidfinalize()Ensures that the password characters of this spec are set to blanks when there are no more references to it.java.lang.StringgetAlgorithm()Returns the algorithm.char[]getPassword()Returns a clone of the password.
-
-
-
Constructor Detail
-
PKCS5KeySpec
public PKCS5KeySpec(char[] password, java.lang.String alg)Constructor that takes a password and an algorithm.Note that the given password is cloned before it is stored in the new
PKCS5KeySpecobject.- Parameters:
password- the password.alg- the algorithm.
-
-
Method Detail
-
getPassword
public final char[] getPassword()
Returns a clone of the password.Note that this method returns a clone of sensitive information. It is the caller's responsibility to zero out the information after it is no longer needed.
- Returns:
- A clone of the password
-
getAlgorithm
public final java.lang.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:
finalizein classjava.lang.Object
-
-