All Packages Class Hierarchy This Package Previous Next Index
Class au.net.aba.crypto.provider.PBE
java.lang.Object
|
+----javax.crypto.CipherSpi
|
+----au.net.aba.crypto.provider.PBE
- public abstract class PBE
- extends CipherSpi
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.
-
cipher
-
-
ident
-
-
PBE(String)
-
-
engineDoFinal(byte[], int, int)
- Encrypts or decrypts data in a single-part operation, or
finishes a multiple-part operation.
-
engineDoFinal(byte[], int, int, byte[], int)
- Encrypts or decrypts data in a single-part operation, or finishes
a multiple-part operation.
-
engineGetBlockSize()
- Returns the block size (in bytes).
-
engineGetIV()
- Returns the initialisation vector (IV) in a new buffer.
-
engineGetOutputSize(int)
- 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).
-
engineGetParameters()
- Returns the parameters used with this cipher.
-
engineInit(int, Key, AlgorithmParameters, SecureRandom)
- Initialises this cipher with a key, a set of algorithm parameters,
and a source of randomness.
-
engineInit(int, Key, AlgorithmParameterSpec, SecureRandom)
- Initialises this cipher with a key, a set of algorithm parameters,
and a source of randomness.
-
engineInit(int, Key, SecureRandom)
- Initialises this cipher with a key and a source of randomness.
-
engineSetMode(String)
- Sets the mode of this cipher.
-
engineSetPadding(String)
- Sets the padding mechanism of this cipher.
-
engineUpdate(byte[], int, int)
- Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialised), processing another
data part.
-
engineUpdate(byte[], int, int, byte[], int)
- Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialised), processing another
data part.
-
initCipher(int, byte[], int, char[])
- This method is provided by the specific implementation
to create the digest from the password and the algorithm
parameters.
ident
public static final String ident
cipher
protected Cipher cipher
PBE
protected PBE(String cipherName)
engineSetMode
protected void engineSetMode(String mode) throws NoSuchAlgorithmException
- Sets the mode of this cipher. Generally PBE ciphers only
operate in a single mode and so this method will throw
an exception.
- Parameters:
- mode - the cipher mode
- Throws: NoSuchAlgorithmException
- if the requested cipher mode
does not exist
- Overrides:
- engineSetMode in class CipherSpi
engineSetPadding
protected void engineSetPadding(String padding) throws NoSuchPaddingException
- Sets the padding mechanism of this cipher. Generally PBE
ciphers only operate in a single mode and so this method will
throw an exception.
- Parameters:
- padding - the padding mechanism
- Throws: NoSuchPaddingException
- if the requested padding
mechanism does not exist.
- Overrides:
- engineSetPadding in class CipherSpi
engineGetBlockSize
protected int engineGetBlockSize()
- Returns the block size (in bytes). This method will return
the block size of the underlying Cipher.
- Returns:
- the block size (in bytes), or 0 if the underlying
algorithm is not a block cipher
- Overrides:
- engineGetBlockSize in class CipherSpi
engineGetOutputSize
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).
This method will return a result based on the underlying cipher.
- Parameters:
- inputLen - the input length (in bytes)
- Returns:
- the required output buffer size (in bytes)
- Overrides:
- engineGetOutputSize in class CipherSpi
engineGetIV
protected byte[] engineGetIV()
- Returns the initialisation vector (IV) in a new buffer.
This is useful in the context of password-based encryption or
decryption, where the IV is derived from a user-provided passphrase.
- Returns:
- the initialisation vector in a new buffer, or null if the
underlying algorithm does not use an IV, or if the IV has
not yet been set.
- Overrides:
- engineGetIV in class CipherSpi
engineGetParameters
protected AlgorithmParameters engineGetParameters()
- Returns the parameters used with this cipher.
Currently, the PBE ciphers do not support this method.
- Returns:
- the parameters used with this cipher, or null if this cipher
does not use any parameters.
- Overrides:
- engineGetParameters in class CipherSpi
engineInit
protected void engineInit(int opmode,
Key key,
SecureRandom random) throws InvalidKeyException
- Initialises this cipher with a key and a source of randomness.
This method of initialisation is not supported for PBE ciphers
as they require parameterisation that cannot be generated
by the cipher.
- Overrides:
- engineInit in class CipherSpi
engineInit
protected void engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
- Initialises this cipher with a key, a set of algorithm parameters,
and a source of randomness.
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.
- Parameters:
- opmode - the operation mode of this cipher (this is either
ENCRYPT_MODE or DECRYPT_MODE)
- key - the encryption key
- params - the algorithm parameters
- random - the source of randomness
- Throws: InvalidKeyException
- if the given key is not a PBEKey
- Throws: InvalidAlgorithmParameterException
- if the given algorithm
parameter instance is not a PBEParameterSpec.
- Overrides:
- engineInit in class CipherSpi
engineInit
protected void engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
- Initialises this cipher with a key, a set of algorithm parameters,
and a source of randomness.
Attempts to convert the supplied algorithm parameters into a
PBEParameterSpec and then initialise the cipher as above.
- Parameters:
- opmode - the operation mode of this cipher (this is either
ENCRYPT_MODE or DECRYPT_MODE)
- key - the encryption key
- params - the algorithm parameters
- random - the source of randomness
- Throws: InvalidKeyException
- if the given key is
not a PBEKey
- Throws: InvalidAlgorithmParameterException
- if the given algorithm
parameters cannot be converted into a PBEParameterSpec
- Overrides:
- engineInit in class CipherSpi
engineUpdate
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.
The first inputLen bytes in the input buffer, starting at
inputOffset, are processed, and the result is stored in a new buffer.
- Parameters:
- input - the input buffer
- inputOffset - the offset in input where the input starts
- inputLen - the input length
- Returns:
- the new buffer with the result, or null if the underlying
cipher is a block cipher and the input data is too short to
result in a new block.
- Overrides:
- engineUpdate in class CipherSpi
engineUpdate
protected int engineUpdate(byte input[],
int inputOff,
int inputLen,
byte output[],
int outputOff) throws ShortBufferException
- Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialised), processing another
data part.
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.
- Parameters:
- input - the input buffer
- inputOffset - the offset in input where the input starts
- inputLen - the input length
- output - the buffer for the result
- outputOffset - the offset in output where the result is stored
- Returns:
- the number of bytes stored in output
- Throws: ShortBufferException
- if the given output buffer is too
small to hold the result
- Overrides:
- engineUpdate in class CipherSpi
engineDoFinal
protected byte[] engineDoFinal(byte input[],
int inputOffset,
int inputLen) throws IllegalBlockSizeException, BadPaddingException
- Encrypts or decrypts data in a single-part operation, or
finishes a multiple-part operation. The data is encrypted or
decrypted, depending on how this cipher was initialised.
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.
- Parameters:
- input - the input buffer
- inputOffset - the offset in input where the input starts
- inputLen - the input length
- Returns:
- the new buffer with the result
- Throws: IllegalBlockSizeException
- if this cipher is a block
cipher, no padding has been requested (only in encryption
mode), and the total input length of the data processed by
this cipher is not a multiple of block size
- Throws: BadPaddingException
- if this cipher is in decryption mode,
and (un)padding has been requested, but the decrypted data is
not bounded by the appropriate padding bytes.
- Overrides:
- engineDoFinal in class CipherSpi
engineDoFinal
protected int engineDoFinal(byte input[],
int inputOff,
int inputLen,
byte output[],
int outputOff) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
- Encrypts or decrypts data in a single-part operation, or finishes
a multiple-part operation. The data is encrypted or decrypted,
depending on how this cipher was initialised.
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.
- Parameters:
- input - the input buffer
- inputOffset - - the offset in input where the input starts
- inputLen - - the input length
- output - - the buffer for the result
- outputOffset - - the offset in output where the result is stored
- Returns:
- s the number of bytes stored in output
- Throws: IllegalBlockSizeException
- if this cipher is a block
cipher, no padding has been requested (only in encryption mode),
and the total input length of the data processed by this cipher
is not a multiple of block size
- Throws: ShortBufferException
- if the given output buffer is too
small to hold the result
- Throws: BadPaddingException
- if this cipher is in decryption mode,
and (un)padding has been requested, but the decrypted data is
not bounded by the appropriate padding bytes
- Overrides:
- engineDoFinal in class CipherSpi
initCipher
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. This digest is then used to create the
SecretKey and the IV for the cipher.
All Packages Class Hierarchy This Package Previous Next Index