private void test4WeakKeys(TestHarness harness)
{
harness.checkPoint("TestOfDES.test4WeakKeys");
DES des = (DES) cipher;
String msg;
int i;
for (i = 0; i < DES.WEAK_KEYS.length; i++)
{
msg = "detecting weak key 0x" + Util.dumpString(DES.WEAK_KEYS[i]);
try
{
des.makeKey(DES.WEAK_KEYS[i], DES.KEY_SIZE);
harness.fail(msg);
}
catch (WeakKeyException x)
{
harness.check(true, msg);
}
catch (Exception x)
{
harness.debug(x);
harness.fail(msg + ": " + String.valueOf(x));
}
}
for (i = 0; i < DES.SEMIWEAK_KEYS.length; i++)
{
msg = "detecting semi-weak key 0x"
+ Util.dumpString(DES.SEMIWEAK_KEYS[i]);
try
{
des.makeKey(DES.SEMIWEAK_KEYS[i], DES.KEY_SIZE);
harness.fail(msg);
}
catch (WeakKeyException x)
{
harness.check(true, msg);
}
catch (Exception x)
{
harness.debug(x);
harness.fail(msg + ": " + String.valueOf(x));
}
}
for (i = 0; i < DES.POSSIBLE_WEAK_KEYS.length; i++)
{
msg = "detecting possible weak key 0x"
+ Util.dumpString(DES.POSSIBLE_WEAK_KEYS[i]);
try
{
des.makeKey(DES.POSSIBLE_WEAK_KEYS[i], DES.KEY_SIZE);
harness.fail(msg);
}
catch (WeakKeyException x)
{
harness.check(true, msg);