Search code examples
javaandroidsecuritybouncycastlespongycastle

Spongycastle provider not working on Android


I am trying to use Spongy Castle on my Android application. As per these instructions, I have added the jar files and then called this method to include provider.

static {
    Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
}

But I still get the error on this line:

KeyStore keyStore = KeyStore.getInstance("SC");

The Exception I get is this:

java.security.KeyStoreException: KeyStore SC implementation not found

I have spent several hours on this and I cannot figure out what I have missed.


Solution

  • If you use Eclipse, I recommended you download this example and compile it. Based on the example, "SC" is not a KeyStore.

    If you need another example, there is a good tutorial here (ECDH - Elliptic Curve Diffie Hellman on Android).