|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.crypto.CipherSpi | +--au.net.aba.crypto.provider.PBE
This class implements a basic password based encryption (PBE) algorithm. The particular implementation of PBE will specify the cipher and digest algorithms to use as well as the specific mechanism used to convert the supplied password into a secret key.
Field Summary | |
protected Cipher |
cipher
|
static java.lang.String |
ident
|
Fields inherited from class javax.crypto.CipherSpi |
ident |
Constructor Summary | |
protected |
PBE(java.lang.String cipherName)
|
Method Summary | |
protected byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
protected int |
engineDoFinal(byte[] input,
int inputOff,
int inputLen,
byte[] output,
int outputOff)
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
protected int |
engineGetBlockSize()
Returns the block size (in bytes). |
protected byte[] |
engineGetIV()
Returns the initialisation vector (IV) in a new buffer. |
protected int |
engineGetOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes). |
protected java.security.AlgorithmParameters |
engineGetParameters()
Returns the parameters used with this cipher. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initialises this cipher with a key, a set of algorithm parameters, and a source of randomness. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.AlgorithmParameters params,
java.security.SecureRandom random)
Initialises this cipher with a key, a set of algorithm parameters, and a source of randomness. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.SecureRandom random)
Initialises this cipher with a key and a source of randomness. |
protected void |
engineSetMode(java.lang.String mode)
Sets the mode of this cipher. |
protected void |
engineSetPadding(java.lang.String padding)
Sets the padding mechanism of this cipher. |
protected byte[] |
engineUpdate(byte[] input,
int inputOff,
int inputLen)
Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialised), processing another data part. |
protected int |
engineUpdate(byte[] input,
int inputOff,
int inputLen,
byte[] output,
int outputOff)
Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialised), processing another data part. |
protected abstract void |
initCipher(int opmode,
byte[] salt,
int iteration,
char[] password)
This method is provided by the specific implementation to create the digest from the password and the algorithm parameters. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String ident
protected Cipher cipher
Constructor Detail |
protected PBE(java.lang.String cipherName)
Method Detail |
protected void engineSetMode(java.lang.String mode) throws java.security.NoSuchAlgorithmException
mode
- the cipher modeprotected void engineSetPadding(java.lang.String padding) throws NoSuchPaddingException
padding
- the padding mechanismprotected int engineGetBlockSize()
protected int engineGetOutputSize(int inputLen)
This method will return a result based on the underlying cipher.
inputLen
- the input length (in bytes)protected byte[] engineGetIV()
This is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.
protected java.security.AlgorithmParameters engineGetParameters()
Currently, the PBE ciphers do not support this method.
protected void engineInit(int opmode, java.security.Key key, java.security.SecureRandom random) throws java.security.InvalidKeyException
This method of initialisation is not supported for PBE ciphers as they require parameterisation that cannot be generated by the cipher.
protected void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
The key must be a PBEKey and the algorithm parameter spec must be a PBEParameterSpec.
The cipher is initialised for encryption or decryption, depending on the value of opmode.
opmode
- the operation mode of this cipher (this is either
ENCRYPT_MODE or DECRYPT_MODE)key
- the encryption keyparams
- the algorithm parametersrandom
- the source of randomnessprotected void engineInit(int opmode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
Attempts to convert the supplied algorithm parameters into a PBEParameterSpec and then initialise the cipher as above.
opmode
- the operation mode of this cipher (this is either
ENCRYPT_MODE or DECRYPT_MODE)key
- the encryption keyparams
- the algorithm parametersrandom
- the source of randomnessprotected byte[] engineUpdate(byte[] input, int inputOff, int inputLen)
The first inputLen bytes in the input buffer, starting at inputOffset, are processed, and the result is stored in a new buffer.
input
- the input bufferinputOffset
- the offset in input where the input startsinputLen
- the input lengthprotected int engineUpdate(byte[] input, int inputOff, int inputLen, byte[] output, int outputOff) throws ShortBufferException
The first inputLen bytes in the input buffer, starting at inputOffset, are processed, and the result is stored in the output buffer, starting at outputOffset.
If the output buffer is too small to hold the result, a ShortBufferException is thrown. In this case, repeat this call with a larger output buffer. Use getOutputSize to determine how big the output buffer should be.
input
- the input bufferinputOffset
- the offset in input where the input startsinputLen
- the input lengthoutput
- the buffer for the resultoutputOffset
- the offset in output where the result is storedprotected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException
The first inputLen bytes in the input buffer, starting at inputOffset, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in a new buffer.
The cipher is reset to its initial state (uninitialised) after this call.
input
- the input bufferinputOffset
- the offset in input where the input startsinputLen
- the input lengthprotected int engineDoFinal(byte[] input, int inputOff, int inputLen, byte[] output, int outputOff) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
The first inputLen bytes in the input buffer, starting at inputOffset, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in the output buffer, starting at outputOffset.
If the output buffer is too small to hold the result, a ShortBufferException is thrown. In this case, repeat this call with a larger output buffer. Use getOutputSize to determine how big the output buffer should be.
input
- the input bufferinputOffset
- - the offset in input where the input startsinputLen
- - the input lengthoutput
- - the buffer for the resultoutputOffset
- - the offset in output where the result is storedprotected abstract void initCipher(int opmode, byte[] salt, int iteration, char[] password)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |