}
public TestResult perform()
{
byte[] out = new byte[input.length];
BufferedBlockCipher engine = new CTSBlockCipher(cipher);
engine.init(true, params);
int len = engine.processBytes(input, 0, input.length, out, 0);
try
{
engine.doFinal(out, len);
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": encryption exception - " + e.toString());
}
for (int i = 0; i != output.length; i++)
{
if (out[i] != output[i])
{
return new SimpleTestResult(false, getName() + ": failed encryption expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
}
}
engine.init(false, params);
len = engine.processBytes(output, 0, output.length, out, 0);
try
{
engine.doFinal(out, len);
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": decryption exception - " + e.toString());
}