return engine.getAlgorithmName() + " Monte Carlo Test " + id;
}
public TestResult perform()
{
BufferedBlockCipher cipher = new BufferedBlockCipher(engine);
cipher.init(true, param);
byte[] out = new byte[input.length];
System.arraycopy(input, 0, out, 0, out.length);
for (int i = 0; i != iterations; i++)
{
int len1 = cipher.processBytes(out, 0, out.length, out, 0);
try
{
cipher.doFinal(out, len1);
}
catch (CryptoException e)
{
return new SimpleTestResult(false,
getName() + ": failed - exception " + e.toString());
}
}
if (!isEqualArray(out, output))
{
return new SimpleTestResult(false,
getName() + ": failed - " + "expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
}
cipher.init(false, param);
for (int i = 0; i != iterations; i++)
{
int len1 = cipher.processBytes(out, 0, out.length, out, 0);
try
{
cipher.doFinal(out, len1);
}
catch (CryptoException e)
{
return new SimpleTestResult(false,
getName() + ": failed reversal - exception " + e.toString());