Top Description Fields Constructors Methods
org.bouncycastle.pqc.jcajce.provider.util

public abstract Class CipherSpiExt

extends CipherSpi
Class Inheritance
Known Direct Subclasses
org.bouncycastle.pqc.jcajce.provider.util.AsymmetricBlockCipher, org.bouncycastle.pqc.jcajce.provider.util.AsymmetricHybridCipher
Imports
java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .InvalidParameterException, .Key, .NoSuchAlgorithmException, .SecureRandom, java.security.spec.AlgorithmParameterSpec, javax.crypto.BadPaddingException, .CipherSpi, .IllegalBlockSizeException, .NoSuchPaddingException, .ShortBufferException

The CipherSpiExt class extends CipherSpi.

Field Summary

Modifier and TypeField and Description
public static final int
DECRYPT_MODE

Constant specifying decrypt mode.

public static final int
ENCRYPT_MODE

Constant specifying encrypt mode.

protected int
opMode

The operation mode for this cipher (ENCRYPT_MODE or DECRYPT_MODE).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final byte[]

Returns:

a new buffer with the result
doFinal
()

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

public final byte[]

Returns:

a new buffer with the result
doFinal
(byte[]
the input buffer
input
)

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

public abstract byte[]

Returns:

a new buffer with the result
doFinal
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
)

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

public abstract int

Returns:

the output length
doFinal
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
,
byte[]
the buffer for the result
output
,
int
the offset where the result is stored
outOff
)

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

protected final byte[]

Returns:

the byte array containing the en-/decrypted data
engineDoFinal
(byte[]
the byte array holding the data to be processed
input
,
int
the offset indicating the start position within the input byte array
inOff
,
int
the number of bytes to be processed
inLen
)

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Return the result of the last step of a multi-step en-/decryption operation or the result of a single-step en-/decryption operation by processing the given input data and any remaining buffered data.

protected final int

Returns:

the number of bytes stored in the output byte array
engineDoFinal
(byte[]
the byte array holding the data to be processed
input
,
int
the offset indicating the start position within the input byte array
inOff
,
int
the number of bytes to be processed
inLen
,
byte[]
the byte array for holding the result
output
,
int
the offset indicating the start position within the output byte array to which the en/decrypted data is written
outOff
)

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Perform the last step of a multi-step en-/decryption operation or a single-step en-/decryption operation by processing the given input data and any remaining buffered data.

protected final int

Returns:

the block size (in bytes), or 0 if the underlying algorithm is not a block cipher
engineGetBlockSize
()

Implements abstract javax.crypto.CipherSpi.engineGetBlockSize.

Returns the block size (in bytes).

protected final byte[]

Returns:

the initialization 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.
engineGetIV
()

Implements abstract javax.crypto.CipherSpi.engineGetIV.

Return the initialization vector.

protected final int

Returns:

the key size in bits of the given key object
engineGetKeySize
(Key
the key object
key
)

Overrides javax.crypto.CipherSpi.engineGetKeySize.

Return the key size of the given key object in bits.

protected final int

Returns:

the required output buffer size (in bytes)
engineGetOutputSize
(int
the input length (in bytes)
inLen
)

Implements abstract javax.crypto.CipherSpi.engineGetOutputSize.

Return 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 final AlgorithmParameters

Returns:

the parameters used with this cipher, or null if this cipher does not use any parameters.
engineGetParameters
()

Implements abstract javax.crypto.CipherSpi.engineGetParameters.

Returns the parameters used with this cipher.

protected final void
engineInit(int
the operation mode (ENCRYPT_MODE or DECRYPT_MODE)
opMode
,
Key
the key
key
,
SecureRandom
the random seed
random
)

Implements abstract javax.crypto.CipherSpi.engineInit.

Initialize this cipher object with a proper key and some random seed.

protected final void
engineInit(int
the operation mode (ENCRYPT_MODE or DECRYPT_MODE)
opMode
,
Key
the key
key
,
AlgorithmParameters
the algorithm parameters
algParams
,
SecureRandom
the random seed
random
)

Implements abstract javax.crypto.CipherSpi.engineInit.

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness.

protected void
engineInit(int
the operation mode (ENCRYPT_MODE or DECRYPT_MODE)
opMode
,
Key
the encryption key
key
,
AlgorithmParameterSpec
the algorithm parameters
params
,
SecureRandom
the source of randomness
javaRand
)

Implements abstract javax.crypto.CipherSpi.engineInit.

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness.

protected final void
engineSetMode(String
the cipher mode
modeName
)

Implements abstract javax.crypto.CipherSpi.engineSetMode.

Set the mode of this cipher.

protected final void
engineSetPadding(String
the padding scheme
paddingName
)

Implements abstract javax.crypto.CipherSpi.engineSetPadding.

Set the padding scheme of this cipher.

protected final byte[]

Returns:

the byte array containing the en-/decrypted data
engineUpdate
(byte[]
the byte array holding the data to be processed
input
,
int
the offset indicating the start position within the input byte array
inOff
,
int
the number of bytes to be processed
inLen
)

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Return the result of the next step of a multi-step en-/decryption operation.

protected final int

Returns:

the number of bytes that are stored in the output byte array
engineUpdate
(final byte[]
the byte array holding the data to be processed
input
,
final int
the offset indicating the start position within the input byte array
inOff
,
final int
the number of bytes to be processed
inLen
,
byte[]
the byte array for holding the result
output
,
final int
the offset indicating the start position within the output byte array to which the en-/decrypted data is written
outOff
)

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Perform the next step of a multi-step en-/decryption operation.

public abstract int

Returns:

the block size (in bytes), or 0 if the underlying algorithm is not a block cipher
getBlockSize
()

public abstract byte[]

Returns:

the initialization 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.
getIV
()

Return the initialization vector.

public abstract int

Returns:

the key size in bits of the given key object
getKeySize
(Key
the key object
key
)

Return the key size of the given key object in bits.

public abstract String

Returns:

the name of this cipher
getName
()

public abstract int

Returns:

the required output buffer size (in bytes)
getOutputSize
(int
the input length (in bytes)
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).

public abstract AlgorithmParameterSpec

Returns:

the parameters used with this cipher, or null if this cipher does not use any parameters.
getParameters
()

Returns the parameters used with this cipher.

public abstract void
initDecrypt(Key
the encryption key
key
,
AlgorithmParameterSpec
the cipher parameters
cipherParams
)

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness for decryption.

public abstract void
initEncrypt(Key
the encryption key
key
,
AlgorithmParameterSpec
the cipher parameters
cipherParams
,
SecureRandom
the source of randomness
random
)

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness for encryption.

protected abstract void
setMode(String
the cipher mode
mode
)

Set the mode of this cipher.

protected abstract void
setPadding(String
the padding mechanism
padding
)

Set the padding mechanism of this cipher.

public final byte[]

Returns:

a new buffer with the result (maybe an empty byte array)
update
(byte[]
the input buffer
input
)

Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

public abstract byte[]

Returns:

a new buffer with the result (maybe an empty byte array)
update
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
)

Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

public abstract int

Returns:

the length of the output
update
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
,
byte[]
the output buffer
output
,
int
the offset where the result is stored
outOff
)

Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

Inherited from javax.crypto.CipherSpi:
engineDoFinalengineUnwrapengineUpdateengineUpdateAADengineUpdateAADengineWrap

Field Detail

DECRYPT_MODEback to summary
public static final int DECRYPT_MODE

Constant specifying decrypt mode.

ENCRYPT_MODEback to summary
public static final int ENCRYPT_MODE

Constant specifying encrypt mode.

opModeback to summary
protected int opMode

The operation mode for this cipher (ENCRYPT_MODE or DECRYPT_MODE).

Constructor Detail

CipherSpiExtback to summary
public CipherSpiExt()

Method Detail

doFinalback to summary
public final byte[] doFinal() throws IllegalBlockSizeException, BadPaddingException

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

Returns:byte[]

a new buffer with the result

Exceptions
IllegalBlockSizeException:
if this cipher is a block cipher and the total input length is not a multiple of the block size (for encryption when no padding is used or for decryption).
BadPaddingException:
if this cipher is a block cipher and unpadding fails.
doFinalback to summary
public final byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

Parameters
input:byte[]

the input buffer

Returns:byte[]

a new buffer with the result

Exceptions
IllegalBlockSizeException:
if this cipher is a block cipher and the total input length is not a multiple of the block size (for encryption when no padding is used or for decryption).
BadPaddingException:
if this cipher is a block cipher and unpadding fails.
doFinalback to summary
public abstract byte[] doFinal(byte[] input, int inOff, int inLen) throws IllegalBlockSizeException, BadPaddingException

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

Returns:byte[]

a new buffer with the result

Exceptions
IllegalBlockSizeException:
if this cipher is a block cipher and the total input length is not a multiple of the block size (for encryption when no padding is used or for decryption).
BadPaddingException:
if this cipher is a block cipher and unpadding fails.
doFinalback to summary
public abstract int doFinal(byte[] input, int inOff, int inLen, byte[] output, int outOff) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

output:byte[]

the buffer for the result

outOff:int

the offset where the result is stored

Returns:int

the output length

Exceptions
ShortBufferException:
if the output buffer is too small to hold the result.
IllegalBlockSizeException:
if this cipher is a block cipher and the total input length is not a multiple of the block size (for encryption when no padding is used or for decryption).
BadPaddingException:
if this cipher is a block cipher and unpadding fails.
engineDoFinalback to summary
protected final byte[] engineDoFinal(byte[] input, int inOff, int inLen) throws IllegalBlockSizeException, BadPaddingException

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Return the result of the last step of a multi-step en-/decryption operation or the result of a single-step en-/decryption operation by processing the given input data and any remaining buffered data. The data to be processed is given in an input byte array. Beginning at inputOffset, only the first inputLen bytes are en-/decrypted, including any buffered bytes of a previous update operation. If necessary, padding is performed. The result is returned as a output byte array.

Parameters
input:byte[]

the byte array holding the data to be processed

inOff:int

the offset indicating the start position within the input byte array

inLen:int

the number of bytes to be processed

Returns:byte[]

the byte array containing the en-/decrypted data

Exceptions
IllegalBlockSizeException:
if the ciphertext length is not a multiple of the blocklength.
BadPaddingException:
if unpadding is not possible.
engineDoFinalback to summary
protected final int engineDoFinal(byte[] input, int inOff, int inLen, byte[] output, int outOff) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Perform the last step of a multi-step en-/decryption operation or a single-step en-/decryption operation by processing the given input data and any remaining buffered data. The data to be processed is given in an input byte array. Beginning at inputOffset, only the first inputLen bytes are en-/decrypted, including any buffered bytes of a previous update operation. If necessary, padding is performed. The result is stored in the given output byte array, beginning at outputOffset. The number of bytes stored in this byte array are returned.

Parameters
input:byte[]

the byte array holding the data to be processed

inOff:int

the offset indicating the start position within the input byte array

inLen:int

the number of bytes to be processed

output:byte[]

the byte array for holding the result

outOff:int

the offset indicating the start position within the output byte array to which the en/decrypted data is written

Returns:int

the number of bytes stored in the output byte array

Exceptions
ShortBufferException:
if the output buffer is too short to hold the output.
IllegalBlockSizeException:
if the ciphertext length is not a multiple of the blocklength.
BadPaddingException:
if unpadding is not possible.
engineGetBlockSizeback to summary
protected final int engineGetBlockSize()

Implements abstract javax.crypto.CipherSpi.engineGetBlockSize.

Doc from javax.crypto.CipherSpi.engineGetBlockSize.

Returns the block size (in bytes).

Returns:int

the block size (in bytes), or 0 if the underlying algorithm is not a block cipher

engineGetIVback to summary
protected final byte[] engineGetIV()

Implements abstract javax.crypto.CipherSpi.engineGetIV.

Return the initialization vector. This is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.

Returns:byte[]

the initialization 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.

engineGetKeySizeback to summary
protected final int engineGetKeySize(Key key) throws InvalidKeyException

Overrides javax.crypto.CipherSpi.engineGetKeySize.

Return the key size of the given key object in bits.

Parameters
key:Key

the key object

Returns:int

the key size in bits of the given key object

Exceptions
InvalidKeyException:
if key is invalid.
engineGetOutputSizeback to summary
protected final int engineGetOutputSize(int inLen)

Implements abstract javax.crypto.CipherSpi.engineGetOutputSize.

Return 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 call takes into account any unprocessed (buffered) data from a previous update call, and padding.

The actual output length of the next update or doFinal call may be smaller than the length returned by this method.

Parameters
inLen:int

the input length (in bytes)

Returns:int

the required output buffer size (in bytes)

engineGetParametersback to summary
protected final AlgorithmParameters engineGetParameters()

Implements abstract javax.crypto.CipherSpi.engineGetParameters.

Returns the parameters used with this cipher.

The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).

Returns:AlgorithmParameters

the parameters used with this cipher, or null if this cipher does not use any parameters.

engineInitback to summary
protected final void engineInit(int opMode, Key key, SecureRandom random) throws InvalidKeyException

Implements abstract javax.crypto.CipherSpi.engineInit.

Initialize this cipher object with a proper key and some random seed. Before a cipher object is ready for data processing, it has to be initialized according to the desired cryptographic operation, which is specified by the opMode parameter.

If this cipher (including its underlying mode or padding scheme) requires any random bytes, it will obtain them from random.

Note

If the mode needs an initialization vector, a blank array is used in this case.

Parameters
opMode:int

the operation mode (ENCRYPT_MODE or DECRYPT_MODE)

key:Key

the key

random:SecureRandom

the random seed

Exceptions
InvalidKeyException:
if the key is inappropriate for initializing this cipher.
engineInitback to summary
protected final void engineInit(int opMode, Key key, AlgorithmParameters algParams, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract javax.crypto.CipherSpi.engineInit.

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness. The cipher is initialized for encryption or decryption, depending on the value of opMode.

If this cipher (including its underlying mode or padding scheme) requires any random bytes, it will obtain them from random. Note that when a cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it.

Note

If the mode needs an initialization vector, a try to retrieve it from the AlgorithmParametersSpec is made.

Parameters
opMode:int

the operation mode (ENCRYPT_MODE or DECRYPT_MODE)

key:Key

the key

algParams:AlgorithmParameters

the algorithm parameters

random:SecureRandom

the random seed

Exceptions
InvalidKeyException:
if the key is inappropriate for initializing this block cipher.
InvalidAlgorithmParameterException:
if the parameters are inappropriate for initializing this block cipher.
engineInitback to summary
protected void engineInit(int opMode, Key key, AlgorithmParameterSpec params, SecureRandom javaRand) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract javax.crypto.CipherSpi.engineInit.

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness. The cipher is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opMode. If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random. Note that when a Cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it.

Parameters
opMode:int

the operation mode (ENCRYPT_MODE or DECRYPT_MODE)

key:Key

the encryption key

params:AlgorithmParameterSpec

the algorithm parameters

javaRand:SecureRandom

the source of randomness

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher
InvalidAlgorithmParameterException:
if the given algorithm parameters are inappropriate for this cipher, or if this cipher is being initialized for decryption and requires algorithm parameters and the parameters are null.
engineSetModeback to summary
protected final void engineSetMode(String modeName) throws NoSuchAlgorithmException

Implements abstract javax.crypto.CipherSpi.engineSetMode.

Set the mode of this cipher.

Parameters
modeName:String

the cipher mode

Exceptions
NoSuchAlgorithmException:
if neither the mode with the given name nor the default mode can be found
engineSetPaddingback to summary
protected final void engineSetPadding(String paddingName) throws NoSuchPaddingException

Implements abstract javax.crypto.CipherSpi.engineSetPadding.

Set the padding scheme of this cipher.

Parameters
paddingName:String

the padding scheme

Exceptions
NoSuchPaddingException:
if the requested padding scheme cannot be found.
engineUpdateback to summary
protected final byte[] engineUpdate(byte[] input, int inOff, int inLen)

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Return the result of the next step of a multi-step en-/decryption operation. The data to be processed is given in an input byte array. Beginning at inputOffset, only the first inputLen bytes are en-/decrypted. The result is returned as a byte array.

Parameters
input:byte[]

the byte array holding the data to be processed

inOff:int

the offset indicating the start position within the input byte array

inLen:int

the number of bytes to be processed

Returns:byte[]

the byte array containing the en-/decrypted data

engineUpdateback to summary
protected final int engineUpdate(final byte[] input, final int inOff, final int inLen, byte[] output, final int outOff) throws ShortBufferException

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Perform the next step of a multi-step en-/decryption operation. The data to be processed is given in an input byte array. Beginning at inputOffset, only the first inputLen bytes are en-/decrypted. The result is stored in the given output byte array, beginning at outputOffset. The number of bytes stored in this output byte array are returned.

Parameters
input:byte[]

the byte array holding the data to be processed

inOff:int

the offset indicating the start position within the input byte array

inLen:int

the number of bytes to be processed

output:byte[]

the byte array for holding the result

outOff:int

the offset indicating the start position within the output byte array to which the en-/decrypted data is written

Returns:int

the number of bytes that are stored in the output byte array

Exceptions
ShortBufferException:
if the output buffer is too short to hold the output.
getBlockSizeback to summary
public abstract int getBlockSize()
Returns:int

the block size (in bytes), or 0 if the underlying algorithm is not a block cipher

getIVback to summary
public abstract byte[] getIV()

Return the initialization vector. This is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.

Returns:byte[]

the initialization 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.

getKeySizeback to summary
public abstract int getKeySize(Key key) throws InvalidKeyException

Return the key size of the given key object in bits.

Parameters
key:Key

the key object

Returns:int

the key size in bits of the given key object

Exceptions
InvalidKeyException:
if key is invalid.
getNameback to summary
public abstract String getName()
Returns:String

the name of this cipher

getOutputSizeback to summary
public abstract int getOutputSize(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 call takes into account any unprocessed (buffered) data from a previous update call, and padding.

The actual output length of the next update or doFinal call may be smaller than the length returned by this method.

Parameters
inputLen:int

the input length (in bytes)

Returns:int

the required output buffer size (in bytes)

getParametersback to summary
public abstract AlgorithmParameterSpec getParameters()

Returns the parameters used with this cipher.

The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).

Returns:AlgorithmParameterSpec

the parameters used with this cipher, or null if this cipher does not use any parameters.

initDecryptback to summary
public abstract void initDecrypt(Key key, AlgorithmParameterSpec cipherParams) throws InvalidKeyException, InvalidAlgorithmParameterException

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness for decryption.

If this cipher requires any algorithm parameters and paramSpec is null, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and throw an InvalidAlgorithmParameterException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).

If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.

Note that when a cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it.

Parameters
key:Key

the encryption key

cipherParams:AlgorithmParameterSpec

the cipher parameters

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this block cipher.
InvalidAlgorithmParameterException:
if the parameters are inappropriate for initializing this block cipher.
initEncryptback to summary
public abstract void initEncrypt(Key key, AlgorithmParameterSpec cipherParams, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException

Initialize this cipher with a key, a set of algorithm parameters, and a source of randomness for encryption.

If this cipher requires any algorithm parameters and paramSpec is null, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and raise an InvalidAlgorithmParameterException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).

If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.

Note that when a cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it.

Parameters
key:Key

the encryption key

cipherParams:AlgorithmParameterSpec

the cipher parameters

random:SecureRandom

the source of randomness

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this block cipher.
InvalidAlgorithmParameterException:
if the parameters are inappropriate for initializing this block cipher.
setModeback to summary
protected abstract void setMode(String mode) throws NoSuchAlgorithmException

Set the mode of this cipher.

Parameters
mode:String

the cipher mode

Exceptions
NoSuchAlgorithmException:
if the requested mode cannot be found.
setPaddingback to summary
protected abstract void setPadding(String padding) throws NoSuchPaddingException

Set the padding mechanism of this cipher.

Parameters
padding:String

the padding mechanism

Exceptions
NoSuchPaddingException:
if the requested padding scheme cannot be found.
updateback to summary
public final byte[] update(byte[] input)

Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

Parameters
input:byte[]

the input buffer

Returns:byte[]

a new buffer with the result (maybe an empty byte array)

updateback to summary
public abstract byte[] update(byte[] input, int inOff, int inLen)

Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

Returns:byte[]

a new buffer with the result (maybe an empty byte array)

updateback to summary
public abstract int update(byte[] input, int inOff, int inLen, byte[] output, int outOff) throws ShortBufferException

Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

output:byte[]

the output buffer

outOff:int

the offset where the result is stored

Returns:int

the length of the output

Exceptions
ShortBufferException:
if the output buffer is too small to hold the result.