In fact I encounter the same problem now same like you. I suppose I can only use j2me version of bouncy castle (which contains jce.provider package) for mobile development but not jdk version.
I have a keystore of type bks generated by keytool IUI. I want to retrieve the private and public keys and convert them them to ECPrivateKeyParameters and ECPublicKeyParameters objects. the following code has two problem:
Code:
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
KeyStore ks = KeyStore.getInstance("BKS", "BC");
ks.load(new FileInputStream(args[0]), args[1].toCharArray());
Key key = ks.getKey(alias, password);
if (key instanceof PrivateKey) {
// Get certificate of public key
java.security.cert.Certificate cert = keystore.getCertificate(alias);
// Get public key
PublicKey publicKey = cert.getPublicKey();
// Return a key pair
return new KeyPair(publicKey, (PrivateKey)key);
}
first I don't have org.bouncycastle.jce under j2me version so I can't get bouncy castle provider.
second how can' I convert PublicKey and PrivateKey into ECPublicKeyParameters and ECPrivateKeyParameters so I can use them for EC encryption/decryption?
please help?