public void testKeyPairRawCodec(TestHarness harness)
{
harness.checkPoint("TestOfSRPCodec.testKeyPairRawCodec");
setUp();
SRPPublicKey pubK = (SRPPublicKey) kp.getPublic();
SRPPrivateKey secK = (SRPPrivateKey) kp.getPrivate();
byte[] pk1, pk2;
try
{ // an invalid format ID
pk1 = ((SRPPublicKey) pubK).getEncoded(0);
harness.fail("Succeeded with unknown format ID");
}
catch (IllegalArgumentException x)
{
harness.check(true, "Recognised unknown format ID");
}
pk1 = ((SRPPublicKey) pubK).getEncoded(IKeyPairCodec.RAW_FORMAT);
pk2 = ((SRPPrivateKey) secK).getEncoded(IKeyPairCodec.RAW_FORMAT);
IKeyPairCodec codec = new SRPKeyPairRawCodec();
PublicKey newPubK = codec.decodePublicKey(pk1);
PrivateKey newSecK = codec.decodePrivateKey(pk2);
harness.check(pubK.equals(newPubK),
"SRP public key Raw encoder/decoder test");
harness.check(secK.equals(newSecK),
"SRP private key Raw encoder/decoder test");
}