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

public Class PaddedBlockCipher

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

Deprecated

use org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher instead.

A wrapper class that allows block ciphers to be used to process data in a piecemeal fashion with PKCS5/PKCS7 padding. The PaddedBlockCipher outputs a block only when the buffer is full and more data is being added, or on a doFinal (unless the current block in the buffer is a pad block). The padding mechanism used is the one outlined in PKCS5/PKCS7.

Field Summary

Inherited from org.bouncycastle.crypto.DefaultBufferedBlockCipher:
bufbufOffcipherforEncryptionmbCipherpartialBlockOkaypgpCFB

Constructor Summary

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

Create a buffered block cipher with, or without, padding.

Method Summary

Modifier and TypeMethod and Description
public int
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
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 neccessary.
public int
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

Constructor Detail

PaddedBlockCipherback to summary
public PaddedBlockCipher(BlockCipher cipher)

Create a buffered block cipher with, or without, padding.

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. If the buffer is currently full and padding needs to be added a call to doFinal will produce 2 * getBlockSize() bytes.

Parameters
out:byte[]

the array the block currently being held is copied into.

outOff:int

the offset at which the copying starts.

Returns:int

Doc from org.bouncycastle.crypto.DefaultBufferedBlockCipher.doFinal.

the number of output bytes copied to out.

Exceptions
DataLengthException:
if there is insufficient space in out for the output or we are decrypting and the input is not block size aligned.
IllegalStateException:
if the underlying cipher is not initialised.
InvalidCipherTextException:
if padding is expected and not found.
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 neccessary.

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

Doc from org.bouncycastle.crypto.DefaultBufferedBlockCipher.processByte.

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

Doc from org.bouncycastle.crypto.DefaultBufferedBlockCipher.processBytes.

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.