org.bouncycastle.crypto

Class BufferedAsymmetricBlockCipher

public class BufferedAsymmetricBlockCipher extends Object

a buffer wrapper for an asymmetric block cipher, allowing input to be accumulated in a piecemeal fashion until final processing.
Field Summary
protected byte[]buf
protected intbufOff
Constructor Summary
BufferedAsymmetricBlockCipher(AsymmetricBlockCipher cipher)
base constructor.
Method Summary
byte[]doFinal()
process the contents of the buffer using the underlying cipher.
intgetBufferPosition()
return the amount of data sitting in the buffer.
intgetInputBlockSize()
returns the largest size an input block can be.
intgetOutputBlockSize()
returns the maximum size of the block produced by this cipher.
AsymmetricBlockCiphergetUnderlyingCipher()
return the underlying cipher for the buffer.
voidinit(boolean forEncryption, CipherParameters params)
initialise the buffer and the underlying cipher.
voidprocessByte(byte in)
add another byte for processing.
voidprocessBytes(byte[] in, int inOff, int len)
add len bytes to the buffer for processing.
voidreset()
Reset the buffer and the underlying cipher.

Field Detail

buf

protected byte[] buf

bufOff

protected int bufOff

Constructor Detail

BufferedAsymmetricBlockCipher

public BufferedAsymmetricBlockCipher(AsymmetricBlockCipher cipher)
base constructor.

Parameters: cipher the cipher this buffering object wraps.

Method Detail

doFinal

public byte[] doFinal()
process the contents of the buffer using the underlying cipher.

Returns: the result of the encryption/decryption process on the buffer.

Throws: InvalidCipherTextException if we are given a garbage block.

getBufferPosition

public int getBufferPosition()
return the amount of data sitting in the buffer.

Returns: the amount of data sitting in the buffer.

getInputBlockSize

public int getInputBlockSize()
returns the largest size an input block can be.

Returns: maximum size for an input block.

getOutputBlockSize

public int getOutputBlockSize()
returns the maximum size of the block produced by this cipher.

Returns: maximum size of the output block produced by the cipher.

getUnderlyingCipher

public AsymmetricBlockCipher getUnderlyingCipher()
return the underlying cipher for the buffer.

Returns: the underlying cipher for the buffer.

init

public void init(boolean forEncryption, CipherParameters params)
initialise the buffer and the underlying cipher.

Parameters: forEncryption if true the cipher is initialised for encryption, if false for decryption. params the key and other data required by the cipher.

processByte

public void processByte(byte in)
add another byte for processing.

Parameters: in the input byte.

processBytes

public void processBytes(byte[] in, int inOff, int len)
add len bytes to the buffer for processing.

Parameters: in the input data inOff offset into the in array where the data starts len the length of the block to be processed.

reset

public void reset()
Reset the buffer and the underlying cipher.