* @throws InvalidKeySpecException
*/
public static PublicKey getECPublicKeyWithParams(final PublicKey pk, final String keySpec) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {
PublicKey ret = pk;
if ( (pk instanceof PublicKeyEC) && (keySpec != null) ) {
final PublicKeyEC pkec = (PublicKeyEC) pk;
// The public key of IS and DV certificate do not have any parameters so we have to do some magic to get a complete EC public key
final ECParameterSpec spec = pkec.getParams();
if (spec == null) {
// we did not have the parameter specs, lets create them because we know which curve we are using
final org.bouncycastle.jce.spec.ECParameterSpec bcspec = ECNamedCurveTable.getParameterSpec(keySpec);
final java.security.spec.ECPoint p = pkec.getW();
final org.bouncycastle.math.ec.ECPoint ecp = EC5Util.convertPoint(bcspec.getCurve(), p, false);
final ECPublicKeySpec pubKey = new ECPublicKeySpec(ecp, bcspec);
final KeyFactory keyfact = KeyFactory.getInstance("ECDSA", "BC");
ret = keyfact.generatePublic(pubKey);
}