从公钥创建 256 字节 RSA 加密块
你好,我正在尝试编写一个 php 函数/类,它将连接到远程(java)服务器并向其发送一条已使用公钥用 256 字节 RSA 块编码的消息。
java服务器的github在这里:https://github.com/vexsoftware/votifier
(搜索:协议文档)。
这就是我发送数据的方式。现在我的问题是:
a)公钥是一个连续的字符串。
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsdG2qEpV74TQOwJEXU6BCBoXTLPXEG/Q5P3pkhpn433bStahMbqHROda7QgInfqMHvkAoFm84mNzckH+YsBRIiCRw3c7vYArWfGmmqIdr/NiLdS/pmNm2PnPDRpk/VadCwcOlSoCP6/RjUncMKqv0LW89DtCum5MrptDCkSrAgRP5ZOAHoBJehk6YW2jfpD2CfBpQsu9v7UNLkZ3ZnNxWNCKnkxiB6mqA7aDFh9J4XA+9amBC5oj/ZVfwHNiXq3IB4tMdgZsx/+DesS2mZ0ML78fCKXSOfT4xbfSlGGIyI7QsfqzB4Fh8d9WUuxADeFznTVfy185pGinOpbjDuH8+wIDAQAB
我在网上找到的每个功能都不能满足我的需要。
b) 如果您发送了错误的数据,服务器将返回一条默认消息;如果一切正常,服务器将返回一条 OK 消息(我在这里猜测)。
有谁知道如何制作这个 RSA 块?我的意思是它必须是 256 字节,我不知道如何用 PHP 计算字节(或者这并不重要? rsa 函数可以为我做到这一点?)
Hello I am trying to write a php function/class that will connect to a remote (java) server and send a message to it that has been encoded with a 256 byte RSA block using a public key.
The github of the java server is here : https://github.com/vexsoftware/votifier
(search for: Protocol Documentation).
This is how i have to send the data. Now my problem is that:
a) the public key is a continuous string.
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsdG2qEpV74TQOwJEXU6BCBoXTLPXEG/Q5P3pkhpn433bStahMbqHROda7QgInfqMHvkAoFm84mNzckH+YsBRIiCRw3c7vYArWfGmmqIdr/NiLdS/pmNm2PnPDRpk/VadCwcOlSoCP6/RjUncMKqv0LW89DtCum5MrptDCkSrAgRP5ZOAHoBJehk6YW2jfpD2CfBpQsu9v7UNLkZ3ZnNxWNCKnkxiB6mqA7aDFh9J4XA+9amBC5oj/ZVfwHNiXq3IB4tMdgZsx/+DesS2mZ0ML78fCKXSOfT4xbfSlGGIyI7QsfqzB4Fh8d9WUuxADeFznTVfy185pGinOpbjDuH8+wIDAQAB
and every function i found on the net doesnt do what i need.
b) The server responds either with a default message if you send the wrong data or (i am guessing here) an OK message when all is good.
Does anyone know how to make this RSA block ? I mean it has to be 256 bytes and i got no clue how to count bytes with PHP (or it doesnt matter ? an rsa function would do that for me ?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
公钥是一个base64编码的DER编码的SubjectPublicKey结构:参见RFC5280phpseclib 可以使用的密钥。
The public key is an base64-encoded DER-encoded SubjectPublicKey structure: see RFC5280 for details. There is a PHP method to do the bas64 decoding, and certainly something out there to decode the result. You can convert the key with openssl rsa into something that phpseclib can work with, for example.