• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to generate EC Keys

furrbie

Lurker
Hi,

I am new to Android development and am trying to implement a simple application that does elliptic curve cryptography using the BouncyCastle libraries, which I understand that Android supports.

I have the following line of code that I use to get an instance of a KeyFactory object that works on my laptop but throws an NoSuchAlgorithmException when I try running on my Nexus One Android phone (running SDK 2.1):

PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedKey);
KeyFactory kf = KeyFactory.getInstance("ECDH", "BC"); // throws NoSuchAlgorithmException() - "KeyFactory ECDH implementation not found"
ECPrivateKey pk = (ECPrivateKey) kf.generatePrivate(privateKeySpec);
What should I do get an instance of KeyFactory that supports ECKey generation? Or is there some other way to create an ECKey object?
 
Back
Top Bottom