自 Android 2.3 起 PSS 签名验证失败
在我的应用程序中,我使用 SHA1 和 RSA 验证通过概率签名方案 (PSS) 签名的文件的数字签名。签名是在 BouncyCastle 的帮助下在 J2SE 中创建的。
在 Android 应用程序中,此验证到目前为止运行良好(例如 2.1、2.2)。在 Android 2.3 设备/模拟器上测试应用程序时,我收到 NoSuchAlgorithmException。
NoSuchAlgorithmException: Signature SHA1withRSA/PSS implementation not found
我用于验证签名的相关代码如下:
Signature signature = Signature.getInstance("SHA1withRSA/PSS", "BC");
signature.setParameter(new PSSParameterSpec(64));
signature.initVerify(thePublicKey);
signature.update(theMessage.getBytes());
boolean signatureIsValid = signature.verify(theSignature);
自Android 2.2以来发生了什么,为什么从“BC”提供程序中删除了算法“SHA1withRSA/PSS”?
有人有替代方案(最多适用于所有 Android 版本)吗?
谢谢你!
In my app, I am verifying the digital signature of a file signed with the Probabilistic Signature Scheme (PSS) using SHA1 and RSA. The signatures are created in J2SE with the help of BouncyCastle.
In the Android app this verification worked fine so far (e.g., 2.1, 2.2). When testing the app on Android 2.3 devices/simulator I receive a NoSuchAlgorithmException.
NoSuchAlgorithmException: Signature SHA1withRSA/PSS implementation not found
The relevant code I use for verifying the signature is the following:
Signature signature = Signature.getInstance("SHA1withRSA/PSS", "BC");
signature.setParameter(new PSSParameterSpec(64));
signature.initVerify(thePublicKey);
signature.update(theMessage.getBytes());
boolean signatureIsValid = signature.verify(theSignature);
What happened since Android 2.2, why was the algorithm "SHA1withRSA/PSS" removed from the "BC" provider?
Does anybody have a alternative (which at best works with all Android versions)?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我设法让 PSS 签名正常工作的唯一方法是将我的签名提供程序切换到 Spongy Castle。
快速操作方法:
在签名类中的某处添加以下行
静态{
Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
}
在 getInstance() 中将 BC 替换为 SC
Signaturesignature = Signature.getInstance("SHA1withRSA/PSS", "SC");
缺点:您的二进制文件将包含额外的 1.5mb。
The only way I managed to get PSS Signatures working was by switching my signature provider to Spongy Castle.
Quick how-to:
Add the following line somewhere in your signing class
static {
Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
}
Replace your BC with SC in getInstance()
Signature signature = Signature.getInstance("SHA1withRSA/PSS", "SC");
The downside: Your binary will include a bonus 1.5mb.
我面临着同样的问题。将 Bouncy Castle 移植到 Android 上,自己动手是唯一的方法吗?
I'm facing the same problem. Is do-it-yourself-way by porting Bouncy Castle to Android the only way?