"1CDEC1D10BD749090B1F491A4FC8E2F8B150D64F3215CE8F" };
public void test(TestHarness harness)
{
harness.checkPoint("TestOfTiger");
algorithm = new Tiger();
try
{
harness.check(algorithm.selfTest(), "selfTest");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.selfTest");
}
try
{
algorithm.update("a".getBytes(), 0, 1);
byte[] md = algorithm.digest();
String exp = "77BEFBEF2E7EF8AB2EC8F93BF587A7FC613E247F5F247809";
harness.check(exp.equals(Util.toString(md)), "testA");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testA");
}
try
{
algorithm.update("abc".getBytes(), 0, 3);
byte[] md = algorithm.digest();
String exp = "2AAB1484E8C158F2BFB8C5FF41B57A525129131C957B5F93";
harness.check(exp.equals(Util.toString(md)), "testABC");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testABC");
}
try
{
algorithm.update("message digest".getBytes(), 0, 14);
byte[] md = algorithm.digest();
String exp = "D981F8CB78201A950DCF3048751E441C517FCA1AA55A29F6";
harness.check(exp.equals(Util.toString(md)), "testMessageDigest");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testMessageDigest");
}
try
{
algorithm.update("abcdefghijklmnopqrstuvwxyz".getBytes(), 0, 26);
byte[] md = algorithm.digest();
String exp = "1714A472EEE57D30040412BFCC55032A0B11602FF37BEEE9";
harness.check(exp.equals(Util.toString(md)), "testAlphabet");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testAlphabet");
}
try
{
algorithm.update(
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq".getBytes(),
0, 56);
byte[] md = algorithm.digest();
String exp = "0F7BF9A19B9C58F2B7610DF7E84F0AC3A71C631E7B53F78E";
harness.check(exp.equals(Util.toString(md)), "test56Chars");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.test56Chars");
}
try
{
algorithm.update(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
.getBytes(),
0, 62);
byte[] md = algorithm.digest();
String exp = "8DCEA680A17583EE502BA38A3C368651890FFBCCDC49A8CC";
harness.check(exp.equals(Util.toString(md)), "testAsciiSubset");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testAsciiSubset");
}
try
{
algorithm.update(
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
.getBytes(),
0, 80);
byte[] md = algorithm.digest();
String exp = "1C14795529FD9F207A958F84C52F11E887FA0CABDFD91BFD";
harness.check(exp.equals(Util.toString(md)), "testEightyNumerics");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testEightyNumerics");
}
try
{
for (int i = 0; i < 1000000; i++)
{
algorithm.update((byte) 'a');
}
byte[] md = algorithm.digest();
String exp = "6DB0E2729CBEAD93D715C6A7D36302E9B3CEE0D2BC314B41";
harness.check(exp.equals(Util.toString(md)), "testOneMillionA");
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testOneMillionA");
}
try
{
for (int i = 1; i < 128; i++)
{
algorithm.update(new byte[i], 0, i);
byte[] md = algorithm.digest();
harness.check(ZERO_BITS_ANSWERS[i - 1].equals(Util.toString(md)),
"test" + (i * 8) + "ZeroBits");
}
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testZeroBits");
}
try
{
byte[] input = new byte[64];
input[0] = (byte) 0x80;
for (int i = 0; i < SINGLE_BIT_ANSWERS.length; i++)
{
algorithm.update(input, 0, input.length);
byte[] md = algorithm.digest();
harness.check(SINGLE_BIT_ANSWERS[i].equals(Util.toString(md)),
"testSingleBit[" + i + "]");
shiftRight1(input);
}
}
catch (Exception x)
{
harness.debug(x);
harness.fail("TestOfTiger.testZeroBits");
}
try
{
algorithm = new Tiger();
algorithm.update("a".getBytes(), 0, 1);
clone = (IMessageDigest) algorithm.clone();
byte[] md = algorithm.digest();
String exp = "77BEFBEF2E7EF8AB2EC8F93BF587A7FC613E247F5F247809";
harness.check(exp.equals(Util.toString(md)), "testCloning #1");