Closed MaxApp closed 9 years ago
Did you ever find a resolution to this issue?
I was able to resolve this issue by using BouncyCastle 1.46
http://central.maven.org/maven2/org/bouncycastle/bcprov-jdk16/1.46/bcprov-jdk16-1.46.jar
I talked to the CryptoWorkshop team that built the BouncyCastle library and they gave me the following fix:
PEMParser pemReaderPublic = new PEMParser(new StringReader(ephemeralPubKeyStr));
SubjectPublicKeyInfo ephemeralPublicKeyInfo = (SubjectPublicKeyInfo)pemReaderPublic.readObject();
ECPublicKey ephemeralPublicKey = (ECPublicKey)new JcaPEMKeyConverter().setProvider("BC").getPublicKey(ephemeralPublicKeyInfo);
So many thanks,bentoo. I use the following code for retrieving ECPublicKey:
KeySpec keySpec = new X509EncodedKeySpec(ephemeralPublicKey_bytes);
KeyFactory keyFact = KeyFactory.getInstance("EC", Security.getProvider("BC"));
PublicKey pubKey = keyFact.generatePublic(keySpec);
ephemeralPublicKey = (ECPublicKey)pubKey;
that runs well
with bcprov-jdk16 (from 1.45 to 1.49 ) and bcpkix-jdk16 (from 1.45 to 1.49), running the following code:
the 'ephemeralPublicKey' was null. Debug into the code:
' PublicKey pubKey = keyFact.generatePublic(keySpec);' always fall into 'InvalidKeySpecException'