Top Description Fields Constructors Methods
org.bouncycastle.crypto.modes

public Class CTSBlockCipher

extends DefaultBufferedBlockCipher
Class Inheritance
Imports
org.bouncycastle.crypto.BlockCipher, .DataLengthException, .DefaultBufferedBlockCipher, .InvalidCipherTextException, .OutputLengthException, .StreamBlockCipher

A Cipher Text Stealing (CTS) mode cipher. CTS allows block ciphers to be used to produce cipher text which is the same length as the plain text.

Field Summary

Modifier and TypeField and Description
private int
Inherited from org.bouncycastle.crypto.DefaultBufferedBlockCipher:
bufbufOffcipherforEncryptionmbCipherpartialBlockOkaypgpCFB

Constructor Summary

AccessConstructor and Description
public
CTSBlockCipher(BlockCipher
the underlying block cipher this buffering object wraps.
cipher
)

Create a buffered block cipher that uses Cipher Text Stealing

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of output bytes copied to out.
doFinal
(byte[]
the array the block currently being held is copied into.
out
,
int
the offset at which the copying starts.
outOff
)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.doFinal.

Process the last block in the buffer.
public int

Returns:

the space required to accommodate a call to update and doFinal with len bytes of input.
getOutputSize
(int
the length of the input.
len
)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.getOutputSize.

return the size of the output buffer required for an update plus a doFinal with an input of len bytes.
public int

Returns:

the space required to accommodate a call to update with len bytes of input.
getUpdateOutputSize
(int
the length of the input.
len
)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.getUpdateOutputSize.

return the size of the output buffer required for an update an input of len bytes.
public int

Returns:

the number of output bytes copied to out.
processByte
(byte
the input byte.
in
,
byte[]
the space for any output that might be produced.
out
,
int
the offset from which the output will be copied.
outOff
)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.processByte.

process a single byte, producing an output block if necessary.
public int

Returns:

the number of output bytes copied to out.
processBytes
(byte[]
the input byte array.
in
,
int
the offset at which the input data starts.
inOff
,
int
the number of bytes to be copied out of the input array.
len
,
byte[]
the space for any output that might be produced.
out
,
int
the offset from which the output will be copied.
outOff
)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.processBytes.

process an array of bytes, producing output if necessary.
Inherited from org.bouncycastle.crypto.DefaultBufferedBlockCipher:
getBlockSizegetUnderlyingCipherinitreset

Field Detail

blockSizeback to summary
private int blockSize

Constructor Detail

CTSBlockCipherback to summary
public CTSBlockCipher(BlockCipher cipher)

Create a buffered block cipher that uses Cipher Text Stealing

Parameters
cipher:BlockCipher

the underlying block cipher this buffering object wraps.

Method Detail

doFinalback to summary
public int doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException, InvalidCipherTextException

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.doFinal.

Process the last block in the buffer.

Parameters
out:byte[]

the array the block currently being held is copied into.

outOff:int

the offset at which the copying starts.

Returns:int

the number of output bytes copied to out.

Exceptions
DataLengthException:
if there is insufficient space in out for the output.
IllegalStateException:
if the underlying cipher is not initialised.
InvalidCipherTextException:
if cipher text decrypts wrongly (in case the exception will never get thrown).
getOutputSizeback to summary
public int getOutputSize(int len)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.getOutputSize.

return the size of the output buffer required for an update plus a doFinal with an input of len bytes.

Parameters
len:int

the length of the input.

Returns:int

the space required to accommodate a call to update and doFinal with len bytes of input.

getUpdateOutputSizeback to summary
public int getUpdateOutputSize(int len)

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.getUpdateOutputSize.

return the size of the output buffer required for an update an input of len bytes.

Parameters
len:int

the length of the input.

Returns:int

the space required to accommodate a call to update with len bytes of input.

processByteback to summary
public int processByte(byte in, byte[] out, int outOff) throws DataLengthException, IllegalStateException

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.processByte.

process a single byte, producing an output block if necessary.

Parameters
in:byte

the input byte.

out:byte[]

the space for any output that might be produced.

outOff:int

the offset from which the output will be copied.

Returns:int

the number of output bytes copied to out.

Exceptions
DataLengthException:
if there isn't enough space in out.
IllegalStateException:
if the cipher isn't initialised.
processBytesback to summary
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException, IllegalStateException

Overrides org.bouncycastle.crypto.DefaultBufferedBlockCipher.processBytes.

process an array of bytes, producing output if necessary.

Parameters
in:byte[]

the input byte array.

inOff:int

the offset at which the input data starts.

len:int

the number of bytes to be copied out of the input array.

out:byte[]

the space for any output that might be produced.

outOff:int

the offset from which the output will be copied.

Returns:int

the number of output bytes copied to out.

Exceptions
DataLengthException:
if there isn't enough space in out.
IllegalStateException:
if the cipher isn't initialised.