public class AESPasswordRfc2898CipherFactory extends java.lang.Object implements ICipherFactory
Constructor and Description |
---|
AESPasswordRfc2898CipherFactory(java.lang.String password)
Constructs a new instance of AESPasswordRfc2898CipherFactory with the specified password.
|
AESPasswordRfc2898CipherFactory(java.lang.String password,
byte[] salt,
byte[] initializationVector)
Constructs a new instance of AESPasswordRfc2898CipherFactory with the specified password, salt and initialization vector.
|
Modifier and Type | Method and Description |
---|---|
boolean |
cipherAttributesModified()
Gets if the cipher settings attributes have been modified.
|
javax.crypto.Cipher |
getCipher(int opmode)
Gets a new cipher instance.
|
byte[] |
getInitializationVector()
Gets the initialization vector.
|
java.lang.String |
getName()
Gets the name of the cipher factory.
|
java.lang.String |
getPassword()
Gets the password.
|
byte[] |
getSalt()
Gets the salt in use.
|
byte[] |
getSettings()
Gets the cipher settings as a byte array.
|
int |
getSettingsLength()
Gets the length of the settings byte array.
|
byte[] |
getSettingsNoSecrets()
Gets the cipher settings as a byte array without secrets.
|
int |
getSettingsNoSecretsLength()
Gets the length of the settings byte array without secrets.
|
boolean |
isOutputtingInitializationVector()
Gets whether the InitializationVector is output.
|
boolean |
isOutputtingSalt()
Gets whether the salt is output.
|
void |
setInitializationVector(byte[] initializationVector)
Sets the initialization vector in use, set to null to generate a random initialization vector.
|
void |
setOutputInitializationVector(boolean outputInitializationVector)
Sets if the InitializationVector is output.
|
void |
setOutputSalt(boolean outputSalt)
Sets if the salt is output.
|
void |
setPassword(java.lang.String password)
Sets the password.
|
void |
setSalt(byte[] salt)
Sets the salt in use, set to null to generate a random salt.
|
void |
setSettings(byte[] settingsIn)
Sets the cipher settings using a byte array.
|
public AESPasswordRfc2898CipherFactory(java.lang.String password)
password
- The password to use.java.lang.NullPointerException
- password is null.public AESPasswordRfc2898CipherFactory(java.lang.String password, byte[] salt, byte[] initializationVector)
password
- The password to use.salt
- The salt to use or null.initializationVector
- The initialization vector to use or null.java.lang.NullPointerException
- password is null.java.lang.IllegalArgumentException
- salt or initializationVector is larger than 255.public javax.crypto.Cipher getCipher(int opmode) throws CipherException
getCipher
in interface ICipherFactory
opmode
- The Cipher Operation Mode (Cipher.ENCRYPT_MODE
, Cipher.DECRYPT_MODE
, Cipher.WRAP_MODE
and Cipher.UNWRAP_MODE
).CipherException
- An Exception has occurred.public java.lang.String getName()
getName
in interface ICipherFactory
public boolean cipherAttributesModified()
cipherAttributesModified
in interface ICipherFactory
public byte[] getSettings()
getSettings
in interface ICipherFactory
public int getSettingsLength()
getSettingsLength
in interface ICipherFactory
public byte[] getSettingsNoSecrets()
getSettingsNoSecrets
in interface ICipherFactory
public int getSettingsNoSecretsLength()
getSettingsNoSecretsLength
in interface ICipherFactory
public void setSettings(byte[] settingsIn) throws CipherException
setSettings
in interface ICipherFactory
settingsIn
- The byte array to load the settings from.java.lang.NullPointerException
- settingsIn is null.CipherException
- An Exception has occurred.public java.lang.String getPassword()
public void setPassword(java.lang.String password)
password
- The new password.java.lang.NullPointerException
- password is null.public byte[] getSalt()
public void setSalt(byte[] salt)
salt
- The new salt or null.java.lang.IllegalArgumentException
- salt is larger than 255.public byte[] getInitializationVector()
public void setInitializationVector(byte[] initializationVector)
initializationVector
- The new initialization vector or null.java.lang.IllegalArgumentException
- initializationVector is larger than 255.public boolean isOutputtingSalt()
public void setOutputSalt(boolean outputSalt)
outputSalt
- Should the salt be output.public boolean isOutputtingInitializationVector()
public void setOutputInitializationVector(boolean outputInitializationVector)
outputInitializationVector
- Should the InitializationVector be output.