0
我想生成一個橢圓曲線私鑰,但我一直在android操作系統版本5和6上得到這個錯誤。下面是代碼生成與EC密碼學的PrivateKey 。Android:InvalidKeySpecException:橢圓曲線例程:EC_GROUP_new_by_curve_name:UNKNOWN_GROUP
private static java.security.PrivateKey createPrivateKey(List<PrivateKey> privateKeys, String appInstallationIdentifier) throws Exception {
PrivateKey privateKey = getPrivateKeyForActivation(privateKeys);
String key = decryptMessage(privateKey.getEncryptedPrivateKey(), appInstallationIdentifier, privateKey.getIv());
key = key.replace("-----BEGIN PRIVATE KEY-----", "")
.replace("-----END PRIVATE KEY-----", "")
.replaceAll("\\s", "");
byte[] privateKeyFileContent = decode(key);
KeyFactory keyFactory = KeyFactory.getInstance("EC");
PKCS8EncodedKeySpec ks = new PKCS8EncodedKeySpec(privateKeyFileContent);
return keyFactory.generatePrivate(ks);
}
這裏是我收到的OS版本5和6
java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0f06707b:elliptic curve routines:EC_GROUP_new_by_curve_name:UNKNOWN_GROUP
爲什麼我收到此錯誤,任何想法的錯誤? EC也應該從API級別11以上獲得支持,所以使用EC應該不成問題。