public class TestOfSRPKeyGeneration implements Testlet
{
public void test(TestHarness harness)
{
harness.checkPoint("TestOfSRPKeyGeneration");
SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
HashMap map = new HashMap();
map.put(SRPKeyPairGenerator.MODULUS_LENGTH, new Integer(530));
try
{
kpg.setup(map);
harness.fail("L should be >= 512, <= 2048 and of the form 512 + 256n");
}
catch (IllegalArgumentException x)
{
harness.check(true,
"L should be >= 512, <= 2048 and of the form 512 + 256n");
}
map.put(SRPKeyPairGenerator.MODULUS_LENGTH, new Integer(512));
map.put(SRPKeyPairGenerator.USE_DEFAULTS, Boolean.FALSE);
kpg.setup(map);
KeyPair kp = kpg.generate();
BigInteger N1 = ((SRPPublicKey) kp.getPublic()).getN();
BigInteger N2 = ((SRPPrivateKey) kp.getPrivate()).getN();
harness.check(N1.equals(N2), "N1.equals(N2)");