String modeName = Strings.toUpperCase(mode);
if (modeName.equals("ECB"))
{
ivLength = 0;
cipher = new PaddedBufferedBlockCipher(cipher.getUnderlyingCipher());
}
else if (modeName.equals("CBC"))
{
ivLength = cipher.getUnderlyingCipher().getBlockSize();
cipher = new PaddedBufferedBlockCipher(
new CBCBlockCipher(cipher.getUnderlyingCipher()));
}
else if (modeName.startsWith("OFB"))
{
ivLength = cipher.getUnderlyingCipher().getBlockSize();
if (modeName.length() != 3)
{
int wordSize = Integer.parseInt(modeName.substring(3));
cipher = new PaddedBufferedBlockCipher(
new OFBBlockCipher(cipher.getUnderlyingCipher(), wordSize));
}
else
{
cipher = new PaddedBufferedBlockCipher(
new OFBBlockCipher(cipher.getUnderlyingCipher(), 8 * cipher.getBlockSize()));
}
}
else if (modeName.startsWith("CFB"))
{
ivLength = cipher.getUnderlyingCipher().getBlockSize();
if (modeName.length() != 3)
{
int wordSize = Integer.parseInt(modeName.substring(3));
cipher = new PaddedBufferedBlockCipher(
new CFBBlockCipher(cipher.getUnderlyingCipher(), wordSize));
}
else
{
cipher = new PaddedBufferedBlockCipher(
new CFBBlockCipher(cipher.getUnderlyingCipher(), 8 * cipher.getBlockSize()));
}
}
else
{