无法在 Windows x86 上使用 Java 验证在 Linux x64 上签名的数字签名

发布于 2024-12-27 05:13:19 字数 802 浏览 1 评论 0原文

我很难找到问题的原因。 问题的核心是 Signature.verify 总是返回 false。 在具有 x64 架构的 Linux 机器上创建签名,并在 Windows x86 上进行验证。

下面是用于签名的代码

Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initVerify(getPublicKey());

byte[] licenseeB = licensee.trim().toUpperCase().getBytes("UTF-8");
dsa.update(= merge(0, encodedLicenseB, licenseeB));            
return dsa.verify(signature);

这是用于签名的代码

byte[] encodedLicenseB = license.getEncoded();
byte[] licenseeB = license.getLicensee().trim().toUpperCase().getBytes("UTF-8");
Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initSign(getPrivateKey());
dsa.update(merge(0, encodedLicenseB, licenseeB));
byte[] signature = dsa.sign();

从 IDE 进行签名和验证代码始终有效。没有出现任何异常。

请分享任何想法。

谢谢 !

I'm having hard time to find the reason of the problem.
The core of the problem is that Signature.verify always returns false.
Signature created on Linux box with x64 architecture and I verify on Windows x86.

Below is the code for signing

Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initVerify(getPublicKey());

byte[] licenseeB = licensee.trim().toUpperCase().getBytes("UTF-8");
dsa.update(= merge(0, encodedLicenseB, licenseeB));            
return dsa.verify(signature);

This is code for signature

byte[] encodedLicenseB = license.getEncoded();
byte[] licenseeB = license.getLicensee().trim().toUpperCase().getBytes("UTF-8");
Signature dsa = Signature.getInstance("SHA1withDSA");
dsa.initSign(getPrivateKey());
dsa.update(merge(0, encodedLicenseB, licenseeB));
byte[] signature = dsa.sign();

Signing and verifying code on from IDE always works. No exceptions appears.

Please share any ideas.

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文