PBEKeySpecpublic class PBEKeySpec extends Object implements KeySpecThe key specification for a password based encryption key.
Password based encryption is described in PKCS #5. |
Fields Summary |
---|
private char[] | password | private final byte[] | salt | private final int | iterationCount | private final int | keyLength |
Constructors Summary |
---|
public PBEKeySpec(char[] password)Creates a new PBEKeySpec with the specified password.
if (password == null) {
this.password = new char[0];
} else {
this.password = new char[password.length];
System.arraycopy(password, 0, this.password, 0, password.length);
}
salt = null;
iterationCount = 0;
keyLength = 0;
| public PBEKeySpec(char[] password, byte[] salt, int iterationCount, int keyLength)Creates a new PBEKeySpec with the specified password, salt,
iteration count and the desired length of the derived key.
if (salt == null) {
throw new NullPointerException(Messages.getString("crypto.3B")); //$NON-NLS-1$
}
if (salt.length == 0) {
throw new IllegalArgumentException(Messages.getString("crypto.3C")); //$NON-NLS-1$
}
if (iterationCount <= 0) {
throw new IllegalArgumentException(
Messages.getString("crypto.3D")); //$NON-NLS-1$
}
if (keyLength <= 0) {
throw new IllegalArgumentException(Messages.getString("crypto.3E")); //$NON-NLS-1$
}
if (password == null) {
this.password = new char[0];
} else {
this.password = new char[password.length];
System.arraycopy(password, 0, this.password, 0, password.length);
}
this.salt = new byte[salt.length];
System.arraycopy(salt, 0, this.salt, 0, salt.length);
this.iterationCount = iterationCount;
this.keyLength = keyLength;
| public PBEKeySpec(char[] password, byte[] salt, int iterationCount)Creates a new PBEKeySpec with the specified password, salt
and iteration count.
if (salt == null) {
throw new NullPointerException(Messages.getString("crypto.3B")); //$NON-NLS-1$
}
if (salt.length == 0) {
throw new IllegalArgumentException(Messages.getString("crypto.3C")); //$NON-NLS-1$
}
if (iterationCount <= 0) {
throw new IllegalArgumentException(
Messages.getString("crypto.3D")); //$NON-NLS-1$
}
if (password == null) {
this.password = new char[0];
} else {
this.password = new char[password.length];
System.arraycopy(password, 0, this.password, 0, password.length);
}
this.salt = new byte[salt.length];
System.arraycopy(salt, 0, this.salt, 0, salt.length);
this.iterationCount = iterationCount;
this.keyLength = 0;
|
Methods Summary |
---|
public final void | clearPassword()Clears the password by overwriting it.
Arrays.fill(password, '?");
password = null;
| public final int | getIterationCount()Returns the iteration count of this key specification.
return iterationCount;
| public final int | getKeyLength()Returns the desired key length of the derived key.
return keyLength;
| public final char[] | getPassword()Returns a copy of the password of this key specification.
if (password == null) {
throw new IllegalStateException(Messages.getString("crypto.3F")); //$NON-NLS-1$
}
char[] result = new char[password.length];
System.arraycopy(password, 0, result, 0, password.length);
return result;
| public final byte[] | getSalt()Returns a copy of the salt of this key specification.
if (salt == null) {
return null;
}
byte[] result = new byte[salt.length];
System.arraycopy(salt, 0, result, 0, salt.length);
return result;
|
|