我正在使用SpongyCastle(为Android完全实现BouncyCastle的加密函数),并且我有一个包含大小为384的密钥的bks。我尝试使用方法KeyStore.getKey(别名,密码)提取该密钥,就像密钥库中的任何密钥。 但我遇到的是错误
java.security.UnrecoverableKeyException: no match 。
做一点研究表明,这可能是因为Android的密钥太大,无法处理,这是有道理的,因为我的程序获得128和256大小的其他密钥没有问题。 通常在Java中,这可以通过将“Unlimited Strength”JCE导入Java安全文件夹来解决,但android呢? 我可以将无限强度的JCE导入到android中(我的直觉是否定的)如果没有,是否有关于如何提取密钥的建议? SpongyCastle解决了很多其他问题,我希望这里也有SpongyCastle解决方案。
谢谢!
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!
最满意答案
所以经过多次摔角之后,我发现了这个问题。
我没有指定提供程序,所以我的程序默认为默认的Android BouncyCastle。 我做的那一分钟
KeyStore ks = new KeyStore("BKS","SC");而不是
KeyStore ks = new KeyStore("BKS");它工作得很好,没有抱怨。
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.
更多推荐
发布评论