• 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
Jun 25, 2010
1
0
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?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones