return "RIPEMD320";
}
public TestResult perform()
{
Digest digest = new RIPEMD320Digest();
byte[] resBuf = new byte[digest.getDigestSize()];
for (int i = 0; i < messages.length; i++)
{
byte[] m = messages[i].getBytes();
digest.update(m, 0, m.length);
digest.doFinal(resBuf, 0);
if (!arraysEqual(resBuf, Hex.decode(digests[i])))
{
return new SimpleTestResult(false, getName() + ": Vector " + i + " failed");
}
}
//
// test 2
//
byte[] m = messages[messages.length-1].getBytes();
digest.update(m, 0, m.length/2);
// clone the Digest
Digest d = new RIPEMD320Digest((RIPEMD320Digest)digest);
digest.update(m, m.length/2, m.length - m.length/2);
digest.doFinal(resBuf, 0);
if (!arraysEqual(resBuf, Hex.decode(digests[digests.length-1])))
{
return new SimpleTestResult(false,
"RIPEMD320 failing clone test"
+ System.getProperty("line.separator")
+ " expected: " + digests[digests.length-1]
+ System.getProperty("line.separator")
+ " got : " + new String(Hex.encode(resBuf)));
}
d.update(m, m.length/2, m.length - m.length/2);
d.doFinal(resBuf, 0);
if (!arraysEqual(resBuf, Hex.decode(digests[digests.length-1])))
{
return new SimpleTestResult(false,
"RIPEMD320 failing clone test - part 2"