开发者

Create a 256 byte RSA encrypted block from a public key

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 ?)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜