{
if (bufOff == blockSize)
{
if ((outOff + 2 * blockSize) > out.length)
{
throw new DataLengthException("output buffer too short");
}
resultLen = cipher.processBlock(buf, 0, out, outOff);
bufOff = 0;
}
//
// add PKCS7 padding
//
byte code = (byte)(blockSize - bufOff);
while (bufOff < blockSize)
{
buf[bufOff] = code;
bufOff++;
}
resultLen += cipher.processBlock(buf, 0, out, outOff + resultLen);
}
else
{
if (bufOff == blockSize)
{
resultLen = cipher.processBlock(buf, 0, buf, 0);
bufOff = 0;
}
else
{
throw new DataLengthException("last block incomplete in decryption");
}
//
// remove PKCS7 padding
//