Question

I'm using SpongyCastle (full implementation of BouncyCastle's crypto functions for Android) and I have a bks that contains a key of size 384. I'm trying to extract that key using the method KeyStore.getKey(alias, password) as you would any key in a keystore. But what I'm running into is the error

java.security.UnrecoverableKeyException: no match.

Doing a little bit of research indicates that it might be because the key size is too big for Android to handle which makes sense as my program gets the other keys of sizes 128 and 256 no problem. Normally in Java, this would be resolved by importing the "Unlimited Strength" JCE into the Java security folder but what about android? Can I import the unlimited strength JCE into android (my gut instinct is no) If not, are there any suggestions as to how to extract the key? SpongyCastle has solved a lot of my other issues, I'm hoping there's a SpongyCastle solution here too.

Thanks!

Was it helpful?

Solution

So after much wrestling with it, I figured out the problem.

I wasn't specifying a provider so my program defaulted to the default Android BouncyCastle. The minute I did

KeyStore ks = new KeyStore("BKS","SC");

as opposed to

KeyStore ks = new KeyStore("BKS");

it worked just fine and did not complain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top