Unlimited Strength Jce and Android

痞子三分冷 提交于 2019-12-23 17:48:17

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/7258016/unlimited-strength-jce-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!