//
byte[] pubEnc = pubKey.getEncoded();
KeyFactory keyFac = KeyFactory.getInstance(pubKey.getAlgorithm(), "BC");
X509EncodedKeySpec pubX509 = new X509EncodedKeySpec(pubEnc);
pubKey = (PublicKey)keyFac.generatePublic(pubX509);
pubEnc = pubKey.getEncoded();
keyFac = KeyFactory.getInstance(pubKey.getAlgorithm(), "BC");
pubX509 = new X509EncodedKeySpec(pubEnc);