KeyStore keyStore = KeyStore.getInstance("BKS");
keyStore.load(null, keyStorePass.toCharArray());
keyStore.setCertificateEntry("ECCert", chain[0]);
JCEECPrivateKey privateECKey = (JCEECPrivateKey)kp.getPrivate();
keyStore.setKeyEntry("ECPrivKey", privateECKey, keyStorePass
.toCharArray(), chain);
// Test ec sign / verify
JCEECPublicKey pub = (JCEECPublicKey)kp.getPublic();
String oldPrivateKey = new String(Hex.encode(privateECKey.getEncoded()));
String oldPublicKey = new String(Hex.encode(pub.getEncoded()));
JCEECPrivateKey newKey = (JCEECPrivateKey)keyStore.getKey("ECPrivKey",
keyStorePass.toCharArray());
JCEECPublicKey newPubKey = (JCEECPublicKey)keyStore.getCertificate(
"ECCert").getPublicKey();
if (!compress)
{
newKey.setPointFormat("UNCOMPRESSED");
newPubKey.setPointFormat("UNCOMPRESSED");
}
String newPrivateKey = new String(Hex.encode(newKey.getEncoded()));
String newPublicKey = new String(Hex.encode(newPubKey.getEncoded()));
if (!oldPrivateKey.equals(newPrivateKey))
{
fail("failed private key comparison");