int outOff)
throws DataLengthException, IllegalStateException, InvalidCipherTextException
{
if (bufOff + outOff > out.length)
{
throw new DataLengthException("output buffer to small in doFinal");
}
int blockSize = cipher.getBlockSize();
int len = bufOff - blockSize;
byte[] block = new byte[blockSize];
if (forEncryption)
{
cipher.processBlock(buf, 0, block, 0);
if (bufOff < blockSize)
{
throw new DataLengthException("need at least one block of input for CTS");
}
for (int i = bufOff; i != buf.length; i++)
{
buf[i] = block[i - blockSize];