//
// private key encoding test
//
byte[] privEnc = aKeyPair.getPrivate().getEncoded();
PKCS8EncodedKeySpec privPKCS8 = new PKCS8EncodedKeySpec(privEnc);
ECPrivateKey privKey = (ECPrivateKey)keyFac.generatePrivate(privPKCS8);
if (!privKey.getD().equals(((ECPrivateKey)aKeyPair.getPrivate()).getD()))
{
return new SimpleTestResult(false, getName() + ": private key encoding (D test) failed");
}
if (!(privKey.getParameters() instanceof ECNamedCurveParameterSpec))
{
return new SimpleTestResult(false, getName() + ": private key encoding not named curve");
}
if (!((ECNamedCurveParameterSpec)privKey.getParameters()).getName().equals(name))
{
return new SimpleTestResult(false, getName() + ": private key encoding wrong named curve");
}
return new SimpleTestResult(true, getName() + ": Okay");