验证和解密使用 pvk.key 和 BouncyCastle 加密 api 生成的签名
我有一个小程序,它使用“foo.key”文件和字符串密码来生成 privateKey 对象,并使用 BouncyCastle api。然后使用此 privateKey 对象和字符串(例如“MYNAMEHERE”)创建签名。我所知道的是用于生成此签名的算法是 RSA。
我想要做的是在 PHP 中解密(或验证)这个签名。我有两个文件 publicKey (file.cer) 和 privateKey (file.key),用于在 Java 中生成 privateKey 对象。
我尝试在 PHP 中使用 openssl_verify 函数,传递值:
openssl_verify("MYNAMEHERE", $signature, "file.cer"),其中 $signature 包含 Java 中生成的签名对象的字符串表示形式:new String (signature)。
我不知道这个过程是否正确验证签名,或者在使用这个功能之前我必须执行什么样的编码/解码过程。
我希望有人指出我正确的方向!
提前致谢!
I have an applet that uses a "foo.key" file and a string password to generate a privateKey object, using BouncyCastle apis. Then a signature is created using this privateKey object and a string such as "MYNAMEHERE". All I know is that the algorythm used to generate this signature is RSA.
What I want to do is to decrypt (or verify) this signature in PHP. I have both files publicKey (file.cer) and privateKey (file.key) that where used to generate the privateKey object in Java.
Im trying using the openssl_verify functions in PHP, passing the values:
openssl_verify("MYNAMEHERE", $signature, "file.cer"), where $signature contains the String representation of the signature object generated in Java: new String (signature).
I dont know if this process is correct to verify the signature, or what kind of encoding/decoding process i have to do before using this function.
I hope somebody points me the right direction!
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有提供足够的信息,例如实际签名或其编码方式。通常,RSA 是指使用 SHA-1(Google it)的 PKCS#1 1.5 模式下的 RSA,这或多或少是当今使用的默认签名生成/验证算法。在这种情况下,验证应按照您的描述进行。不再需要密码,它可能只是用于解密私钥。您仍然可以使用私钥来查看 PHP/openssl 中的登录是否确实创建了相同的数据。如果不是,则可能使用了不同的哈希或 PKCS#1 v2.1 签名。
You haven't given enough information, such as the actual signature or how it is encoded. Normally RSA means RSA in PKCS#1 1.5 mode using SHA-1 (Google it) which is more or less the default signature generation/verification algorithm in use today. In that case, the verify should proceed as you've described. The password is not needed anymore, it might just be used to decrypt the private key. You can still use the private key to see if an sign in PHP/openssl does create the same data. If not, a different hash or PKCS#1 v2.1 signature may have been used.